Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xp_cmdshell and Master database

Status
Not open for further replies.

ton12

Programmer
Mar 9, 2005
58
GB
I'm using master..xp_cmdshell to run simple.sql which is a file containing
'Create Procedure TESTPROC '.

The command works fine but it creates TESTPROC in the
Master database.

I want the procedure TESTPROC to be created in a database called DB1.

I tried DB1..xp_cmdshell but didn't help.


Any suggestions.

Ton

 
I can't remember if this works or not in calling files from xp_cmdshell (no systems to test on at the moment), but in the simple.sql file have you put

Code:
USE MYDBNAME

Create procedure ........

Cheers,

M.
 
Thanks for your response.

Tried it but still creating the stored
procedure in the master database.

Ton
 
When you launch the osql or sqlcmd command within the xp_cmdshell specify the -d switch to specify the database to connect to.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top