January 4, 2013 at 7:30 am
mtassin (1/4/2013)
Since Uniqueness constraints basically enforce what they do with Unique Indexes, I was thinking that nobody uses Unique constraints anymore and just uses unique indexes since they can be filtered. 🙂
A unique index can also contain INCLUDEd columns, whereas the index generated by a unique coinstraint cannot.
January 4, 2013 at 7:31 am
Sean Lange (1/4/2013)
SQLRNNR (1/3/2013)
I have to disagree with the correct answer(s). The question asks for 4 correct answers yet 5 are presented. This causes a bit of a guessing game.+1
I had to guess which 4 of the 5 correct answers were expected. I chose incorrectly.
Lol Join the club 🙂
January 4, 2013 at 7:44 am
Poorly worded question.
+1
January 4, 2013 at 7:49 am
Sean Lange (1/4/2013)
SQLRNNR (1/3/2013)
I have to disagree with the correct answer(s). The question asks for 4 correct answers yet 5 are presented. This causes a bit of a guessing game.+1
I had to guess which 4 of the 5 correct answers were expected. I chose incorrectly.
+ 1
January 4, 2013 at 8:00 am
I feel sure that this was a misleading question, as five, not four, of the answers were valid.
The reputation of these questions is once again dragged through the gutter.
Kenneth Spencer
You never know: reading my book: "All about your computer" might just tell you something you never knew!
lulu.com/kaspencer
January 4, 2013 at 8:03 am
Lively debate today. It seems it is very hard to write a question of this sort without some confusion attached. Straight SQL questions with unequivocal results seem to be the best bet.
January 4, 2013 at 8:23 am
Dineshbabu (1/3/2013)
Since last option said Unique key allows NULL values.. he didn't mention xactly one NULL value in the option . so I choosed other 4 and got it correct..--
Dineshbabu
Dineshbabu is right..
the options says NULL Values, not exactly one NULL.
Thank You.
January 4, 2013 at 8:30 am
SQLRNNR (1/3/2013)
dineshbabus (1/3/2013)
oh.. unique constraint can allow more than one null value.. I don't think so.. Please give me some xample...Here is the example
Took this a bit further. You can only have one of each record:
CREATE TABLE sometest (testid INT, col1 INT, col2 INT);
ALTER TABLE sometest
ADD CONSTRAINT someconstraint UNIQUE (testid,col1,col2);
INSERT INTO sometest(testid,col1,col2)
VALUES (NULL,1,1),(1,NULL,1),(NULL,NULL,NULL),(1,1,NULL);
SELECT *
FROM sometest;
INSERT INTO sometest(testid,col1,col2)
values(null,null,NULL);
SELECT *
FROM sometest;
DROP TABLE sometest;
January 4, 2013 at 8:33 am
SQLRNNR (1/3/2013)
I have to disagree with the correct answer(s). The question asks for 4 correct answers yet 5 are presented. This causes a bit of a guessing game.
I too disagree with the correct answers.
But actually only 4 correct answers are presented - the first one., although claimed to be correct, says the are different but that doesn't identify any difference, so shouldn't be included when listing differences.
Anyway, it's certainly not a well designed question!
Tom
January 4, 2013 at 8:34 am
pchirags (1/4/2013)
the options says NULL Values, not exactly one NULL.
create table temp
(a int, b int, constraint ukTemp unique (a,b))
go
insert into temp values (null,null),(null,1),(1,null)
go
Three rows contain Null values. One of them contains two.
January 4, 2013 at 8:49 am
Dineshbabu (1/3/2013)
I think few days back same conversation happened... Unique constraint is different from unique index. While creating unique index we can create with filter and that will allow more than one NULL value but not with unique constraint.--
Dineshbabu
create table #Test (P int identity primary key, A int, B int, unique(A,B))
insert #Test(A,B) values(1,NULL),(2,NULL),(3,NULL),(NULL,1),(NULL,2),(NULL,3)
insert #Test(A,B) values (NULL,NULL)
select * from #Test order by P
drop table #TestTry running that code and you'll see that despite teh unique constraing column A has 4 rows with NULL in it, and column B has 4 rows with null in it. In fact there are 7 rows and in every one of them either A or B or both are null.
Your statement about only one null being permitted is valid only when the unique constraint applies to a single column; it is not valid when it applies to multiple columns.
Tom
January 4, 2013 at 8:59 am
I disagree with the list of correct answers: this list should contain 5 answers, not 4.
Asking to choose 4 answers makes it confusing
January 4, 2013 at 9:53 am
Bobby Russell (1/4/2013)
Poorly worded question. The 4 items I selected were the BEST possible of the 5 that ARE ACTUALLY CORRECT answers AS STATED and has been pointed out by everyone else here already. Sadly, his choice of what is CORRECT are not mine and thus I am WRONG. I'll miss my point. :Whistling:
Totally right, I want my point back 😀
January 4, 2013 at 10:01 am
Victor Abkin (1/4/2013)
I disagree with the list of correct answers: this list should contain 5 answers, not 4.Asking to choose 4 answers makes it confusing
There are 4 correct ansers - 2,4,5 and 6 - just not the answers marked as being correct.
January 4, 2013 at 10:11 am
Toreador (1/4/2013)
Victor Abkin (1/4/2013)
I disagree with the list of correct answers: this list should contain 5 answers, not 4.Asking to choose 4 answers makes it confusing
There are 4 correct ansers - 2,4,5 and 6 - just not the answers marked as being correct.
Is number 3 an incorrect statement?
Viewing 15 posts - 31 through 45 (of 70 total)
You must be logged in to reply to this topic. Login to reply