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 |
|
podrik
Starting Member
3 Posts |
Posted - 2004-09-10 : 10:32:20
|
| What I'm doing wrong? Why doesn't "select * from @var1" work?use pubsGoDECLARE @var1 varchar(50) select @var1 = 'titles'print @var1Goselect * from @var1Go/Patrik |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2004-09-10 : 10:35:52
|
| It should be:SELECT @var1You could only do SELECT * FROM @var1 if @var1 was declared as a table variable.Mark |
 |
|
|
podrik
Starting Member
3 Posts |
Posted - 2004-09-10 : 10:39:19
|
But how should I solve this then!My problem is that I'm reading from another table which table I will insert a value!/Patrikquote: Originally posted by mwjdavidson It should be:SELECT @var1You could only do SELECT * FROM @var1 if @var1 was declared as a table variable.Mark
|
 |
|
|
DustinMichaels
Constraint Violating Yak Guru
464 Posts |
Posted - 2004-09-10 : 10:40:58
|
| You have to use dynamic sql function like sp_executesql or EXECUTE(...) if you want to do something that you listed in your first post.But it sounds like you don't even need to use dynamic sql to perform your task. Gives us more information about what your trying to do.Dustin Michaels |
 |
|
|
podrik
Starting Member
3 Posts |
Posted - 2004-09-10 : 10:49:25
|
Thanks, you made my weekend much better know that I have solved this!/Patrikquote: Originally posted by DustinMichaels You have to use dynamic sql function like sp_executesql or EXECUTE(...) if you want to do something that you listed in your first post.But it sounds like you don't even need to use dynamic sql to perform your task. Gives us more information about what your trying to do.Dustin Michaels
|
 |
|
|
|
|
|