sqlserver-tips.blogspot.com
SQL Server Tips: November 2006
http://sqlserver-tips.blogspot.com/2006_11_01_archive.html
Friday, November 03, 2006. Starting concurrency tests simultaneously could be tricky, especially they need to start at the same time from different workstations. One way to do it:. CREATE TABLE WhistleSound(i INT). SET @cnt = 0. WHILE (@cnt = 0) BEGIN. SELECT @cnt = COUNT(*) FROM WhistleSound WITH(NOLOCK). IF @cnt = 0. From one connection run. From another connection run. From third connection run. Posted by Alex Kuznetsov @ 2:56 PM. When Snapshot Isolation Helps and When It Hurts. Matija Lah's Blog (MVP).
sqlserver-tips.blogspot.com
SQL Server Tips: October 2006
http://sqlserver-tips.blogspot.com/2006_10_01_archive.html
Friday, October 27, 2006. Child Intervals Of Time Inside Parent Ones - Enforced By RI. I needed to enforce a business rule that appointments fit into shifts. The only one watertight way of doing it that i know about is to use RI, as follows:. CREATE Table Shifts(ShiftID INT NOT NULL PRIMARY KEY,. StartedAt DATETIME NOT NULL,. FinishedAt DATETIME NOT NULL,. CONSTRAINT UK Shifts UNIQUE(ShiftID, StartedAt, FinishedAt). INSERT Shifts VALUES(1, '20061025 08:00AM', '20061025 05:00PM'). These updates succeed: a...
sqlserver-tips.blogspot.com
SQL Server Tips: July 2007
http://sqlserver-tips.blogspot.com/2007_07_01_archive.html
Monday, July 23, 2007. All Permutations For A String. Suppose you have a auxiliary Numbers table with integer numbers. DECLARE @s VARCHAR(5);. SET @s = 'ABCDE';. WITH Subsets AS (. SELECT CAST(SUBSTRING(@s, Number, 1) AS VARCHAR(5) AS Token,. CAST('.' CAST(Number AS CHAR(1) '.' AS VARCHAR(11) AS Permutation,. CAST(1 AS INT) AS Iteration. FROM dbo.Numbers WHERE Number BETWEEN 1 AND 5. SELECT CAST(Token SUBSTRING(@s, Number, 1) AS VARCHAR(5) AS Token,. SIteration 1 AS Iteration. BETWEEN 1 AND 5. Matija Lah...
sqlserver-tips.blogspot.com
SQL Server Tips: June 2007
http://sqlserver-tips.blogspot.com/2007_06_01_archive.html
Friday, June 22, 2007. One More Article on Devx.com. Enforce Business Rules for All Your Data with Constraints". Http:/ www.devx.com/dbzone/Article/34479. This article is a reply to Paul Nielsen's post on sqlblog.com. Http:/ sqlblog.com/blogs/paul nielsen/archive/2006/12/18/430.aspx#comments. Posted by Alex Kuznetsov @ 11:35 AM. Thursday, June 21, 2007. Materialized Path: Making Sure a Tree has No Cycles. The following DDL guarantees no cycles for Materialized Path:. ParentPath VARCHAR(900) NULL,. INSERT...
sqlserver-tips.blogspot.com
SQL Server Tips: December 2006
http://sqlserver-tips.blogspot.com/2006_12_01_archive.html
Saturday, December 09, 2006. Maximum selectivity for bookmark lookups depends on row size. Assuming Numbers table with 10000 rows. CREATE TABLE WideRows(i INT NOT NULL PRIMARY KEY, j INT NOT NULL, c. INSERT WideRows SELECT Numbers.Number, Numbers.Number 1, 'asdf' FROM. CREATE INDEX WideRows j ON WideRows(j). Break even point close to 4%. SELECT i, j, c FROM WideRows WHERE j BETWEEN 1000 AND 1400. CREATE TABLE HugeRows(i INT NOT NULL PRIMARY KEY, j INT NOT NULL, c. CREATE INDEX HugeRows j ON HugeRows(j).
sqlserver-tips.blogspot.com
SQL Server Tips: September 2007
http://sqlserver-tips.blogspot.com/2007_09_01_archive.html
Thursday, September 06, 2007. The blog has moved to www.sqlblogcasts.com. I will continue posting over there at www.sqlblogcasts.com. Simon Sabon has moved the blog over to www.sqlblogcasts.com. Posted by Alex Kuznetsov @ 8:15 AM. View my complete profile. Erland Sommarskog's home page (MVP). Tony Rogerson's ramblings on SQL Server (MVP). Dimant DataBase Solutions (MVP). Matija Lah's Blog (MVP). Greg Linwood's Blog (MVP). Tibor Karaszi's home page (MVP). David Portas' Blog (MVP).
sqlserver-tips.blogspot.com
SQL Server Tips: August 2007
http://sqlserver-tips.blogspot.com/2007_08_01_archive.html
Friday, August 24, 2007. Selecting a random number for each row. Create view wrapped rand view. Select rand as random value. Create function wrapped rand(). Set @f = (select random value from wrapped rand view). Select - your columns- , dbo.wrapped rand() wrapped rand. Posted by Alex Kuznetsov @ 9:57 AM. Wednesday, August 22, 2007. How to select a second page faster. This populates IDs with 3M rows, and the CAST strips IDENTITY property. SELECT CAST(my ID*1 AS BIGINT) as ID INTO IDs FROM MyTable. A diffe...
sqlserver-tips.blogspot.com
SQL Server Tips: September 2006
http://sqlserver-tips.blogspot.com/2006_09_01_archive.html
Monday, September 25, 2006. Loading Legacy Data Into parent/Child Tables With Identities. It is one of those cases when OUTPUT clause comes very handy. CREATE TABLE Staging(EmployeeCode CHAR(30), FullName VARCHAR(30),. INSERT INTO Staging VALUES('ABC1234567890XYZ0987654321', 'Doe, John',. INSERT INTO Staging VALUES('ABC1234567890XYZ0987654321', 'Doe, John',. INSERT INTO Staging VALUES('ABD123FHSDJKFH367FHASJ4321', 'Doe, Jane',. CREATE TABLE Party(PartyID INT IDENTITY PRIMARY KEY, EmployeeCode. I think th...