Hi all I have a .sql ..which is not a stored proc , but kind of few sql cmnds and then a stored proc also... I want to read tht sql file in my C# code and execute it. My code looks like this.... FileStream file= new FileStream("Filename.sql",System.IO.FileMode.Open); StreamReader sr=new StreamReader(file); string str_create=sr.ReadToEnd(); sr.Close(); file.Close(); SqlCommand sp_createcmd=new SqlCommand(str_create,conn); conn.Open(); sp_createcmd.ExecuteNonQuery(); conn.Close(); ....This code is giving me exceptions in the .sql file........... My sql file looks like this...... USE Performance GO if exists (select * from sysobjects where id = object_id(N'[dbo].[AddEvent]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[AddEvent] GO USE Performance GO SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO CREATE PROC dbo.AddEvent ( @TraceID int, @EventList varchar(1000), @ColumnList varchar(1000) = NULL ) AS BEGIN CREATE TABLE #EventList ( .....................etc etc../. So my C# code gives me exceptions like Create PROC shd be the first like...etc.etc.. It seems its trying to run this as an stored proc....I cannot change my stored proc code....so How do i execute this then... Any help would be gr8ly appreciated Thanks, Deeps |