question

roopakumarir avatar image
roopakumarir asked

Need SQL'S for string patterns below

1) string that have same letter with or without space 2) string starts with 3 digit same number 3) string starts with NULL 4) string that starts with sequential digits 5) string that has sequential alphabets 6) string only one character (digit or letter) 7) string has same character repeated 3 times except for OOO 8) string has three characters, 1 digit and two letters or 2 digit one letter 9) string that has two characters one digit and one letter
sql-server-2008
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

SirSQL avatar image SirSQL commented ·
How can you have a string that starts with a NULL? It's either NULL or not.
1 Like 1 ·
TimothyAWiseman avatar image TimothyAWiseman commented ·
You can have an ascii null character without the field being null. I ran into this once due to odd formatting in a text file being input.
1 Like 1 ·
SirSQL avatar image SirSQL commented ·
Damn, that's crazy. I've never seen such a thing.
0 Likes 0 ·

1 Answer

·
Fatherjack avatar image
Fatherjack answered
Have you got any work done so far? It's a pretty blunt request and a long list, may be if you show some effort then we can help you get the list complete. Where have you looked for your solution so far - Books Online is a great place to start, you could need LIKE ( http://msdn.microsoft.com/en-us/library/ms179859.aspx) and if there are lots or rows to process then you may even need to use a CLR function for speed and flexibility
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

TimothyAWiseman avatar image TimothyAWiseman commented ·
For some of these, like no 4 I would be very tempted to use CLR and gain RegEx. No 6 is a straightforwad call to Len though.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.