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 2005 Forums
 Transact-SQL (2005)
 run sql file under one procedure

Author  Topic 

maxim
Yak Posting Veteran

51 Posts

Posted - 2007-11-14 : 18:30:45
hello!

I have one SQLfile with something like this:

--Drop DataBase
...
--Create database
...
--Create tables
...
-- Insert Values
...

But I want to do this inside one procedure!

Something like: "Exec createDB.sql"....

It's possible?
What is the right command?
Thanks,
Max

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-11-14 : 22:42:57
Call it with sqlcmd.
Go to Top of Page

maxim
Yak Posting Veteran

51 Posts

Posted - 2007-11-15 : 08:20:51
Thanks, but how can i use it inside a sqlProcedure ?

Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-11-15 : 22:42:35
With master..xp_cmdshell 'sqlcmd ...'.
Go to Top of Page

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2007-11-16 : 16:24:39
quote:
Originally posted by maxim

Thanks, but how can i use it inside a sqlProcedure ?





Umm... Don't use a file, but put it into the "sqlProcedure" instead?
Go to Top of Page
   

- Advertisement -