How to execute .sql file in C# -Urgent

8 views
Skip to first unread message

Uma Devi

unread,
Jun 12, 2008, 10:49:31 AM6/12/08
to Techdot...@googlegroups.com
Hi,
I need to execute sql file through c# program.Some sql file takes some parameters that I need to pass the variables through C# program.Is there any way to do it.I found out that sqlcmd can be used by passing all parameters to sql file using Process class.But I am trying to find whether we can do this programmatically in C#.
 
Please help.
Thanks,
Uma.

Uma Devi

unread,
Jun 13, 2008, 8:01:13 AM6/13/08
to Techdot...@googlegroups.com
Sql file I mentioned here is just contains the set of sql queries with soem Exec statements in it.
It is not a stored procedure.But it uses some variables that needs to be passed through command line.
Eg : sqlcmd -S server -E -i someinput.sql -v dname='DBName' dbpath="C:\somedir" -o output.log
 
i want to execute this programmatically

Siva CH

unread,
Jun 13, 2008, 8:51:03 AM6/13/08
to Techdot...@googlegroups.com
hi Uma,
Hope the following link might be of help to you.
 
 
 
Thanks,
Siva

Uma Devi

unread,
Jun 13, 2008, 10:24:18 PM6/13/08
to Techdot...@googlegroups.com
Hi Siva,
Thanks for the reply.I am searching for any SMO methods available to do the same.Do you have any code uses SMO to call sql script by passing parameters?
 
sqlcmd requires ' and " quotes for different arguements.
 
Thanks,
Uma.

Reply all
Reply to author
Forward
0 new messages