Execute TSQL script via .NET code?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a TSQL script which I would like to run against a MSSQL database.

The script is something like
Create table ...
GO
Insert into ...
GO
....

Is it possible to execute that script let's say by assigning it to a
SqlCommand object's Text property? Are there other ways of executing the
script without the use of osql.exe?

Thanks for your ideas,
Guido
 
We used this problem as an exercise in my class. Write a routine that parses
the strings looking for the <CR><LF>GO string. Submit everything before that
in the CommandText and handle the results. Repeat starting at the point just
after the GO.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
www.sqlreportingservices.net
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top