Easy sql script question

Easy sql script question

Post by Fredrik Wahlgre » Fri, 18 Aug 2000 04:00:00



Hi

Suppose I have a SQL script on a file. Can it call another script in the
same directory ?

Thanks in advance,
Fredrik

 
 
 

Easy sql script question

Post by Neil Boy » Sat, 19 Aug 2000 04:00:00


There is no direct equivelant of calling a submodule in another file.

You can use the SQL command

        xp_cmdsell "isql -iScriptFile -Ooutfile -Sserver ..........."

but that's quite messy.  You would probably  be better off coding the
scripts as stored procedures.

Neil Boyle
--
www.impetus-sql.co.uk - Free SQL Server guide on-line

 
 
 

Easy sql script question

Post by Tibor Karasz » Sat, 19 Aug 2000 04:00:00


Not really. You can shell out from SQL Server to the operating system and execute
OSQL.EXE which can execute a script. But that file would be from the SQL Servers
perspective (and SQL Server does not know which directory your script happened to be
opened from).

EXEC xp_cmdshell OSQL.EXE /i...

--
Tibor Karaszi, SQL Server MVP
Please reply to the newsgroup only, not by email.


Quote:> Hi

> Suppose I have a SQL script on a file. Can it call another script in the
> same directory ?

> Thanks in advance,
> Fredrik

 
 
 

1. Easy question: where to run sql scripts?

Steve,

You can run the creation statement for a database from the context of the
master db.  If you look at your script, you'll probably see a "USE <your db
name>" statement somewhere between the creation statement and any work on
the objects contained in the database.  Once the USE statement gets
executed, the remaining statements will execute within the context of your
new db (or at least until "USE <some other db>" gets called <g>).

HTH,
Nicole


2. US.NY.WHITEPLAINS.PICK-MR.KING WHERE ARE YOU(KENDA Systems)

3. Easy Scripting Question

4. Suppressing messages

5. Easy question about Create Scripts

6. SQL Server Collation

7. Easy question for scripts

8. SQL syntax help

9. Easy script question: Connecting templates.

10. Give this newbe easy answers on easy questions!

11. Easy SQL Question

12. Easy question on sql profiler

13. Easy SQL question