RE: HOWTO programmtically code 'use' in T-SQL
From: ATS (ATS_at_discussions.microsoft.com)
Date: 02/10/05
- Next message: David C: "Duplicate key error"
- Previous message: Stephen Russell: "Re: HOWTO programmtically code 'use' in T-SQL"
- In reply to: Cowboy (Gregory A. Beamer) - MVP: "RE: HOWTO programmtically code 'use' in T-SQL"
- Next in thread: David Gugick: "Re: HOWTO programmtically code 'use' in T-SQL"
- Reply: David Gugick: "Re: HOWTO programmtically code 'use' in T-SQL"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 10 Feb 2005 11:39:07 -0800
Thanks everyone for the reply, but I have found the sad answer. It can not be
done. I found an rticle posted by a Gary Johnson who was trying to solve the
same problem. Basically, one can not pass a variable into the "use database"
statement or onto the "refix" of a select statement such as select * from
@MY_DB..MY_TABLE.
This is not the end of the world for me, as fortunately I have the option of
using Dynamic SQL (i.e. @QRY = 'use ' + @MY_DB).
BUT....
If I could make a wish, I would wish that in T-SQL for SQL Server 2000 there
was a programmatic way of changing a connection "currently being used"
database. Or put another way, I wish we could programmatically pass in a
variable to the "use database" statement.
- Next message: David C: "Duplicate key error"
- Previous message: Stephen Russell: "Re: HOWTO programmtically code 'use' in T-SQL"
- In reply to: Cowboy (Gregory A. Beamer) - MVP: "RE: HOWTO programmtically code 'use' in T-SQL"
- Next in thread: David Gugick: "Re: HOWTO programmtically code 'use' in T-SQL"
- Reply: David Gugick: "Re: HOWTO programmtically code 'use' in T-SQL"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|