Re: Dynamic SQL Again !$&

From: Uri Dimant (urid_at_iscar.co.il)
Date: 10/28/04


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.



Relevant Pages

  • Dynamic SQL Again !$&
    ... I am bulding dynamic SQL statements and am running into syntax issues when ... trying to use a literal string in a statement. ... I am getting a syntax error on Unknown. ...
    (microsoft.public.sqlserver.programming)
  • Re: Type of Data Returned by a Function
    ... returned by my functions is "unknown" in the following syntax: ... I *think* I can specify that by doing something like this: ... The only thing I can think of that might have something to do with what you say are phpdoc comments: ...
    (comp.lang.php)
  • Type of Data Returned by a Function
    ... I've noticed that some code analyzers comment that the type of data returned by my functions is "unknown" in the following syntax: ... If so, is there a performance gain, or is it just clean coding? ...
    (comp.lang.php)
  • Re: sql for row where value=
    ... Malcolm Dew-Jones wrote: ... This is probably a stupid question but I don't get it. ... That is because NULL also represents an "unknown" value, and it isn't possible to say that two unknown values are the same as each other. ... I had tried that but my syntax was wrong. ...
    (comp.lang.php)
  • New functions in .NET 2.0 ???
    ... I have this line of code, but the syntax check in VB.NET 2003 and also in ... VB.NET 2005 Beta 2 shows as unknown: ... Dim local4 As Byte ...
    (microsoft.public.dotnet.languages.vb)

Loading