Oracle :
STR_SQL := ' SELECT ... where x = :1 and y = :2';
OPEN RS FOR STR_SQL USING VAR1, VAR2;
Postgres:
STR_SQL := ' SELECT ... where x = $1 and y = $2';
OPEN RS FOR EXECUTE STR_SQL USING VAR1, VAR2;
How can I do this in SQL Server? All I want is to avoid multiple execution plans
EDIT:
Does using a variable on the query with @
preserve the execution plan ?
SET @RS = CURSOR FOR SELECT ... where x = @MY_PROC_PARAMETER
OPEN @RS;
FETCH NEXT FROM @RS INTO @VRESULT_VALUE;