Re: sqlexec



Hi,

This is actually a dynamic SQL and can be executed using one of the below :-

EXEC(@Var1)

or

exec sp_executesql @Var1

Thanks
Hari
SQL Server MVP


"shif" <ns_0001@xxxxxxxxxxx> wrote in message
news:1969B7F1-6254-4734-8F4C-3DDEFC9BF424@xxxxxxxxxxxxxxxx
Hi
How can i execute a piece of sqlstmt which is stored in a string variable
from query analyser.
for ex:@var1="select name,code from" + @var2
--
Thanks


.



Relevant Pages

  • Re: Logging within User_Defined Functions (UDF)
    ... >>SQL Server MVP ... >>> I'm trying to carry out some logging each time an UDF ... Ultimately you can only execute ... >>> Only functions and extended stored procedures can be ...
    (microsoft.public.sqlserver.programming)
  • Re: Deadlock incidence greatly increased after upgrade from 11.5.1 to 12.5.3 - Suggestions?
    ... They may not execute simultaneously, but each user process only gets a ... Mike Epprecht, Microsoft SQL Server MVP ... >> Mike Epprecht, Microsoft SQL Server MVP ...
    (comp.databases.sybase)
  • Re: how to return the result of execute sql programmatically
    ... You can get the result through an Execute SQL Task, so no ned for ADO if you don't like it. ... I'd like to schadule the package in another server which my password of integrated security might not work. ... oExecSQL.SQLStatement = sSQLStatement ' Clean Up Set oExecSQL = Nothing ... Darren Green (SQL Server MVP) ...
    (microsoft.public.sqlserver.dts)
  • Re: sp_password
    ... SQL Server MVP ... "Leon Parker" wrote in message ... > Whenever I execute the procedure I get the error message that the ...
    (microsoft.public.sqlserver.security)
  • Re: 64bit insert delays
    ... If you execute them in QA using the same QA window, then they are executed synchronously, i.e., the ... Tibor Karaszi, SQL Server MVP ... >> If that takes significant time, then you have some other problem. ... >> Tibor Karaszi, SQL Server MVP ...
    (microsoft.public.sqlserver.programming)