Wednesday, March 28, 2012
running a text file full of sql?
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).
Monday, March 26, 2012
RUNNING A DTS PACKET FROM WITHIN TSQL
Here is my problem: I don't have permissions to the 'master' db, thusly I don't have permissions to 'xp_cmdshell'. However, I need to output several small tables that I have created from one large table into individual text files.
Now, from the documentation I have read this is easily possible with the use of dts packets. However, my knowledge of dts packets is non-existent. So, I have created a dts packet that will take the data from a table and export it to a text file.
Here is what I need to know how to do: I would like all the small tables to go to their individual text files based on the file name I provide from within tsql. I would also like this to be done with the use of local tables (i.e. #tablename).
I am trying to alleviate human interface and the resulting errors from the sql statements we have now. We have an elaborate db system with tables and permissions all over the place, and thusly I want this done and removed with the use of local tables. Is this something that anyone could assist me with?
To execute a DTS package from a stored procedure or other t-sql code, you have to use the sp_OACreate and sp_OAMethod system procedures.
The problem, if you don't have permission to the master db, you won't be able to execute these either.
My recommendation to you would be to create SQL Server Agent job(s) to execute the DTS Package and allow the package to execute on a schedule. The SQL Agent execution account should have access to run the DTS Package.
The only other option is to be granted sufficient permission to the master db.
sqlRUNNING A DTS PACKET FROM WITHIN TSQL
Here is my problem: I don't have permissions to the 'master' db, thusly I don't have permissions to 'xp_cmdshell'. However, I need to output several small tables that I have created from one large table into individual text files.
Now, from the documentation I have read this is easily possible with the use of dts packets. However, my knowledge of dts packets is non-existent. So, I have created a dts packet that will take the data from a table and export it to a text file.
Here is what I need to know how to do: I would like all the small tables to go to their individual text files based on the file name I provide from within tsql. I would also like this to be done with the use of local tables (i.e. #tablename).
I am trying to alleviate human interface and the resulting errors from the sql statements we have now. We have an elaborate db system with tables and permissions all over the place, and thusly I want this done and removed with the use of local tables. Is this something that anyone could assist me with?
To execute a DTS package from a stored procedure or other t-sql code, you have to use the sp_OACreate and sp_OAMethod system procedures.
The problem, if you don't have permission to the master db, you won't be able to execute these either.
My recommendation to you would be to create SQL Server Agent job(s) to execute the DTS Package and allow the package to execute on a schedule. The SQL Agent execution account should have access to run the DTS Package.
The only other option is to be granted sufficient permission to the master db.
Monday, March 12, 2012
Run Job From TSQL
I need some help on this problem.
I create a job on SQL Agent, the job had schedule as selected date and time,
but I want to have a optional choise to user to allow them start the job at
the web page, so I try to create a store procedure to start the job and
return the outcome for the job (Fail or success). And I use
msdb.dbo.sp_start_job to start the job, now I face the problem how can I kno
w
the job are finished and after the job completed, I need to check the result
of the job. Can give me some idea, what should I do for this.
TQhi
probably you can have a log table. The jon logs the data into the table. and
you can read it from the web page of u can have ur sp return a value.
did this answer your question.
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
---
"Judy" wrote:
> Dear All,
> I need some help on this problem.
> I create a job on SQL Agent, the job had schedule as selected date and tim
e,
> but I want to have a optional choise to user to allow them start the job a
t
> the web page, so I try to create a store procedure to start the job and
> return the outcome for the job (Fail or success). And I use
> msdb.dbo.sp_start_job to start the job, now I face the problem how can I k
now
> the job are finished and after the job completed, I need to check the resu
lt
> of the job. Can give me some idea, what should I do for this.
> TQ
>|||sp_hlep_job will give you the status and such but you will have to poll for
it periodically.
Andrew J. Kelly SQL MVP
"Judy" <Judy@.discussions.microsoft.com> wrote in message
news:97716C52-85C6-41F0-8BE8-EFB61EF3E0FD@.microsoft.com...
> Dear All,
> I need some help on this problem.
> I create a job on SQL Agent, the job had schedule as selected date and
> time,
> but I want to have a optional choise to user to allow them start the job
> at
> the web page, so I try to create a store procedure to start the job and
> return the outcome for the job (Fail or success). And I use
> msdb.dbo.sp_start_job to start the job, now I face the problem how can I
> know
> the job are finished and after the job completed, I need to check the
> result
> of the job. Can give me some idea, what should I do for this.
> TQ
>|||...or check out this article about how to use xp_sqlagent_enum_jobs to be a
ble to deal with the results since the results from sp_help_job cannot be in
serted into a table.
http://www.databasejournal.com/arti...10888_3491201_2
/Magnus
Wednesday, March 7, 2012
Run a Snapshot agent from a script or cmdline
from a cmd line. I have merge replication setup to several different
publications and would like to script all of the snapshot agents to run
on cmd rather on a schedule. I am using SQL Server 2000 with SP3.
Thank You in advance.
You could use sp_start_job from TSQL, or use the activeX control if you want
the command-line control.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .