Comments Feed

Puzzle Me This: String Replacement Commented on: 26 weeks ago (April 10, 2015)

Here is my take at it.

DECLARE @Keyword NVARCHAR(1000) = N'wwAMxxAMyyAMzz',
@Source NVARCHAR(1000) = N'AM',
@Synonym NVARCHAR(1000) = N'AN';

DECLARE @Permutations INT...

Find a Minimum Missing Value Commented on: 47 weeks ago (November 14, 2014)

Slightly less cost. Reduce the WHERE clause like this

SELECT col1, LEAD(col1, 1, 0) OVER(ORDER BY col1) AS nxt
FROM dbo.T1

Identifying a Subsequence in a Sequence, Part 3 Commented on: 1 year ago (July 15, 2014)

Thank you Itzik for this excellent walk-through!

Identifying a Subsequence in a Sequence, Part 1 Commented on: 1 year ago (February 6, 2014)

See my set-based solution in second part of this article.
1.5 seconds and 14 000 reads.

Identifying a Subsequence in a Sequence, Part 2 Commented on: 1 year ago (February 6, 2014)

Hi Itzik.

The problem is just another Relational Division; Ordered Relational Division. My solution finishes in just 1.5 seconds and uses about 14000 reads.

DECLARE @Items INT = (...

What's a good use for a UNIQUE filtered index? Commented on: 3 years ago (November 21, 2011) I use it to enforce data integrity in our data warehouse. Currently there are two business systems feeding the DW with data, and some tables (like Orders.SalesDetail) containts data from both systems...
Use T-SQL to Generate a Sequence Commented on: 4 years ago (August 22, 2011) Itzik, let me know if you got my script by email. //Peter
Solutions to TSQL Challenge – Reoccurring Visits Commented on: 4 years ago (July 14, 2011) Not bad Mr Celko. Not bad at all. It's clever to build a "dual date" cte holding yesterday's and today's dates. Add "sum(today_flg) as NumVisits," to the final output...
TSQL Challenge – Reoccurring Visits Commented on: 4 years ago (July 6, 2011) Here is my stats with 100,000+ row sample data using same date interval as original (8 row(s) affected) Table 'Worktable'. Scan count 0, logical reads 0. Table 'DailyVisits'. Scan...
Solutions to Packing Date and Time Intervals Puzzle Commented on: 4 years ago (March 25, 2011) Where is my #3? ;-)

Digital Magazine Archives

Browse back issues of SQL Server Pro, from January 2007 through the last issue published in April 2014. Find the back issues here.


From the Blogs
Sep 29, 2015

Data Breaches and Insider Threats

I’ll sound a bit like Captain Obvious for bringing this up, but it’s important to remember that security encompasses a lot more than protecting sensitive data from the specter of outsider threats like hackers. Properly implemented security policies also account for threat-models that include insiders – or people within your organization....More
Sep 15, 2015

Setting Up Additional Checks to Ensure Regular Transaction Log Backups 1

There’s simply no way to overstate the importance of regular Transaction Log Backups. Not only do they help protect from disaster, but regular execution of T-Log backups on Full (and Bulk-Logged) Recovery databases helps keep thing “fit and trim”. Most of the time, setting up a Notification for when T-Log Backup Jobs fail is enough to let you know when something goes wrong....More
Sep 1, 2015

Stop Using INFORMATION_SCHEMA and SysObjects for Exists Checks 3

Code like this isn’t optimal: IF EXISTS(SELECT * FROM sys.objects WHERE name = N'TableToDrop' AND type = 'U')         DROP TABLE TableToDrop; GO Neither is this: IF EXISTS(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'TableToDrop')         DROP TABLE TableToDrop; GO Yet, I see both of those used all of the time – over and over again. Even though it’s 2015.  ...More
SQL Server Pro Forums

Get answers to questions, share tips, and engage with the SQL Server community in our Forums.

Sponsored Introduction Continue on to (or wait seconds) ×