May 24, 2006 at 11:00 pm
@delimiter varchar(1)
@delimiter = char(254)
@string varchar(200)
@string = 'Abc' + @delimiter + 'qwe'
@index int
substring( @string, 0, @index)
May 25, 2006 at 12:17 am
I think you may have the 'column result width' set to 14. Can you do the following select and see what it displays:
select 'qwertyuiuoipthe'
If it returns 'qwertyuiuoipth', then you will need to do the following:
In Query Analyser menu, select Tools->Options and then Results tab, then change the 'maximum characters per column' to an appropriate value.
May 25, 2006 at 12:36 am
May 25, 2006 at 2:07 am
hi,
are you expecting it to return qwertyuiuoipthe ?
that's the result i get on my SQL Server 2000
Paul
May 25, 2006 at 6:26 pm
May 26, 2006 at 6:58 am
This is strange indeed, and unfortunately I can't repro it.
On both 2000 and 2005 the example above returns the expected string. No sign of the strange truncate behaviour.
/Kenneth
May 26, 2006 at 9:02 am
I also attempted to reproduce the problem on SQL 2000 but was unable too.
When I run your code it returns "qwertyuiuoipthe" as expected.
Sorry that I couldn't be more helpful.
May 26, 2006 at 9:49 am
It's probably not a bug, rather a collation issue. That's why some people can see it and others can't (I can). Try this (including the people who couldn't repro with the original example) and you're likely to see the difference; I get 3 the first time and 1 the second:
declare @delimiter char(1)
set @delimiter = CAST(char(254) AS VARCHAR(1)) COLLATE SQL_Latin1_General_CP1251_CI_AS
select charindex(@delimiter,'th' + @delimiter)
set @delimiter = CAST(char(254) AS VARCHAR(1)) COLLATE Latin1_General_CS_AI
select charindex(@delimiter,'th' + @delimiter)
>L<
May 26, 2006 at 9:57 am
hi, i still get 3 in both cases ...
Paul
May 26, 2006 at 10:12 am
This might have something to do with our base collations. Mine is Latin1_General_CS_AI. What's yours?
>L<
May 26, 2006 at 10:29 am
(this post may appear twice)
I did a little experimenting and, if I set up a scratch database with a collation of SQL_Latin1_General_Cp1_CI_AS, I don't see the difference. I'm pretty sure this is it. BOL says:
Note The Setup program does not set the instance default collation to the Windows collation Latin1_General_CI_AS if the computer is using the U.S. English locale. Instead, it sets the instance default collation to the SQL collation SQL_Latin1_General_Cp1_CI_AS. This may change in a future release.
... the gentleman with the question may not be set to a U.S. English locale. I am, but I changed the default explicitly during setup (again, mine is Latin1_General_CS_AI).
The point is that if he uses an extended character, or at least this one, he may have to declare its codepage/collation before it will work as a delimiter. It may or may not be a bug, I'm not sure.
>L<
May 28, 2006 at 6:22 pm
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply