How to use global variable to SQLStatement without parameter mapping
Hello. I have one global variable
Name : aBook
Value : Books(it's table name)
I want to use this to SQLStatement.
For example,
INSERT INTO BOOK(TITLE) VALUES(@aBook);
=> it means that "INSERT INTO Books(TITLE) VALUES('Books);
I know if I use Parameter Mapping, It is possible.
But, could you tell me how to do this without Parameter Mapping function?
Thank you.
July 3rd, 2011 12:53am
Thank you for the answer.
I want to use SQL Satement in SQLStatement Box.
Do you have any idea?
If I use expression "INSERT INTO BOOK(TITLE) VALUES('"+@[User::aBook] +"')", I Can get the result what I want.
But, I want to do this only in SQLStatement.
Please, Help me.
Free Windows Admin Tool Kit Click here and download it now
July 3rd, 2011 3:38am
Where do you get the value of the variable from?
The only way to work with variables with TSQL only is to use TSQL variables:
DECLARE @aBook varchar(100);
SET @aBook = 'Some Title';
INSERT INTO BOOK(TITLE) VALUES (@aBook)
If this isn't what you want, you'll need to use either the expression or the parameter mapping.
MCTS, MCITP - Please mark posts as answered where appropriate.
July 3rd, 2011 3:57am