|
|
Hi all. I am using Microsoft SQL Server 2008 Management Studio. I have been trying to create a database (containing tables etc) from a query file (Delivery.sql).
In the Object explorer I right-clicked Database folder and created the "Delivery database". I then clicked New Query and pasted the contents of Delivery.sql (from notepad) into the new query.
Now when I execute this code, it says it has completed successfully, but in the Object Explorer the "Delivery database" does not contain any tables . I am confused and am in need of help . Thanks.
Here is the image of the object explorer: http://imageshack.us/a/img694/7558/sqlobjectexplorerp.png[^]
Here is the code of the query file (Delivery.sql):
USE [Delivery database]
GO
CREATE DATABASE [Delivery] ON PRIMARY
( NAME = N'Delivery', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\Delivery.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'Delivery_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\Delivery_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [Delivery] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [Delivery database].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [Delivery] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [Delivery] SET ANSI_NULLS OFF
GO
ALTER DATABASE [Delivery] SET ANSI_PADDING OFF
GO
ALTER DATABASE [Delivery] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [Delivery] SET ARITHABORT OFF
GO
ALTER DATABASE [Delivery] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [Delivery] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [Delivery] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [Delivery] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [Delivery] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [Delivery] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [Delivery] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [Delivery] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [Delivery] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [Delivery] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [Delivery] SET DISABLE_BROKER
GO
ALTER DATABASE [Delivery] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [Delivery] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [Delivery] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [Delivery] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [Delivery] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [Delivery] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [Delivery] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [Delivery] SET READ_WRITE
GO
ALTER DATABASE [Delivery] SET RECOVERY SIMPLE
GO
ALTER DATABASE [Delivery] SET MULTI_USER
GO
ALTER DATABASE [Delivery] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [Delivery] SET DB_CHAINING OFF
GO
|
|
|
|
|
Did you refresh the Object Explorer after creation?
|
|
|
|
|
Yeah it didnt work. However I realised that this script didnt have any code to create tables so I used a different script with "CREATE TABLE" code in the query and it worked! thanks
|
|
|
|
|
Hi there, I just want to get some opinions on which tool to use to diagram an ER Picture of a DB model having approx 900 tables, but ....
I have tried a few (Erwin, Aqua Data Studio, Powerdesigner and a few more - even tried Visio). All have problems because I just have the tables - no modelled relations (a pretty bad model but that's the fact). A few PK's almost no FK's. All this is in the code layer or even in the head of the developer only. I want to put all this together to graficaly illustrate our data structure.
What I need to get this job done is
- reverse engineer to have a starting Point (Oracle 11 and MSSQL2008) to have all tables in this tool (on a hidden layer if possible)
- Select some tables and copy them (link) to a new layer to switch visibility depending on the development task that i want to give to a developer
- Display compact (square with table Name, and PKs only). Hide all other columns
- a good way to arrange everything on Screen to avoid crossing Relations and to nicely arrange every table and relation
- toggle visibility of a layer
- a certain table appears on more than one layer depending on the development tasks
- something that makes it all "nice" to present to the Boss.
- crow feet Notation
I more search a documentation type of drawing tool rather than a physical modelling. Some of the tested tools started with creating "alter table add column" scripts that immediately change my DB. This is something I dont need.
Any idea out there?
Any tools avail that accomplish this task?
Thanks a lot in advance
Ole
|
|
|
|
|
I'm using Oracle SQL Developer Data Modeler[^]
ole.Grossklaus@gmx.de wrote: - reverse engineer to have a starting Point (Oracle 11 and MSSQL2008) to have all tables in this tool (on a hidden layer if possible Supports Oracle (duh), MSSQL and DB2.
ole.Grossklaus@gmx.de wrote: - Select some tables and copy them (link) to a new layer to switch visibility depending on the development task that i want to give to a developer It's tab based, you can create a new view with a subset of existing tables.
ole.Grossklaus@gmx.de wrote: - Display compact (square with table Name, and PKs only). Hide all other columns Yes
ole.Grossklaus@gmx.de wrote: - a good way to arrange everything on Screen to avoid crossing Relations and to nicely arrange every table and relation Auto arrange sucks big donkey balls. But it does in all tools in my opinion. So it's up to you to do the work I'm afraid.
ole.Grossklaus@gmx.de wrote: - toggle visibility of a layer It's tab based, and you can have one or more windows and move the tabs between them.
ole.Grossklaus@gmx.de wrote: - a certain table appears on more than one layer depending on the development tasks A table can appear in many windows/views, not sure if this is what you mean.
ole.Grossklaus@gmx.de wrote: - something that makes it all "nice" to present to the Boss. Use Powerpoint.
ole.Grossklaus@gmx.de wrote: - crow feet Notation Barker notation - check
Be excellent to each other. And... PARTY ON, DUDES!
Abraham Lincoln
|
|
|
|
|
Microsoft SQL Server 2012 introduces 14 new built-in functions. These new functions are:
Conversion functions
> PARSE
> TRY_CONVERT
> TRY_PARSE
Date and time functions
> DATEFROMPARTS
> DATETIME2FROMPARTS
> DATETIMEFROMPARTS
>DATETIMEOFFSETFROMPARTS
> EOMONTH
> SMALLDATETIMEFROMPARTS
> TIMEFROMPARTS
Logical functions
> CHOOSE
> IIF
String functions
> CONCAT
> FORMAT
|
|
|
|
|
|
Karthik_J, Coimbatore wrote: Microsoft SQL Server 2012 introduces 14 new built-in functions.
And you posted this to demonstrate that you can read documentation maybe?
|
|
|
|
|
I am using an Access 2000 database file. When parsing user input that has SQL reserved characters, I put [] around any reserved characters I find. This works fine, except when dealing with %s.
I have a table named "Foo", with two rows:
Type as text, SubType as text, with two rows of values:
"Sales Tax (%)", "NY"
"Sales Tax (%)", PA"
When I execute the following:
SELECT * From Foo WHERE Type LIKE '%Sales Tax ([%])%'
I get the rows returned I expect, where the row has a value in the Type column of "Sales Tax (%)"
But when I execute:
SELECT * From Foo WHERE Type = 'Sales Tax ([%])'
No rows are returned
Even if I omit the parenthesis around the % sign, it does not find the rows.
Is there something odd I am doing wrong, perhaps specific to Access SQL?
|
|
|
|
|
<edit>move on, nothing to see here except the proofs of to little sleep.</edit>
Access isn't SQLServer. You're not supposed to use brackets either.
I would strongly recommend renaming the offending fields.
More info here[^].
I especially like this part: "However, if you do use the special characters, you may experience unexpected errors."
Be excellent to each other. And... PARTY ON, DUDES!
Abraham Lincoln
modified 10-May-13 10:49am.
|
|
|
|
|
I am not sure I understand. The % character does not appear in any field names, or table names. The data type of both fields, named "Type" and "SubType" are text, and that text data can contain a % character as part of whatever text the user chooses to enter into the field, along with other special characters.
(I have an application where I prompt the user to enter a text value for the Type and SubType fields, and I save that text into those fields as a new row. The problem I have is that the user can enter a % as part of their user-entered text, and I need to be able to search on text field data for a % character they may have entered; I can put brackets around all other special characters when building my query and they are found fine, but the % just doesn't work for some reason when used in an = query.
|
|
|
|
|
My bad, I think my brain went to sleep before the rest of me did.
Be excellent to each other. And... PARTY ON, DUDES!
Abraham Lincoln
|
|
|
|
|
JohnBlocker wrote: Even if I omit the parenthesis around the % sign, it does not find the rows.
So this:
SELECT * From Foo WHERE Type = 'Sales Tax (%)'
returns nothing?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
JohnBlocker wrote: When parsing user input that has SQL reserved characters
Parsing how? What application/language are you doing this in?
|
|
|
|
|
This could be an odd question, but, you tried
Quote: SELECT * From Foo WHERE Type = 'Sales Tax ([%])'
Cause, when your using '=' command, means that is HAS to be egual.
|
|
|
|
|
Hi everyone
I have a question,is it correct
connected data objects consist of connection,command,reader and dataadapter(why we need to DataAdapter in a connected model?),transaction,....
disconnected data objects consist of dataset,dataTable,datarow,dataadapter
so we have two main models connected and disconnected.
what is the rule of DataAdapter in connected model? why do we need to use of a dataadpter to fill a dataset like this in a connected model?
.....
sqlDataAdapter = new SqlDataAdapter(cmdString, sqlConnection);
sqlDataAdapter.SelectCommand = sqlCommand;
SqlDataAdapter sqlDataAdapter;
sqlDataSet = new DataSet();
sqlDataSet.Clear();
int intValue = sqlDataAdapter.Fill(sqlDataSet);
is it right we are shifting of connected model to disconnected model,if yes why?
|
|
|
|
|
I would not include DataAdapter in the "connected" category.
The "connected" paradigm is still appropriate for many applications, but less so with distributed applications.
DataAdapters cause me nothing but trouble; I don't use them. 
|
|
|
|
|
Is it correct we can fill a dataset with connected objects(connection,command,dataadapter) and without them(with data source window)? if yes so we are using of the connected objects to fill a disconnected object(dataset),right?
|
|
|
|
|
DataAdapters enable the disconnected paradigm.
|
|
|
|
|
And we can use of it form programming (dataset dt=new,....) and from toolbox in the visual studio,right?
|
|
|
|
|
what diffrence betwwen in two below table
with cteStudent(ID,Name,Family)
AS
(
select ID,Name,Family from tblStudent
)
select * from cteStudent
SELECT ID,Name,Family into #tblTemp FROM tblStudent
select * from #tblTemp
assume that i remove temp table after run two query.
which of this two query is better than another (in performance aspect)
thanks for any help
t
|
|
|
|
|
mehdi.sabet wrote: what diffrence betwwen in two below table The first will only work on Sql2005+, since that's when the Common Table Expression was introduced.
mehdi.sabet wrote: assume that i remove temp table after run two query.
which of this two query is better than another (in performance aspect)
What makes you think there's much difference in terms of speed?
It's not like there's "duplicate" functionality and programmers having to look for the "most efficient" version of a routine. Your hunting for speed in the wrong place.
Now, to answer the question; the second version is preferred, it'd be unnoticeable faster. A good reason would be if you'd need to do multiple mutations on the same set. A good reason to use the CTE would be recursion.
Good luck.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
On SQLServer you can think of the CTE as an inline view, while the temporary table will be materialized and can be indexed.
mehdi.sabet wrote: which of this two query is better than another (in performance aspect)
In this specific case probably the CTE, because the select is straight forward and directly streamed to output.
While the temp table needs to be materialized, if even just in memory, and selected from memory to the output.
If the CTE/temptable would be used in more than one place and/or the select could benefit from indexing the temptable, the result could be quite different.
On Oracle it's a bit different though. There a CTE can be materialized.
Be excellent to each other. And... PARTY ON, DUDES!
Abraham Lincoln
|
|
|
|
|
As Jörgen Andersson said, cte is faster cause there's no IO on disk, it's just memory.
when you declare an #Temporary, you really create the table on your tempdb, that means that you have to write on disk. For a long range of information, you can say that is not that fast as use an cte.
If i'm not wrong, declare an variable ( Declare @Table Table (column) ) is faster as use an CTE , and less complicate, cause just create the table on Memory. BUT, you got to remember, that this will only use memory, for a long range of information, this mean that will use a lot of ram.
|
|
|
|