Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FROM phrase not parameterizable in UDF?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00835502
Message ID:
00835505
Vues:
13
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform