Re: Multiple variables
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 18 Apr 2005 21:31:04 +0200
On Mon, 18 Apr 2005 09:09:02 -0700, Andy wrote:
(snip)
>As you can see it is because the quote before C is closing the string and so
>on. Do I need to break the string at that point and concatenate it so that:
>
>pay_or_contact = ' + 'C' + ', etc etc
>
>or is there a way of getting SQL to ignore the string within the string?
(snip)
Hi Andy,
You'll have to make sure that you embed a quote within the string. The
code passed to the EXEC (@sql) needs quotes around the C to recognise it
as a literal. There are two ways to do that: either use the ASCII value
for the quote, or double the quote (one quote in a string is considered
a string delimiter, two consecutive quotes are considered one quote as
part of the string):
--Update the various flags on the company basic table
SET @sql = 'UPDATE company_basic
SET report_status = null,
--Other fields being set to null
verify_svy_urn = null,
pay_or_contact = ''C'',
year_end_date = null,
--Other fields being set to Null
WHERE company_code IN ' + @codes
EXEC (@sql)
or
--Update the various flags on the company basic table
SET @sql = 'UPDATE company_basic
SET report_status = null,
--Other fields being set to null
verify_svy_urn = null,
pay_or_contact = ' +CHAR(39)+ 'C' +CHAR(39)+ ',
year_end_date = null,
--Other fields being set to Null
WHERE company_code IN ' + @codes
EXEC (@sql)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
.
- Follow-Ups:
- Re: Multiple variables
- From: Andy
- Re: Multiple variables
- References:
- Multiple variables
- From: Andy
- Re: Multiple variables
- From: Hugo Kornelis
- Re: Multiple variables
- From: Andy
- Re: Multiple variables
- From: Hugo Kornelis
- Re: Multiple variables
- From: Andy
- Multiple variables
- Prev by Date: Query LDAP Groups
- Next by Date: Re: msde AlaptopND sql server on save
- Previous by thread: Re: Multiple variables
- Next by thread: Re: Multiple variables
- Index(es):
Relevant Pages
|
|