Re: Multiple variables
- From: "Andy" <Andy@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 18 Apr 2005 07:24:05 -0700
Hi Hugo
Thanks for this. I've been out of the office the last few days so have only
just picked this up. Thanks for the advice as well!
Andy
"Hugo Kornelis" wrote:
> On Thu, 14 Apr 2005 04:52:00 -0700, Andy wrote:
>
> >Hi Hugo
> >
> >Thanks very much for this - I've not tried it yet as I think there might be
> >a couple of typos that I want to confirm:
> >
> >You declare a variable called @codes, presumably all of my old instances of
> >@code should now read @codes instead.
>
> Hi Andy,
>
> My bad - since I adapted the script to work for more than one code at
> once, I thought it'd be best to change the variable name from @code to
> @codes - but after changing the first, I promptly forgot to change the
> rest. <blush>
>
>
> >Is the N in this line correct: SET @code = N'(12345,6789)'?
>
> Yes. I've changed the datatype to nvarchar (note: not just varchar, but
> nvarchar), as is required for dynamic SQL. The N in fron of the string
> constant means that this is also regarded as nchar data instead of plain
> char data. (Nothing bad will happen if you leave out the N, nor if you
> use character type varchar - but it will cuase SQL Server to do an
> implicit conversion under the hood. I prefer to use explicit conversion,
> or no conversion at all).
>
>
> >I'm not brave enough to give it a go anyway!!!
>
> Always test code suggestions on a test database. Make sure you have a
> recent backup or another means to retore the data. And if possible,
> enclose the code to be tested in a transaction, so that you can rollback
> the changes if something goes awry.
>
> Following the above advise for code you write yourself is not exactly a
> bad idea either :-)
>
> 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
- Multiple variables
- Prev by Date: why the result of the query is in asending order
- Next by Date: Re: Multiple variables
- Previous by thread: Re: Multiple variables
- Next by thread: Re: Multiple variables
- Index(es):
Relevant Pages
|
|