Wednesday, March 28, 2012

running a text file full of sql?

I'm sure there's a trivial answer to this, but I've looked in both the TSQL
dox and the SS2000 dox, and if it's in there it's well hidden...
Is there a way to run the SQL commands inside a text file from WITHIN TSQL?
I know I can use isql to do this, but is there a syntax for running it from
within a stored proc?
I'm setting up a job to run a Log scraper at night. It's output is a .SQL
file that I then want to read in (all at 3AM). I could use Shell Command and
isql, but it would be "nicer" to avoid this and use TSQL directly (IMHO).
EXEC master..xp_cmdshell 'osql ...'
Take a look at the command line arguments for osql in Books Online.
http://www.aspfaq.com/
(Reverse address to reply.)
"Maury Markowitz" <MauryMarkowitz@.discussions.microsoft.com> wrote in
message news:EF81D2F3-ACBC-45B6-BE56-53A9670C652F@.microsoft.com...
> I'm sure there's a trivial answer to this, but I've looked in both the
TSQL
> dox and the SS2000 dox, and if it's in there it's well hidden...
> Is there a way to run the SQL commands inside a text file from WITHIN
TSQL?
> I know I can use isql to do this, but is there a syntax for running it
from
> within a stored proc?
> I'm setting up a job to run a Log scraper at night. It's output is a .SQL
> file that I then want to read in (all at 3AM). I could use Shell Command
and
> isql, but it would be "nicer" to avoid this and use TSQL directly (IMHO).
|||EXEC master..xp_cmdshell 'osql -S Servername -E -ipath:\SQLScript.sql'
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com
"Maury Markowitz" <MauryMarkowitz@.discussions.microsoft.com> wrote in
message news:EF81D2F3-ACBC-45B6-BE56-53A9670C652F@.microsoft.com...
> I'm sure there's a trivial answer to this, but I've looked in both the
TSQL
> dox and the SS2000 dox, and if it's in there it's well hidden...
> Is there a way to run the SQL commands inside a text file from WITHIN
TSQL?
> I know I can use isql to do this, but is there a syntax for running it
from
> within a stored proc?
> I'm setting up a job to run a Log scraper at night. It's output is a .SQL
> file that I then want to read in (all at 3AM). I could use Shell Command
and
> isql, but it would be "nicer" to avoid this and use TSQL directly (IMHO).

No comments:

Post a Comment