Execute dynamic SQL statements from within triggers etc

 

Syntax

 

<ExecuteStatement> ::= EXECUTE IMMEDIATE <SimpleExpression>

 

Usage

 

Note: the example shows how to work with single quoted parts of the statement

 

 

declare s varchar(100);

 

set s = 'select ' + chr(39) + 'a string' + chr(39) + ' from #dummy';

 

execute immediate (s);