|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi there,
I have this problem.. I created a function in MS SQL and through this fuinction I am also passing the table name... now when I call the table name through the function in a SELECT statement, MS SQL is giving me an error that I have to declare the variabel.... Can someone help me?? Thanks!! |
|
#2
|
|||
|
|||
|
I believe the only way you can use a tablename as a variable is with dynamic SQL. Something like this:
declare @tableName varchar(50) declare @strSQL varchar(3000) select @strSQL = "SELECT * FROM " + @tablename exec(strSQL) |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > passing a table name through a parameter |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|