to work with a passed variable ...
I have a cursor that pulls a filter string from a table (works OK),
then I want to use that filter in a second cursor, but can't get the
syntax ...
@.bakfilter is equal to "MISV2_db_%.BAK" before I try to open and fetch
from the second cursor. Here is the cursor declaration:
DECLARE curFiles CURSOR FOR
SELECT FileName, FileDate
FROM DataFile
WHERE (((Active)=1) AND ((FileName) LIKE '@.bak_filter'))
ORDER BY FileDate DESC
What do I need to do to get it to use the string contained in
@.bak_filter?
Thanks in advance, JimOn 10 Jan 2005 14:53:35 -0800, jfro wrote:
>After trying every way I could come up with I can't get a filter clause
>to work with a passed variable ...
>I have a cursor that pulls a filter string from a table (works OK),
>then I want to use that filter in a second cursor, but can't get the
>syntax ...
>@.bakfilter is equal to "MISV2_db_%.BAK" before I try to open and fetch
>from the second cursor. Here is the cursor declaration:
>DECLARE curFiles CURSOR FOR
>SELECT FileName, FileDate
>FROM DataFile
>WHERE (((Active)=1) AND ((FileName) LIKE '@.bak_filter'))
>ORDER BY FileDate DESC
>What do I need to do to get it to use the string contained in
>@.bak_filter?
Hi Jim,
Remove the quotes: LIKE @.bak_filter
However, I hope that you're aware that cursor-based processing is usually
not needed? Set-based solutions are almost always better. Of course, if
you need to perform an intrinsically row-based operation (like sending
mail or performing some OS command with xp_cmdshell), this doesn't apply.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
No comments:
Post a Comment