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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-05-15 : 10:33:02
|
| Michael writes "Hello -I'm trying to utilize the new SQL 2000's TABLE data type & have spent a lot of time trying to make this simple test to work to no avail, please help! The error I keep getting back is ERROR: Must declare the variable '@Spec' -----------------------------------------Declare @sql nvarchar(1000)Declare @Spec TABLE ( myUserName nvarchar(50) NOT NULL )set @sql = 'insert into ' + @Spec + ' select UserName from t_users 'exec(@sql)-------------------------------------Thank you!!" |
|
|
YellowBug
Aged Yak Warrior
616 Posts |
Posted - 2002-05-15 : 10:48:31
|
| Declare @sql nvarchar(1000) Declare @Spec TABLE ( myUserName nvarchar(50) NOT NULL ) INSERT INTO @SpecSELECT UserName FROM t_users |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-05-15 : 10:51:50
|
| What are you tring to do with this statement. you have to remember you cant use a table variable like a normal variable . you ought to treat it like a table objectif a give a statement it is illogical @spec=10 and So is thisset @sql = 'insert into ' + @Spec + ' select UserName from t_users ' but something like this is perfectly okselect * from @specset @sql='insert into @spec select username from t_users'(probably this is what you are trying to do)HTHSNIPED!!!!!!!--------------------------------------------------------------Edited by - Nazim on 05/15/2002 10:52:39 |
 |
|
|
|
|
|