Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Niagara Falls


Niagara Falls

Author
Message
Christian Buettner-167247
Christian Buettner-167247
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2949 Visits: 3889
I liked the QOTD and especially the Niagara Falls idea.

Best Regards,

Chris Büttner
Paul White
Paul White
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10338 Visits: 11350
David in .AU (7/31/2011)
This article might be interesting: note the reply from microsoft at the bottom

Replace of char(0) does not work in DB with Windows collation

I know it isn't exactly the same issue, but it runs along the same lines...

That explains it nicely - and Peter Larsson (SwePeso) added pretty much the exact same example as this QotD in the comments.



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
cengland0
cengland0
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1484 Visits: 1300
You got me on this one. I had no idea it would hang. Great question.
paul.knibbs
paul.knibbs
SSCommitted
SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)

Group: General Forum Members
Points: 1972 Visits: 6214
SQLkiwi (8/1/2011)
That explains it nicely - and Peter Larsson (SwePeso) added pretty much the exact same example as this QotD in the comments.


It's still realistically a bug, though--even if CHAR(0) is treated as an empty string in a Windows collation, REPLACE() given an empty string as its second parameter should do nothing, not hang the connection!
michael.kaufmann
michael.kaufmann
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1293 Visits: 1082
paul.knibbs (8/1/2011)
SQLkiwi (8/1/2011)
That explains it nicely - and Peter Larsson (SwePeso) added pretty much the exact same example as this QotD in the comments.


It's still realistically a bug, though--even if CHAR(0) is treated as an empty string in a Windows collation, REPLACE() given an empty string as its second parameter should do nothing, not hang the connection!


I'd also second that this is a bug, because the following works nicely:

select replace(cast('Hello World' collate SQL_Latin1_General_CP1_CI_AS as varchar(50)), char(0), '')
select replace(cast('Hello World' collate Latin1_General_100_CI_AS as varchar(50)), char(0), '')
select replace(cast('Hello World' collate Latin1_General_CI_AS as varchar(50)), char(0), '')



I'm well aware that the question was about
varchar(max)
(that's why I got it wrong)... but given only 11 characters tried it anyway.

BTW, collation Latin1_General_100_ is English (Canada) (and many others) in SQL Server 2008, while Latin1_General_ is English (Canada) for SQL Server 2000 and 2005; you may want to check out this document.

-Michael
Dhruvesh Shah
Dhruvesh Shah
SSChasing Mays
SSChasing Mays (635 reputation)SSChasing Mays (635 reputation)SSChasing Mays (635 reputation)SSChasing Mays (635 reputation)SSChasing Mays (635 reputation)SSChasing Mays (635 reputation)SSChasing Mays (635 reputation)SSChasing Mays (635 reputation)

Group: General Forum Members
Points: 635 Visits: 237
My server got hang. but from memory i have setup my instance as US. Can some one pls advise how can i find out what's my default country setting is?
Britt Cluff
Britt Cluff
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1693 Visits: 253
Good question, but not sure how you could get it right without guessing.

http://brittcluff.blogspot.com/
cengland0
cengland0
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1484 Visits: 1300
Britt Cluff (8/1/2011)
Good question, but not sure how you could get it right without guessing.

By trying it.
Eugene Elutin
Eugene Elutin
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3042 Visits: 5478
Can someone guess without executing what the following SQL will return on Canada like server setup (I have the UK one) :-D

DECLARE @var varchar(max);
SET @var = 'Hello World';
SELECT @var + CHAR(0) + @var

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
michael.kaufmann
michael.kaufmann
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1293 Visits: 1082
Dhruvesh Shah (8/1/2011)
My server got hang. but from memory i have setup my instance as US. Can some one pls advise how can i find out what's my default country setting is?


That depends on the account your SQL Server is running in.

Let's assume it's the SYSTEM account:
- Open up the Registry Editor.
- Expand HKEY_USERS\S-1-15-18\Control Panel\International
- If you click on the International key, the regional settings will show for the SYSTEM account.

If you're using a dedicated account with no changes to the default settings, you may go to:
- HKEY_USERS\.DEFAULT\Control Panel\International

If you're using a dedicated account with changes to the default settings, you'll first need to go to:
- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
- Click on any of the S-IDs to find out about the account name (usually to be identified via the ProfileImagePath value) and make a note of the S-ID for your SQL Server account.
- Then go to HKEY_USERS\S-1-15-21-xxxxxxxxx\Control Panel\International

This may not be the most elegant way, but this one definitely works and gives you the results you need.

BTW, the key for the ProfileList will always read \Microsoft\Windows NT\, regardless of the OS your server (or workstation) is running.

-Michael
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search