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 |
jtrirogoff
Starting Member
4 Posts |
Posted - 2007-03-29 : 13:11:31
|
I was wondering if this is possible:CREATE FUNCTION myFunction(@TableName varchar(255))Returns TABLEASBEGINSELECT ID, LastName, FirstNameFROM @TableNameRETURNENDI want this function to select from the TableName that I pass in. Is this possible? I receive the following error when I try to save this: "Must declare the variable '@TableName'"- Jonny |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-29 : 13:14:37
|
No..neither it's not possible inside function, nor advisable.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-29 : 13:21:11
|
You can do this with stored procedure + dynamic SQL.BUT Why do you want to do this ? KH |
|
|
|
|
|