SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Incorrect Syntax near GO


Incorrect Syntax near GO

Author
Message
jaura
jaura
SSC-Enthusiastic
SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)

Group: General Forum Members
Points: 127 Visits: 33
When I executes Database creation sqlscript programmatically through .NET. It gives "Incorrect syntax near 'GO'.". My sql script is

USE [master]
GO

/****** Object: Database [test] Script Date: 04/06/2010 14:30:46 ******/
CREATE DATABASE [test] ON PRIMARY
( NAME = N'test', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\test.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'test_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\test_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO

ALTER DATABASE [test] SET COMPATIBILITY_LEVEL = 100
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [test].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [test] SET ANSI_NULL_DEFAULT OFF
GO

ALTER DATABASE [test] SET ANSI_NULLS OFF
GO

ALTER DATABASE [test] SET ANSI_PADDING OFF
GO

ALTER DATABASE [test] SET ANSI_WARNINGS OFF
GO

ALTER DATABASE [test] SET ARITHABORT OFF
GO

ALTER DATABASE [test] SET AUTO_CLOSE OFF
GO

ALTER DATABASE [test] SET AUTO_CREATE_STATISTICS ON
GO

ALTER DATABASE [test] SET AUTO_SHRINK OFF
GO

ALTER DATABASE [test] SET AUTO_UPDATE_STATISTICS ON
GO

ALTER DATABASE [test] SET CURSOR_CLOSE_ON_COMMIT OFF
GO

ALTER DATABASE [test] SET CURSOR_DEFAULT GLOBAL
GO

ALTER DATABASE [test] SET CONCAT_NULL_YIELDS_NULL OFF
GO

ALTER DATABASE [test] SET NUMERIC_ROUNDABORT OFF
GO

ALTER DATABASE [test] SET QUOTED_IDENTIFIER OFF
GO

ALTER DATABASE [test] SET RECURSIVE_TRIGGERS OFF
GO

ALTER DATABASE [test] SET DISABLE_BROKER
GO

ALTER DATABASE [test] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO

ALTER DATABASE [test] SET DATE_CORRELATION_OPTIMIZATION OFF
GO

ALTER DATABASE [test] SET TRUSTWORTHY OFF
GO

ALTER DATABASE [test] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO

ALTER DATABASE [test] SET PARAMETERIZATION SIMPLE
GO

ALTER DATABASE [test] SET READ_COMMITTED_SNAPSHOT OFF
GO

ALTER DATABASE [test] SET HONOR_BROKER_PRIORITY OFF
GO

ALTER DATABASE [test] SET READ_WRITE
GO

ALTER DATABASE [test] SET RECOVERY SIMPLE
GO

ALTER DATABASE [test] SET MULTI_USER
GO

ALTER DATABASE [test] SET PAGE_VERIFY CHECKSUM
GO

ALTER DATABASE [test] SET DB_CHAINING OFF
GO




Please help me
Dave Ballantyne
Dave Ballantyne
SSCertifiable
SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)

Group: General Forum Members
Points: 7416 Visits: 8370
GO as a command means nothing to Sqlserver. It is used by management studio to break the commands into separate batches. You need to send you commands in one block (without GO) or separate statements.



Clear Sky SQL
My Blog
jaura
jaura
SSC-Enthusiastic
SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)

Group: General Forum Members
Points: 127 Visits: 33
So how can I create scripts without Go using sql management studio
Dave Ballantyne
Dave Ballantyne
SSCertifiable
SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)

Group: General Forum Members
Points: 7416 Visits: 8370
You dont.

You need to send the commands batches ( ie each GO block) separately to SQLServer.



Clear Sky SQL
My Blog
ColdCoffee
ColdCoffee
SSCrazy Eights
SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)

Group: General Forum Members
Points: 9103 Visits: 5555
One doubt mate, are u trying to run this piece of code in SSMS 2005 or SSMS 2008?
jaura
jaura
SSC-Enthusiastic
SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)

Group: General Forum Members
Points: 127 Visits: 33
Its SSMS 2008.
ColdCoffee
ColdCoffee
SSCrazy Eights
SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)

Group: General Forum Members
Points: 9103 Visits: 5555
For SQL Server 2005, the compatiblity level can maximum be 90 and there is no command like HONOR_BROKER_PRIORITY

I tried this code in both SQL 2005 and 2008. i got error for the 2 properties i said above for 2005 and in 2008 it got compiled well...
Dave Ballantyne
Dave Ballantyne
SSCertifiable
SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)

Group: General Forum Members
Points: 7416 Visits: 8370
So why state, "sqlscript programmatically through .NET" ?



Clear Sky SQL
My Blog
ColdCoffee
ColdCoffee
SSCrazy Eights
SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)

Group: General Forum Members
Points: 9103 Visits: 5555
Hmmm..

Tel me if u did this:
1. You Right-click on the database, "Create To" to a new SQL Server Window
2. SAve this script as .sql file
3. And now u are trying to run this .sql file using some .Net code.

Is that right man? or are u trying to run the script from SSMS itself??
jaura
jaura
SSC-Enthusiastic
SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)SSC-Enthusiastic (127 reputation)

Group: General Forum Members
Points: 127 Visits: 33
Yes you are right. I am doing these steps.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search