Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Incorrect Syntax near GO Expand / Collapse
Author
Message
Posted Tuesday, April 6, 2010 3:17 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, January 25, 2011 1:51 AM
Points: 11, 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
Post #897407
Posted Tuesday, April 6, 2010 3:42 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 2:06 AM
Points: 1,768, Visits: 8,318
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
Kent user group
Post #897413
Posted Tuesday, April 6, 2010 3:47 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, January 25, 2011 1:51 AM
Points: 11, Visits: 33
So how can I create scripts without Go using sql management studio
Post #897416
Posted Tuesday, April 6, 2010 3:54 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 2:06 AM
Points: 1,768, Visits: 8,318
You dont.

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




Clear Sky SQL
My Blog
Kent user group
Post #897418
Posted Tuesday, April 6, 2010 4:00 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, December 11, 2014 5:03 PM
Points: 2,262, Visits: 5,427
One doubt mate, are u trying to run this piece of code in SSMS 2005 or SSMS 2008?
Post #897420
Posted Tuesday, April 6, 2010 4:03 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, January 25, 2011 1:51 AM
Points: 11, Visits: 33
Its SSMS 2008.
Post #897422
Posted Tuesday, April 6, 2010 4:06 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, December 11, 2014 5:03 PM
Points: 2,262, Visits: 5,427
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...
Post #897423
Posted Tuesday, April 6, 2010 4:07 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 2:06 AM
Points: 1,768, Visits: 8,318
So why state, "sqlscript programmatically through .NET" ?




Clear Sky SQL
My Blog
Kent user group
Post #897424
Posted Tuesday, April 6, 2010 4:16 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, December 11, 2014 5:03 PM
Points: 2,262, Visits: 5,427
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??
Post #897427
Posted Tuesday, April 6, 2010 4:19 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, January 25, 2011 1:51 AM
Points: 11, Visits: 33
Yes you are right. I am doing these steps.
Post #897428
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse