• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Running another script from within a script

In Oracle I simply use the
@c:\script.sql command
How do I execute another script from within a script in SQLServer?

Thanks
0
orcl8i_dba_2000
Asked:
orcl8i_dba_2000
  • 2
1 Solution
 
Brian CroweDatabase AdministratorCommented:
I'm not familiar with Oracle but it sounds like you're trying to call one stored procedure from with another.

CREATE PROCEDURE myProc
     {parameters}
AS

...
EXECUTE myOtherProc {parameter1, parameter2, ...n}
...
GO
0
 
orcl8i_dba_2000Author Commented:
I am trying to call sqlfile2.sql from inside sqlfile1.sql
0
 
Jay ToopsCommented:
You can use osql or isql utility to run SQL script located on the disk file. This is the example to run SQL script located in the C:\SQLScript.sql file:

EXEC master..xp_cmdshell 'osql -S Servername -U sa -P -ic:\SQLScript.sql'

See SQL Server Books Online for more information about osql or isql utility and about xp_cmdshell extended stored procedure.
0
 
Jay ToopsCommented:
Note you can create a string and modify it VIA sql withing your code ...
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now