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 |
|
nomedia
Starting Member
3 Posts |
Posted - 2003-10-21 : 09:06:36
|
| Hi,I've got some problems with variables in a stored procedure. I hope someone can help me with this...The code of my stored procedure is something like:CREATE PROCEDURE dbo.spStoredProcedure @table varchar(8000) ASSELECT * FROM @tableTo execute this, I have to call something like this:EXECUTE spStoredProcedure 'tblA'What I want to do in this example, is that the stored procedure returns all data in the table tblA.But SQL Server thinks he must return all records from table @table, which does not exist.In other words...I want to get the value of a variable/parameter, but SQL Server takes it as being a table.Anyone have a solution for this?Thanx a lot! |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2003-10-21 : 09:12:14
|
http://www.sqlteam.com/SearchResults.asp?SearchTerms=dynamic+sqlShould sort you out.By the way, this is in the FAQ Damian |
 |
|
|
nomedia
Starting Member
3 Posts |
Posted - 2003-10-21 : 09:20:25
|
| OK, thnx.I haven't seen this, because I didn't think about "dynamic sql", but was searching for "parameter as object" and things like that. |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2003-10-21 : 09:24:07
|
No probs Not to rub it in to you personally :http://www.sqlteam.com/FAQ.aspquote: Why doesn't SELECT * FROM @tablname work?
But welcome aboard!Damian |
 |
|
|
|
|
|