Re: Multiple variables
- From: "Andy" <Andy@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 20 Apr 2005 06:19:02 -0700
Thanks Hugo
This has worked perfectly - its going to save me an awful lot of time!!!
Andy
"Hugo Kornelis" wrote:
> 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)
>
.
- 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
- Re: Multiple variables
- From: Hugo Kornelis
- Multiple variables
- Prev by Date: Re: why the result of the query is in asending order
- Next by Date: Query Performance
- Previous by thread: Re: Multiple variables
- Next by thread: SQL 2000 licensing enquiry
- Index(es):
Relevant Pages
|
|