Hello,
Can you tell me how can i choose one database dinamically
to execute one script
ex:
use @.database_name
go
It's possible?
Best regardsAs you probably know, USE does not accept a variable. There might be ways to accomplish what you
want to do, but you don't post what your scenario is...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"CC&JM" <anonymous@.discussions.microsoft.com> wrote in message
news:206de01c45933$c3ebc830$a501280a@.phx.gbl...
> Hello,
> Can you tell me how can i choose one database dinamically
> to execute one script
> ex:
> use @.database_name
> go
> It's possible?
> Best regards|||not really. Not without Dynamic SQL concatenated at run time and executed
via sp_ExecuteSQL
Greg Jackson
PDX, Oregon|||Hi,
Use the belo sample.
DECLARE @.DBNAME VARCHAR(30)
DECLARE @.SQL NVARCHAR(4000)
SET @.DBNAME = 'TEST'
SET @.SQL = 'USE ' + @.DBNAME + ' SELECT * FROM sysobjects'
EXEC SP_EXECUTESQL @.SQL
--
Thanks
Hari
MCDBA
"CC&JM" <anonymous@.discussions.microsoft.com> wrote in message
news:206de01c45933$c3ebc830$a501280a@.phx.gbl...
> Hello,
> Can you tell me how can i choose one database dinamically
> to execute one script
> ex:
> use @.database_name
> go
> It's possible?
> Best regards
Sunday, March 11, 2012
Choose database dinamically
Labels:
database,
database_name,
dinamically,
execute,
microsoft,
mysql,
oracle,
script,
server,
sql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment