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.
Re: Constructing an sql string
Hi
I have copy and pasted query into Query Analiser for ms sql 2000 and no errors.
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