hi ,
look i have this query
USE [master]
GO
CREATE DATABASE [DLandS] ON PRIMARY
( NAME = N'DLandS', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\DLandS.mdf' , SIZE = 5120KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'DLandS_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\DLandS_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [DLandS] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [DLandS].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [DLandS] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [DLandS] SET ANSI_NULLS OFF
GO
ALTER DATABASE [DLandS] SET ANSI_PADDING OFF
GO
ALTER DATABASE [DLandS] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [DLandS] SET ARITHABORT OFF
GO
ALTER DATABASE [DLandS] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [DLandS] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [DLandS] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [DLandS] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [DLandS] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [DLandS] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [DLandS] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [DLandS] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [DLandS] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [DLandS] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [DLandS] SET DISABLE_BROKER
GO
ALTER DATABASE [DLandS] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [DLandS] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [DLandS] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [DLandS] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [DLandS] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [DLandS] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [DLandS] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [DLandS] SET READ_WRITE
GO
ALTER DATABASE [DLandS] SET RECOVERY FULL
GO
ALTER DATABASE [DLandS] SET MULTI_USER
GO
ALTER DATABASE [DLandS] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [DLandS] SET DB_CHAINING OFF
GO
EXEC sys.sp_db_vardecimal_storage_format N'DLandS', N'ON'
GO
USE [DLandS]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[attachment_tab](
[attachment_id] [bigint] NOT NULL,
[notes] [nvarchar](1000) NULL,
[attachment_name] [nvarchar](500) NULL,
[attachment_price] [money] NULL,
CONSTRAINT [PK_ATTACHMENT] PRIMARY KEY CLUSTERED
(
[attachment_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT [dbo].[attachment_tab] ([attachment_id], [notes], [attachment_name], [attachment_price]) VALUES (0, N'hhgg', N'hfghfg', 60.0000)
INSERT [dbo].[attachment_tab] ([attachment_id], [notes], [attachment_name], [attachment_price]) VALUES (1, NULL, N'enas saeek', 7.0000)
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Attachment_Seq](
[Seq] [bigint] NOT NULL,
[Count_Row] [bigint] NOT NULL,
CONSTRAINT [PK_ATTACHMENT_SEQ] PRIMARY KEY CLUSTERED
(
[Seq] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT [dbo].[Attachment_Seq] ([Seq], [Count_Row]) VALUES (25, 19)
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[Attachment_Update]
@attachment_id BIGINT,
@attachment_name NVARCHAR(500) ,
@attachment_price MONEY,
@notes nvarchar(1000)
AS
SET NOCOUNT ON begin transaction
update [dbo].[attachment_tab] set [attachment_id]=@attachment_id,
[attachment_name]=@attachment_name,
[attachment_price]=@attachment_price,[notes]=@notes
where [attachment_id]= @attachment_id
commit transaction
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[Attachment_Insert]
@attachment_name NVARCHAR(500) = '',
@attachment_price MONEY = 0,
@notes nvarchar(1000)
AS
SET NOCOUNT ON
DECLARE @attachment_id BIGINT;
SELECT TOP 1 @attachment_id= [Seq] FROM [dbo].[attachment_Seq]
INSERT INTO [dbo].[attachment_tab]([attachment_id],[attachment_name],[attachment_price],[notes])
VALUES (@attachment_id,@attachment_name,@attachment_price,@notes)
UPDATE [dbo].[attachment_Seq]
SET Seq=(@attachment_id+1)
, Count_Row =(Count_Row+1) commit transaction
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[Attachment_Delete]
@attachment_id bigint = 0
AS
SET NOCOUNT ON begin transaction
UPDATE [dbo].[attachment_Seq]
SET Count_Row= (Count_Row-1);
DELETE FROM [dbo].[attachment_tab]
WHERE [attachment_id]= @attachment_id
commit transaction
GO
but when i Execute this query is throw Exception
Like this
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near the keyword 'INSERT'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near the keyword 'INSERT'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Must declare the scalar variable "@attachment_id".
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Must declare the scalar variable "@attachment_name".
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
and this is code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.IO;
namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
string connsql = "Data Source=" + Environment.MachineName + ";Integrated Security=True;Pooling=False;MultipleActiveResultSets=False;Packet Size=4096";
SqlConnection conn = new SqlConnection(connsql);
conn.Open();
StreamReader readfilequery = new StreamReader(@"J:\Project\Finelf\Dental lab and Storeff\Main Form\query\script.sql");
string query = readfilequery.ReadToEnd();
SqlCommand commqnd = new SqlCommand(query, conn);
commqnd.ExecuteNonQuery();
}
}
}
help me ..............