Sorry if this has been covered but as you might imagine searching for this has been problematic.
I want to use vaariables with my USE commands.
if I use that I get an error that points to an arbitrary line in the code.
if I use this the database does not change but executes with no errors.
DECLARE @DBName char(3), @X as varchar(MAX)
SET @DBName = 'SBU'
set @X = 'use ' + @DBName +';'
I want to dynamically change which DB I am using. I could just be going about this the wrong way.
"From the smallest necessity to the highest religious abstraction, from the wheel to the skyscraper, everything we are and everything we have comes from one attribute of man - the function of his reasoning mind.