Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 RUN TSQL Script in JOBS

Author  Topic 

CSantos
Starting Member

7 Posts

Posted - 2002-08-23 : 11:05:32

How can I Run a Transact SQL Script in a JOB with more that 3200 Characteres???

Can I call a Script.SQL inside the JOB ???

Thanks by your time.

Kevin Snow
Posting Yak Master

149 Posts

Posted - 2002-08-23 : 11:16:35
Make the TSQL script into a stored procedure. Then call the stored procedure from inside the COMMAND text area.

ie.

paste TSQL script in a new procedure called MYPROC

then in the command text area of the JOB's STEP, enter

exec MYPROC

Although the command text area is limited to @3200 characters, the stored procedures are not.

Go to Top of Page

CSantos
Starting Member

7 Posts

Posted - 2002-08-23 : 11:24:13
Kevin,

Thank you for responding.


Go to Top of Page

CSantos
Starting Member

7 Posts

Posted - 2002-08-23 : 11:31:12

Now I have another problem, how can I access 2 Databases in the same procedure ???

Thanks by your time.

Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2002-08-23 : 12:15:07
SQL has a multi-part naming structure to allow this to happen...


basically SELECT * from a.b.c.d
where a is servername, b is databaseownername, c is databasename and d is tablename


(not sure if b,c are reversed....check BOL for exact details....)

Go to Top of Page

joshb
Yak Posting Veteran

52 Posts

Posted - 2002-08-23 : 12:28:17
Andrew is right, it goes: [server].[database].[object owner].[object]

Go to Top of Page

CSantos
Starting Member

7 Posts

Posted - 2002-08-23 : 12:30:46

Andrew, Josh

Thanks by your time.


Go to Top of Page
   

- Advertisement -