Home Blog Page 8

"Reflect" a TSQL routine

0
Ever want to see the text of a stored procedure, function, or trigger -- or manipulate the text in some way? sp_helptext works, sort of. But I really don't like the way it handles large procedures (> 4000 characters). They seem to end up with some strangely wrapped lines and other side-effects that...

Script out PKs/UNIQUE constraints and referencing FKs

16
In the course of my work, I occasionally need to cluster a primary key that's nonclustered, or go the other way, or make some other modification to a primary key... But it's a hassle! All of the foreign keys need to be dropped, the PK needs to be dropped, and then everything needs to...

Pattern-based split string

9
"hickymanz" asked in the SQL Server Central forums for a method of counting unique words in a text column. Wayne Lawton recommended using a string split function, which was a good idea, but not quite adequate for the job in my opinion. Typical string split functions, like this one that I wrote can...

Bitmask Handling, part 4: Left-shift and right-shift

8
Quick installment this time. Left-shift and right-shift operators. Left-shift and right-shift are integral to binary mathematical operations as they have two important qualities: Left-shifting a bitmask once multiplies by two. Right-shifting once divides by two. For example: 0011 (base 2) = 1 + 2 = 3 3 << 1 = 0110 (base 2)...

Bitmask Handling, part 3: Logical operators

4
It's been longer than I hoped since my last installment on bitmask / big number handling. Life caught up with me and I've had many thankless tasks to catch up on. But that's over now and I'm back to the general slacking that typifies my days, so welcome to Part 3, handling logical operators....

Bitmask Handling, part 2: Bitmask reconstitution

3
Posting the first part of my series on bitmasks (yes, this is now officially a series) taught me a lot about my readers: You don't care about handling bitmasks in the database. And I respect you for that! I'm overjoyed, as a matter of fact! That article has received the least hits of anything...

Correction on bitmask handling

2
In the article on handling bitmasks I posted the other day, I made a fatal error in the splitBitmask function. The function treated the low byte as the first byte, instead of the high byte. Therefore: 0x01 != 0x0001 ... and that is not good! So here's a corrected version...

Dealing with very large bitmasks

8
Continuing in my series of things you should probably not do in SQL Server but sometimes have to, I'm going to do a few posts on dealing with very large bitmasks. Let me first state my utter hatered of bitmasks in databases. I think they're annoying, make the system difficult to understand, and...

Validate a URL from SQL Server

25
File this one in your folder of things you should probably never use -- but maybe, some day, in an emergency, you'll need this. I see posts requesting this functionality all the time. "How do I validate a URL in SQL Server?" Not just the string, but the URL itself -- how can...

Counting occurrences of a substring within a string

22
I have absolutely no idea why anyone wants to do this, but I keep answering the same question in forums: "How do I count the occurrences of a substring within a string?" In an effort to thwart carpal tunnel syndrome, I have created the Ultimate Substring Occurrence Counting UDF. ... And...

Popular Posts