Hello,
I have a script that creates a new database table called MYDATABAE, then it
will use USE [MYDATABASE]
to create tables.
Well.. It doesn't even get past the parser. It stops saying:
Could not locate entry in sysdatabases for database 'MYDATABASE'
Below you will see some of the script I am attempting to run, by the way,
this was created using SqlServer express management studio. At the bottom
of the script, see where the parser gives the error.
USE [master]
GO
/****** Object: Database [MYDATABASE] Script Date: 08/28/2006 10:18:
24
******/
IF NOT EXISTS (SELECT name FROM sys.databases WHERE name = N'MYDATABASE')
BEGIN
CREATE DATABASE [MYDATABASE] ON PRIMARY
( NAME = N'MYDATABASE', FILENAME = N'c:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\DATA\MYDATABASE.mdf' , SIZE = 11456KB , MAXSIZE =
UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'MYDATABASE_log', FILENAME = N'c:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\DATA\MYDATABASE_log.LDF' , SIZE = 26816KB , MAXSIZE =
2048GB , FILEGROWTH = 10%)
END
GO
EXEC dbo.sp_dbcmptlevel @.dbname=N'MYDATABASE', @.new_cmptlevel=90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInsta
lled'))
begin
EXEC [MYDATABASE].[dbo].[sp_fulltext_database] @.action = 'enable
'
end
GO
ALTER DATABASE [MYDATABASE] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [MYDATABASE] SET ANSI_NULLS OFF
GO
ALTER DATABASE [MYDATABASE] SET ANSI_PADDING OFF
GO
ALTER DATABASE [MYDATABASE] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [MYDATABASE] SET ARITHABORT OFF
GO
ALTER DATABASE [MYDATABASE] SET AUTO_CLOSE ON
GO
ALTER DATABASE [MYDATABASE] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [MYDATABASE] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [MYDATABASE] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [MYDATABASE] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [MYDATABASE] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [MYDATABASE] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [MYDATABASE] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [MYDATABASE] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [MYDATABASE] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [MYDATABASE] SET ENABLE_BROKER
GO
ALTER DATABASE [MYDATABASE] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [MYDATABASE] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [MYDATABASE] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [MYDATABASE] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [MYDATABASE] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [MYDATABASE] SET READ_WRITE
GO
ALTER DATABASE [MYDATABASE] SET RECOVERY SIMPLE
GO
ALTER DATABASE [MYDATABASE] SET MULTI_USER
GO
ALTER DATABASE [MYDATABASE] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [MYDATABASE] SET DB_CHAINING OFF
GO
USE [MYDATABASE] > this is where error occurs!
GO
... More sql ...
I am not sure what happended. This was working earlier today, but not
anymore...
Any and help would be appreciated!
Thanks,
BryanI ran the script you posted without error. Perhaps there is a
non-displayable character in your actual script. You might try re-typing
the limes immediately preceding and following the statement.
Hope this helps.
Dan Guzman
SQL Server MVP
"Bryan" <BryanZM@.nospam.nospam> wrote in message
news:efZc8hvyGHA.4648@.TK2MSFTNGP04.phx.gbl...
> Hello,
> I have a script that creates a new database table called MYDATABAE, then
> it will use USE [MYDATABASE]
> to create tables.
> Well.. It doesn't even get past the parser. It stops saying:
> Could not locate entry in sysdatabases for database 'MYDATABASE'
>
> Below you will see some of the script I am attempting to run, by the way,
> this was created using SqlServer express management studio. At the bottom
> of the script, see where the parser gives the error.
> USE [master]
> GO
> /****** Object: Database [MYDATABASE] Script Date: 08/28/2006 10:1
8:24
> ******/
> IF NOT EXISTS (SELECT name FROM sys.databases WHERE name = N'MYDATABASE')
> BEGIN
> CREATE DATABASE [MYDATABASE] ON PRIMARY
> ( NAME = N'MYDATABASE', FILENAME = N'c:\Program Files\Microsoft SQL
> Server\MSSQL.1\MSSQL\DATA\MYDATABASE.mdf' , SIZE = 11456KB , MAXSIZE =
> UNLIMITED, FILEGROWTH = 1024KB )
> LOG ON
> ( NAME = N'MYDATABASE_log', FILENAME = N'c:\Program Files\Microsoft SQL
> Server\MSSQL.1\MSSQL\DATA\MYDATABASE_log.LDF' , SIZE = 26816KB , MAXSIZE =
> 2048GB , FILEGROWTH = 10%)
> END
> GO
> EXEC dbo.sp_dbcmptlevel @.dbname=N'MYDATABASE', @.new_cmptlevel=90
> GO
> IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInsta
lled'))
> begin
> EXEC [MYDATABASE].[dbo].[sp_fulltext_database] @.action = 'enab
le'
> end
> GO
> ALTER DATABASE [MYDATABASE] SET ANSI_NULL_DEFAULT OFF
> GO
> ALTER DATABASE [MYDATABASE] SET ANSI_NULLS OFF
> GO
> ALTER DATABASE [MYDATABASE] SET ANSI_PADDING OFF
> GO
> ALTER DATABASE [MYDATABASE] SET ANSI_WARNINGS OFF
> GO
> ALTER DATABASE [MYDATABASE] SET ARITHABORT OFF
> GO
> ALTER DATABASE [MYDATABASE] SET AUTO_CLOSE ON
> GO
> ALTER DATABASE [MYDATABASE] SET AUTO_CREATE_STATISTICS ON
> GO
> ALTER DATABASE [MYDATABASE] SET AUTO_SHRINK OFF
> GO
> ALTER DATABASE [MYDATABASE] SET AUTO_UPDATE_STATISTICS ON
> GO
> ALTER DATABASE [MYDATABASE] SET CURSOR_CLOSE_ON_COMMIT OFF
> GO
> ALTER DATABASE [MYDATABASE] SET CURSOR_DEFAULT GLOBAL
> GO
> ALTER DATABASE [MYDATABASE] SET CONCAT_NULL_YIELDS_NULL OFF
> GO
> ALTER DATABASE [MYDATABASE] SET NUMERIC_ROUNDABORT OFF
> GO
> ALTER DATABASE [MYDATABASE] SET QUOTED_IDENTIFIER OFF
> GO
> ALTER DATABASE [MYDATABASE] SET RECURSIVE_TRIGGERS OFF
> GO
> ALTER DATABASE [MYDATABASE] SET ENABLE_BROKER
> GO
> ALTER DATABASE [MYDATABASE] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
> GO
> ALTER DATABASE [MYDATABASE] SET DATE_CORRELATION_OPTIMIZATION OFF
> GO
> ALTER DATABASE [MYDATABASE] SET TRUSTWORTHY OFF
> GO
> ALTER DATABASE [MYDATABASE] SET ALLOW_SNAPSHOT_ISOLATION OFF
> GO
> ALTER DATABASE [MYDATABASE] SET PARAMETERIZATION SIMPLE
> GO
> ALTER DATABASE [MYDATABASE] SET READ_WRITE
> GO
> ALTER DATABASE [MYDATABASE] SET RECOVERY SIMPLE
> GO
> ALTER DATABASE [MYDATABASE] SET MULTI_USER
> GO
> ALTER DATABASE [MYDATABASE] SET PAGE_VERIFY CHECKSUM
> GO
> ALTER DATABASE [MYDATABASE] SET DB_CHAINING OFF
> GO
> USE [MYDATABASE] > this is where error occurs!
> GO
> ... More sql ...
>
> I am not sure what happended. This was working earlier today, but not
> anymore...
> Any and help would be appreciated!
> Thanks,
> Bryan
>
>|||Hello Bryan,
I've also tried the script you pasted and it runs corretly on my side
also(except that I change the database file path according to my local
machine).
As for the error you mentioned, does it only occur when you use "Parse"
action to check the syntax? If so, the parser in management studio will
report error against the non-existing database since it hasn't been created
at parse time. However, the script is still able to be executed without any
problem.
Please feel free to post here if there is anything we can help.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.|||Ok, for some miraculous rerason it works now. But it created another
problem. I am now trying ot execute the same script in c# with a connection
to master. It does not work!!! I get an error like this:
Incorrect syntax near 'GO'.\r\nIncorrect syntax near the keyword
'EXEC'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near the keyword
'ALTER'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near 'GO'.\r\nCould
not locate entry in sysdatabases for database 'GOIDB'. No entry found with
that name. Make sure that the name is entered correctly."
I can remove everything but the foloowing and it will execute fine:
It creates the Database without a hitch...
Any more suggestions?
Thanks!
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:u8jKcWwyGHA.1292@.TK2MSFTNGP03.phx.gbl...[vbcol=seagreen]
>I ran the script you posted without error. Perhaps there is a
>non-displayable character in your actual script. You might try re-typing
>the limes immediately preceding and following the statement.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Bryan" <BryanZM@.nospam.nospam> wrote in message
> news:efZc8hvyGHA.4648@.TK2MSFTNGP04.phx.gbl...
>|||Bryan wrote:
> Ok, for some miraculous rerason it works now. But it created another
> problem. I am now trying ot execute the same script in c# with a connectio
n
> to master. It does not work!!! I get an error like this:
> Incorrect syntax near 'GO'.\r\nIncorrect syntax near the keyword
> 'EXEC'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near the keywor
d
> 'ALTER'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
> 'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
> 'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
> 'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
> 'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
> 'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
> 'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
> 'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
> 'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
> 'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
> 'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
> 'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near
> 'GO'.\r\nIncorrect syntax near 'GO'.\r\nIncorrect syntax near 'GO'.\r\nCou
ld
> not locate entry in sysdatabases for database 'GOIDB'. No entry found with
> that name. Make sure that the name is entered correctly."
>
"GO" is not a SQL command, it's a batch seperator used inside a script
file that is executed within QA/Management Studio/ISQL
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||Thanks,
I replaced the GO with ";" and it appears I am almost there, now I get this
error:
Could not locate entry in sysdatabases for database 'MYDATABASE'. No entry
found with that name. Make sure that the name is entered correctly.
when the execution gets here:
USE [MYDATABASE]
Shouldn't it be creating my database, and not throw this error? I am
stumped!
Here is the script:
USE [master]
/****** Object: Database [MYDATABASE] Script Date: 08/28/2006 10:18:
24
******/
IF NOT EXISTS (SELECT name FROM sys.databases WHERE name = N'MYDATABASE')
BEGIN
CREATE DATABASE [MYDATABASE] ON PRIMARY
( NAME = N'MYDATABASE', FILENAME = N'c:\\Program Files\\Microsoft SQL
Server\\MSSQL.1\\MSSQL\\DATA\\MYDATABASE.mdf' , SIZE = 11456KB , MAXSIZE =
UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'MYDATABASE_log', FILENAME = N'c:\\Program Files\\Microsoft SQL
Server\\MSSQL.1\\MSSQL\\DATA\\MYDATABASE_log.LDF' , SIZE = 26816KB , MAXSIZE
= 2048GB , FILEGROWTH = 10%)
END
;
EXEC dbo.sp_dbcmptlevel @.dbname=N'MYDATABASE', @.new_cmptlevel=90
;
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInsta
lled')) begin EXEC
[MYDATABASE].[dbo].[sp_fulltext_database] @.action = 'enable' end
;
ALTER DATABASE [MYDATABASE] SET ANSI_NULL_DEFAULT OFF
;
ALTER DATABASE [MYDATABASE] SET ANSI_NULLS OFF
;
ALTER DATABASE [MYDATABASE] SET ANSI_PADDING OFF
;
ALTER DATABASE [MYDATABASE] SET ANSI_WARNINGS OFF
;
ALTER DATABASE [MYDATABASE] SET ARITHABORT OFF
;
ALTER DATABASE [MYDATABASE] SET AUTO_CLOSE ON
;
ALTER DATABASE [MYDATABASE] SET AUTO_CREATE_STATISTICS ON
;
ALTER DATABASE [MYDATABASE] SET AUTO_SHRINK OFF
;
ALTER DATABASE [MYDATABASE] SET AUTO_UPDATE_STATISTICS ON
;
ALTER DATABASE [MYDATABASE] SET CURSOR_CLOSE_ON_COMMIT OFF
;
ALTER DATABASE [MYDATABASE] SET CURSOR_DEFAULT GLOBAL
;
ALTER DATABASE [MYDATABASE] SET CONCAT_NULL_YIELDS_NULL OFF
;
ALTER DATABASE [MYDATABASE] SET NUMERIC_ROUNDABORT OFF
;
ALTER DATABASE [MYDATABASE] SET QUOTED_IDENTIFIER OFF
;
ALTER DATABASE [MYDATABASE] SET RECURSIVE_TRIGGERS OFF
;
ALTER DATABASE [MYDATABASE] SET ENABLE_BROKER
;
ALTER DATABASE [MYDATABASE] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
;
ALTER DATABASE [MYDATABASE] SET DATE_CORRELATION_OPTIMIZATION OFF
;
ALTER DATABASE [MYDATABASE] SET TRUSTWORTHY OFF
;
ALTER DATABASE [MYDATABASE] SET ALLOW_SNAPSHOT_ISOLATION OFF
;
ALTER DATABASE [MYDATABASE] SET PARAMETERIZATION SIMPLE
;
ALTER DATABASE [MYDATABASE] SET READ_WRITE
;
ALTER DATABASE [MYDATABASE] SET RECOVERY SIMPLE
;
ALTER DATABASE [MYDATABASE] SET MULTI_USER
;
ALTER DATABASE [MYDATABASE] SET PAGE_VERIFY CHECKSUM
;
ALTER DATABASE [MYDATABASE] SET DB_CHAINING OFF
;
USE [MYDATABASE]
more stuff...
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:44F45F39.80506@.realsqlguy.com...
> Bryan wrote:
> "GO" is not a SQL command, it's a batch seperator used inside a script
> file that is executed within QA/Management Studio/ISQL
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||The issue you're running into is that the parser parses a complete batch
before it executes it. When you used the script with a GO after each line,
each line was sent to the parser as a separate batch. Now, you are sending
all the lines to the parser in a single batch. When it gets to the USE
statement, the database doesn't exist because the batch hasn't been
executed. You need to split the commands into separate batches - execute
everything up to the USE as one batch and then do the USE as a separate
batch.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Bryan" <BryanZM@.nospam.nospam> wrote in message
news:%23BaPDf4yGHA.4232@.TK2MSFTNGP05.phx.gbl...
> Thanks,
> I replaced the GO with ";" and it appears I am almost there, now I get
> this error:
> Could not locate entry in sysdatabases for database 'MYDATABASE'. No entry
> found with that name. Make sure that the name is entered correctly.
>
> when the execution gets here:
> USE [MYDATABASE]
>
> Shouldn't it be creating my database, and not throw this error? I am
> stumped!
> Here is the script:
> USE [master]
> /****** Object: Database [MYDATABASE] Script Date: 08/28/2006 10:1
8:24
> ******/
> IF NOT EXISTS (SELECT name FROM sys.databases WHERE name = N'MYDATABASE')
> BEGIN
> CREATE DATABASE [MYDATABASE] ON PRIMARY
> ( NAME = N'MYDATABASE', FILENAME = N'c:\\Program Files\\Microsoft SQL
> Server\\MSSQL.1\\MSSQL\\DATA\\MYDATABASE.mdf' , SIZE = 11456KB , MAXSIZE =
> UNLIMITED, FILEGROWTH = 1024KB )
> LOG ON
> ( NAME = N'MYDATABASE_log', FILENAME = N'c:\\Program Files\\Microsoft SQL
> Server\\MSSQL.1\\MSSQL\\DATA\\MYDATABASE_log.LDF' , SIZE = 26816KB ,
> MAXSIZE = 2048GB , FILEGROWTH = 10%)
> END
> ;
>
> EXEC dbo.sp_dbcmptlevel @.dbname=N'MYDATABASE', @.new_cmptlevel=90
> ;
> IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInsta
lled')) begin EXEC
> [MYDATABASE].[dbo].[sp_fulltext_database] @.action = 'enable' e
nd
> ;
> ALTER DATABASE [MYDATABASE] SET ANSI_NULL_DEFAULT OFF
> ;
> ALTER DATABASE [MYDATABASE] SET ANSI_NULLS OFF
> ;
> ALTER DATABASE [MYDATABASE] SET ANSI_PADDING OFF
> ;
> ALTER DATABASE [MYDATABASE] SET ANSI_WARNINGS OFF
> ;
> ALTER DATABASE [MYDATABASE] SET ARITHABORT OFF
> ;
> ALTER DATABASE [MYDATABASE] SET AUTO_CLOSE ON
> ;
> ALTER DATABASE [MYDATABASE] SET AUTO_CREATE_STATISTICS ON
> ;
> ALTER DATABASE [MYDATABASE] SET AUTO_SHRINK OFF
> ;
> ALTER DATABASE [MYDATABASE] SET AUTO_UPDATE_STATISTICS ON
> ;
> ALTER DATABASE [MYDATABASE] SET CURSOR_CLOSE_ON_COMMIT OFF
> ;
> ALTER DATABASE [MYDATABASE] SET CURSOR_DEFAULT GLOBAL
> ;
> ALTER DATABASE [MYDATABASE] SET CONCAT_NULL_YIELDS_NULL OFF
> ;
> ALTER DATABASE [MYDATABASE] SET NUMERIC_ROUNDABORT OFF
> ;
> ALTER DATABASE [MYDATABASE] SET QUOTED_IDENTIFIER OFF
> ;
> ALTER DATABASE [MYDATABASE] SET RECURSIVE_TRIGGERS OFF
> ;
> ALTER DATABASE [MYDATABASE] SET ENABLE_BROKER
> ;
> ALTER DATABASE [MYDATABASE] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
> ;
> ALTER DATABASE [MYDATABASE] SET DATE_CORRELATION_OPTIMIZATION OFF
> ;
> ALTER DATABASE [MYDATABASE] SET TRUSTWORTHY OFF
> ;
> ALTER DATABASE [MYDATABASE] SET ALLOW_SNAPSHOT_ISOLATION OFF
> ;
> ALTER DATABASE [MYDATABASE] SET PARAMETERIZATION SIMPLE
> ;
> ALTER DATABASE [MYDATABASE] SET READ_WRITE
> ;
> ALTER DATABASE [MYDATABASE] SET RECOVERY SIMPLE
> ;
> ALTER DATABASE [MYDATABASE] SET MULTI_USER
> ;
> ALTER DATABASE [MYDATABASE] SET PAGE_VERIFY CHECKSUM
> ;
> ALTER DATABASE [MYDATABASE] SET DB_CHAINING OFF
> ;
> USE [MYDATABASE]
>
> more stuff...
> "Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
> news:44F45F39.80506@.realsqlguy.com...
>|||Bryan wrote:
> Thanks,
> I replaced the GO with ";" and it appears I am almost there, now I get thi
s
> error:
> Could not locate entry in sysdatabases for database 'MYDATABASE'. No entry
> found with that name. Make sure that the name is entered correctly.
>
> when the execution gets here:
> USE [MYDATABASE]
>
> Shouldn't it be creating my database, and not throw this error? I am
> stumped!
>
Think about what's happening here. You're issuing a series of commands
to SQL as a single batch. That entire batch is compiled, and then
executed. At the time of compilation, the database doesn't exist, thus
an error is thrown.
In your original attempt, you were seperating commands into seperate
batches using the "GO" seperator. That, unfortunately, doesn't work
outside of a script file that is run through QA or ISQL.
It's a bit unusual for an application to create a database on the fly
like this. If you really must create this database this way, you're
going to have to do it in two steps. The first step will create the
database. The second, seperate, step will run the rest of the operation.
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||Thanks for Roger and Tracy's input.
Hi Bryan,
I agree with Roger that when you send all the T-SQL block through one C#
net sqlcommand, it is just as you execute them in a single batch and the
T-SQL engine will report the error against the use statement on a
non-existing database. I suggest you separate the script into to parts,
create database and alter database and execute them in a separate
SqlCommand respectively.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.|||Thanks for all the help, I was able to get it to work.
Bryan .
Sunday, February 12, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment