x

How would you create a set of all possible unicode strings?

Ok, so something I need to do is a bit of investigation into how collations are managed, and how you could use .NET code to compare a string in the same way that any given collation would...

So, for this, I need to try and create a data set which contains all possible two-character unicode strings. Seeing as this will end up being 4 billion rows, it could potentially be quite (very) time consuming.

So I thought I would ask you guys how you would go about doing it.

A bit of background:

This is because I need to be able to take the output of two ordered SELECT statements from two DBs with identical schema, and in .NET be able to tell which row would come 'later'. This is so that if the databases contain different data, I can read from the side which has extra rows until the streams are back in sync. This is pretty easy for numeric types, but I need to work with string types too.

more ▼

asked Jan 25, 2010 at 06:42 AM in Default

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.5k 61 65 87

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Don't create a table with all the values, make one with all the Unicode characters - nchar(0) to nchar(65535) - joining it to itself to get the two-character strings.

more ▼

answered Jan 25, 2010 at 08:00 AM

Rob Farley gravatar image

Rob Farley
5.7k 16 18 20

dagnabit, I was going to suggest a table with a self join but thought there must be a good reason not to ... grudging +1 !;)
Jan 25, 2010 at 05:55 PM Fatherjack ♦♦
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x991
x22

asked: Jan 25, 2010 at 06:42 AM

Seen: 866 times

Last Updated: Jan 25, 2010 at 06:42 AM