Results 1 to 3 of 3

Thread: Constructing an sql string

  1. #1

    Thread Starter
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727

    Constructing an sql string

    Hi, Im trying to build some sql through string concatenation can someone take a look, im having problems with quotes.

    Code:
    set @SQL = @SQL + 'CASE owner_ein '
    set @SQL = @SQL + 'WHEN ''NA'' THEN ''Unassigned'' '
    set @SQL = @SQL + 'else ''''<a target=''_blank'' href=''http://url?ein='' + ein + ''''>'' + LEFT(firstname, 1) + ''. '' + surname + ''</a>'' AS name''' 
    set @SQL = @SQL + 'END as name '
    Its the third line im having trouble with.

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: Constructing an sql string

    Hi
    I have copy and pasted query into Query Analiser for ms sql 2000 and no errors.
    "The dark side clouds everything. Impossible to see the future is."

  3. #3

    Thread Starter
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727

    Re: Constructing an sql string

    thanks, but there were errors when calling the stored procedure from the web. I have sorted it now anyway, if anyones interested.

    Code:
    set @SQL = @SQL + 'else ''<a target="_blank" href="url?ein='' + ein + ''">'' + LEFT(firstname, 1) + ''. '' + surname + ''</a>'''
    i didn't know you could use " in the string

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width