In a stored procedure to use a replaceable parameter in a query I would build the query as a string, then use execute.
This does not seem to work in functions,
How could I perform the same query with a variable tablename
Like
SET @Query = COUNT(*) FROM + @TableNameVariable
Select @VarNum1 = @Query
Does not work because it trys to set the Variable @VarNum1 to a string not the result of the query.
Is there another method of producing variable sql queries inside a UDF?
This does not seem to work in functions,
How could I perform the same query with a variable tablename
Like
SET @Query = COUNT(*) FROM + @TableNameVariable
Select @VarNum1 = @Query
Does not work because it trys to set the Variable @VarNum1 to a string not the result of the query.
Is there another method of producing variable sql queries inside a UDF?