I have attempted the following with both pass through SQL from Dex and by creating a SQL proc and passing in the column name. Both give me an error, even though I can take the exact same code, go to SQL, execute it there and it works fine.
here is the dex call to the SQL proc:
{---
call bmiXLSSourceDataFormatDates,
retValue,
iColumn;
---}
sproc returns long retValue;
in string iColumn;
call sproc "bmiXLSSourceDataFormatDates",
retValue,
iColumn;
AND here is the SQL proc - I pass in the @ColumnName as a parameter to it.
declare @sqlCommand varchar(8000)
declare @sqlCommand2 varchar(8000)
set @sqlCommand = 'update bmiXLSSourceDataTemp set ' + @ColumnName + ' = REPLACE(' + @ColumnName + ',''/'',''-'')'
exec (@sqlCommand);
set @sqlCommand2 = 'update bmiXLSSourceDataTemp set ' + @ColumnName + ' = CONVERT(DATE, ' + @ColumnName + ')'
exec (@sqlCommand2);
You can see, I'm trying to work with dates, but notice very carefully all I'm passing from dex is a column name, not an actual date. Again, if I take the sql code above into tSql, do a SELECT @ColumName = 'columnname' and run the script, it works just fine.
I am just about to lose my mind on this one. It's giving me the SQL 241 error. Any help would be appreciated.
one more thing... the replace part works just fine, the CONVERT is where the issue comes in.