sql server - Returning a table from a function with parameters in SQL -


as far know, can return table result of db function:

create function myfunction(@value varchar(100)) returns table return (select * mytable columnname = '@value') 

in example can make column name parameter function. question is, can write column name , table name parameter function? hence can write more generic function like:

create function mygenericsearchfunction(@tablename varchar(100), @columnname varchar(100), @value varchar(100)) returns table return (select * @tablename @columnname = '@value') 

no, can't.

this dynamic query. dynamic queries in sql server, 1 has use exec() or sp_executesql() functions, not allowed in functions.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -