June 17, 2009 at 10:46 am
Florian Reischl (6/17/2009)
@Jeffrey:Erm... Just played with this nullbuster. This might be an important information for you:
This feature works find on SSE2k5 but it does not work anymore on SSE2k8 for bulk inserts like:
INSERT INTO dupNulls (X)
SELECT 1
UNION ALL SELECT NULL
UNION ALL SELECT NULL
Flo
Hmm - works fine for me. Are you sure it isn't failing because you already have a row with a 1 in the X column?
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
June 17, 2009 at 10:48 am
Jeffrey Williams (6/17/2009)
Hmm - works fine for me. Are you sure it isn't failing because you already have a row with a 1 in the X column?
Well, I'm out now for coffee!!!
Sorry!
June 17, 2009 at 11:36 am
Florian Reischl (6/17/2009)
Jeffrey Williams (6/17/2009)
Hmm - works fine for me. Are you sure it isn't failing because you already have a row with a 1 in the X column?Well, I'm out now for coffee!!!
Sorry!
Well - there you go. Already on my fourth cup :w00t:
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
June 17, 2009 at 11:53 am
Jeffrey Williams (6/17/2009)
only4mithunc (6/17/2009)
since by default the unique identifire is non-clustured , the records should be in the same order I have inserted na..?By definition, a table has no order. The only way to guarantee the order data is returned is to provide an ORDER BY on the query. Without an ORDER BY - SQL Server can return the results in any order.
Should that be by definition, a table is in clustered index order but a SELECT is not guaranteed to return data in that order without an ORDER BY? 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
June 17, 2009 at 1:53 pm
Florian Reischl (6/17/2009)
@Jeffrey:Erm... Just played with this nullbuster. This might be an important information for you:
This feature works find on SSE2k5 but it does not work anymore on SSE2k8 for bulk inserts like:
Flo
Even if that was the case, on 2008 there's a neater solution to unique indexes with multiple nulls.
CREATE TABLE dupNulls (
pk int identity(1,1) primary key,
X int NULL,
)
CREATE UNIQUE INDEX idx_UniqueX
ON dupNulls (X)
WHERE X IS NOT NULL
GO
INSERT INTO dupNulls(X) VALUES (1)
INSERT INTO dupNulls(X) VALUES (NULL)
INSERT INTO dupNulls(X) VALUES (NULL)
GO
SELECT pk, X FROM dupNulls
UPDATE dupNulls SET X = 1 WHERE pk = 2
GO
SELECT pk, X FROM dupNulls
UPDATE dupNulls SET X = 2 WHERE pk = 2
SELECT pk, X FROM dupNulls
Not allowed for unique constraints, just unique indexes.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 17, 2009 at 2:00 pm
GilaMonster (6/17/2009)
Florian Reischl (6/17/2009)
@Jeffrey:Erm... Just played with this nullbuster. This might be an important information for you:
This feature works find on SSE2k5 but it does not work anymore on SSE2k8 for bulk inserts like:
Flo
Even if that was the case, on 2008 there's a neater solution to unique indexes with multiple nulls.
CREATE TABLE dupNulls (
pk int identity(1,1) primary key,
X int NULL,
)
CREATE UNIQUE INDEX idx_UniqueX
ON dupNulls (X)
WHERE X IS NOT NULL
GO
INSERT INTO dupNulls(X) VALUES (1)
INSERT INTO dupNulls(X) VALUES (NULL)
INSERT INTO dupNulls(X) VALUES (NULL)
GO
SELECT pk, X FROM dupNulls
UPDATE dupNulls SET X = 1 WHERE pk = 2
GO
SELECT pk, X FROM dupNulls
UPDATE dupNulls SET X = 2 WHERE pk = 2
SELECT pk, X FROM dupNulls
Not allowed for unique constraints, just unique indexes.
Oh, totally forgot about filtered indexes in 2008 - thanks.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
June 17, 2009 at 2:16 pm
GilaMonster (6/17/2009)
Florian Reischl (6/17/2009)
@Jeffrey:Erm... Just played with this nullbuster. This might be an important information for you:
This feature works find on SSE2k5 but it does not work anymore on SSE2k8 for bulk inserts like:
Flo
Even if that was the case, on 2008 there's a neater solution to unique indexes with multiple nulls.
CREATE TABLE dupNulls (
pk int identity(1,1) primary key,
X int NULL,
)
CREATE UNIQUE INDEX idx_UniqueX
ON dupNulls (X)
WHERE X IS NOT NULL
GO
INSERT INTO dupNulls(X) VALUES (1)
INSERT INTO dupNulls(X) VALUES (NULL)
INSERT INTO dupNulls(X) VALUES (NULL)
GO
SELECT pk, X FROM dupNulls
UPDATE dupNulls SET X = 1 WHERE pk = 2
GO
SELECT pk, X FROM dupNulls
UPDATE dupNulls SET X = 2 WHERE pk = 2
SELECT pk, X FROM dupNulls
Not allowed for unique constraints, just unique indexes.
Heh. As soon as I started reading this thread, I thouhg "filtered indexes in 2008! Now if only Gail hasn't seen this thread yet ..." Rats, I've got to quit work earlier! 🙂
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 7 posts - 16 through 21 (of 21 total)
You must be logged in to reply to this topic. Login to reply