Re: Dynamic SQL Again !$&
From: Uri Dimant (urid_at_iscar.co.il)
Date: 10/28/04
- Next message: Dan Guzman: "Re: Dynamic SQL Again !$&"
- Previous message: Uri Dimant: "Re: Statistics"
- In reply to: Larry Menzin: "Dynamic SQL Again !$&"
- Next in thread: Dan Guzman: "Re: Dynamic SQL Again !$&"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 28 Oct 2004 14:18:15 +0200
Larry
Exchange a EXEC for PRINT and see what is happened.
"Larry Menzin" <LarryMenzin@discussions.microsoft.com> wrote in message
news:B4132BE7-9DE9-4A42-AEC4-B5684FC5F087@microsoft.com...
> I am bulding dynamic SQL statements and am running into syntax issues when
> trying to use a literal string in a statement. In the following code
snippet,
> the word 'Unknown' is supposed to appear as a literal string with single
> quotes around it it:
>
> SET @SOURCECOLUMNS = @SOURCECOLUMNS + ','
> + '(SELECT MAX(c.CODEID) FROM '
> + @target_db + 'CODEALIAS c '
> + 'WHERE c.FacilityID in (a.FacilityID,0) AND '
> + 'c.codesetid = '
> + cast(@acodesetid as varchar(4))
> + ' AND c.alias = CASE WHEN a.'
> + substring (@acolumnname,1,(len(@acolumnname) -2))
> + ' IS NULL THEN ''Unknown'' ELSE a.'
> + substring (@acolumnname,1,(len(@acolumnname) -2))
> + ' END)'
> + CHAR(13)
>
> I am getting a syntax error on Unknown. What am I doing wrong?
>
> --
> Larry Menzin
> American Techsystems Corp.
- Next message: Dan Guzman: "Re: Dynamic SQL Again !$&"
- Previous message: Uri Dimant: "Re: Statistics"
- In reply to: Larry Menzin: "Dynamic SQL Again !$&"
- Next in thread: Dan Guzman: "Re: Dynamic SQL Again !$&"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|