June 4, 2015 at 5:42 am
Strange that differt versions act so different.
That is why I have sent this QOTD
June 4, 2015 at 6:03 am
This was removed by the editor as SPAM
June 4, 2015 at 6:32 am
option B is coming in both the case in SQL server 2000 and 2008.
June 4, 2015 at 6:41 am
Great Catch!! One of the wonder of SQL Server I guess. If there's some explanation for this it would be great.
Nice Question though. Thank you
______________________________________________________________Every Problem has a Solution; Every Solution has a Problem: 🙂
June 4, 2015 at 7:10 am
what a pitiful QOTD (¬.¬) i lost my 10-row good questions.
Next time advice in which SSMS you tested it.
I got script B twice in
Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)
June 4, 2015 at 7:16 am
I am sorry not to mention which SSMS version you should use.
But I gave the SQL Server Version 2014.
So you should have known that it is not for SSMS 2008 😀
I am not be able to open a SQL 2014 Database in SSMS Version 2008.
On the other hand, SSMS is backwards compatible so I can open a 2008 Database in the SSMS 2014.
June 4, 2015 at 7:31 am
What a strange question. I assumed you would get script B in both cases. I tested this in 2008r2 and confirmed that is correct. I don't have 2014 at work so I couldn't test that version.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 4, 2015 at 7:36 am
Sorry Sean,
I was not intend to confuse you but I just would let other people know what strange behaviour SSMS (and SQL Server) sometimes has.
As mentioned before in one of my replies here. In SQL Srv 2008R2 and SQL Srv 2012 I also got script B twice.
That is why I was surprised to get script A in SQL Srv 2014, but only after insertion of data.
June 4, 2015 at 7:57 am
ArnoKwetters (6/4/2015)
Sorry Sean,I was not intend to confuse you but I just would let other people know what strange behaviour SSMS (and SQL Server) sometimes has.
As mentioned before in one of my replies here. In SQL Srv 2008R2 and SQL Srv 2012 I also got script B twice.
That is why I was surprised to get script A in SQL Srv 2014, but only after insertion of data.
Not trying to imply you attempted to confuse anybody. I think MS took care of that for us all. 😀 Strange that the scripting engine changes when a table has data in it.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 4, 2015 at 8:01 am
Strange that the scripting engine changes when a table has data in it.
I agree with that !
June 4, 2015 at 8:18 am
I get script B for both as well
June 4, 2015 at 8:21 am
in SQL Server 2014 ?
June 4, 2015 at 8:40 am
I just found the wording of the question very confusing.
June 4, 2015 at 8:59 am
Nice basic question.....Thanx. Scored 1 mark.
Thanks.
June 4, 2015 at 9:29 am
The problem with script A is the constraint name will be system generated. Script B is also written to use a system generated name. It is best practice to use Script B, but provide an name. The system generated name is unique to each instance of the database. If you ever need to write a script to update the default constraint with a system generated name, it is painful. however, if you name it, it is easy.
Viewing 15 posts - 16 through 30 (of 41 total)
You must be logged in to reply to this topic. Login to reply