I have to declare a cursor to get list of rows, which don't contain the following characters in a column.
exec('DECLARE curData CURSOR for SELECT count(*) from ' + @TableName + ' where
convert(varchar(255), [' + @ColName + ']) like
''%[^\\-\\^_<>`~:{}\",#$%&!?;+0-9a-zA-Z@/*()\\.\\-\\b\\\\ ]%')
I can only declare it inside EXEC statement as I have to pass the table name dynamically. But when I execute the statement above, I get the following error message,
"Unclosed quotation mark before the character string '%[^\\-\\^_<>`~:{}\",#$%&!?;+0-9a-zA-Z@/*()\\.\\-\\b\\\\ ]%'"
What could be the reason.
Also, one of the characters is hyphen, but this is not checked. Can anyone help why is it so?
Thanks in Advance,
Manohar
exec('DECLARE curData CURSOR for SELECT count(*) from ' + @TableName + ' where
convert(varchar(255), [' + @ColName + ']) like
''%[^\\-\\^_<>`~:{}\",#$%&!?;+0-9a-zA-Z@/*()\\.\\-\\b\\\\ ]%')
I can only declare it inside EXEC statement as I have to pass the table name dynamically. But when I execute the statement above, I get the following error message,
"Unclosed quotation mark before the character string '%[^\\-\\^_<>`~:{}\",#$%&!?;+0-9a-zA-Z@/*()\\.\\-\\b\\\\ ]%'"
What could be the reason.
Also, one of the characters is hyphen, but this is not checked. Can anyone help why is it so?
Thanks in Advance,
Manohar