Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FROM phrase not parameterizable in UDF?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00835502
Message ID:
00835505
Views:
12
Terry,

You get an error because it's not allowed in SQL Server. In a sproc you can build dynamic SQL and run it using EXECUTE command or sp_executesql system sproc. I'm not sure what you can do in UDF.

>The following UDF works fine w/o the @tablename param, but with a static tablename instead.
>
>ALTER FUNCTION dbo.GetDesc (@tablename varchar(100), @id int)
>RETURNS varchar(400) AS
>BEGIN
>return (select name from @tablename where id = @id)
>END
>
>With the @tablename param, I get error:
>@tablename must be declared
>
>Does anyone see the problem here?
>TIA
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform