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.
| Author |
Topic |
|
Torch
Starting Member
20 Posts |
Posted - 2005-07-11 : 20:37:10
|
| Im unsure on the exact syntax of the "USE" command in SQL.What I'm trying to do is run an SQL script that drops and creates tables in a different database (but on the same server). However I am getting the error:Error 154: a USE database statement is not allowed in a procedure or trigger.What Im doing is the following:CREATE PROCEDURE [dbo].[dropTables]@database varchar(200)ASUSE @database....Any help in this matter would be much appreciated.Torch. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-07-12 : 00:36:20
|
Instead of using Use, you can use DBname..tablename approachCREATE PROCEDURE [dbo].[dropTables]@database varchar(200)AS--Use Dynamic SQL to include DBNameExec('Select columns from '+@database+'..tablename')MadhivananFailing to plan is Planning to fail |
 |
|
|
Torch
Starting Member
20 Posts |
Posted - 2005-07-12 : 05:08:45
|
| Thanks, thats the approach I used in the end.Torch. |
 |
|
|
|
|
|