
In Sql Server you can exec a string like sql, for make it you shall use a stored procedure called sp_sqlexec. In the nex code I write a query like string and the next line exec the string like query: You should be careful with this stored procedure, as it could allow sql injection.