Thursday, March 29, 2012

Dynamic Select in MSSQL

Hi folks,
I have a problem migrating from Oracle to MSSQL the statement:
stmt2 := 'Select substr('||tabc||',1,50) from '||tabn||'
OPEN cur2 FOR stmt2;

How can I to perform this dynamic select into MSQL ??

Thanks 4 your helpI partially solved with:

Exec ('select substring('+@.chvCol+',1,50) from ' + @.chvTable + .....)

with

DECLARE @.chvTable sysname, @.chvCol sysname

No comments:

Post a Comment