Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Predict the outcome


Predict the outcome

Author
Message
bazzkar
bazzkar
SSC-Enthusiastic
SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)SSC-Enthusiastic (160 reputation)

Group: General Forum Members
Points: 160 Visits: 72
Comments posted to this topic are about the item Predict the outcome
ziangij
ziangij
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2979 Visits: 376
thanks, nice simple one... :-)
Open Minded
Open Minded
SSC-Enthusiastic
SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)

Group: General Forum Members
Points: 188 Visits: 567
1% of 186 or 2 people answered in relation to user permission. I bet these same people were wary of syntax errors and gotchas.
cengland0
cengland0
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1532 Visits: 1300
The URL in the explanation didn't say you cannot use a zero -- at least not that I found.

So why can't you use it? If you have IDENTITY INSERTS on, can't you duplicate values on an Identity column? I never tried that but I think you can unless you also create a constraint to make it unique. So I thought if you have an increment of 0, you'd get the same number in the identity column for every new row.
Rune Bivrin
Rune Bivrin
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3770 Visits: 1484
I couldn't find any mention of the restriction on increment either. My gut reaction was to answer "error" given that an zero increment makes no sense, but as I couldn't see that in the documentation I figured it may actually be valid.

I should have followed my first thought...


Just because you're right doesn't mean everybody else is wrong.
Duncan Pryde
Duncan Pryde
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3422 Visits: 1552
Rune Bivrin (7/15/2010)
I couldn't find any mention of the restriction on increment either.
.


I agree, there doesn't seem to be any mention in the documentation about it. And it's not just zero increments - you can't have a seed or increment which has a higher value than the maximum for the data type, or lower than the minimum (hence you can't have negative increments with tinyint identity columns). You can't have fractional values for either seed or increment, etc., etc.

All semi-obvious, but as yet I can't find any official documentation.

Duncan
ronmoses
ronmoses
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1111 Visits: 996
Good question. In retrospect it seems obvious, and I think that's why I didn't go with the obvious answer. Like others I researched the question as far as possible without actually running the script, and I couldn't find any solid documentation on it either. I went with "can't predict" figuring there might be an option set that could affect the outcome.

-----
a haiku...

NULL is not zero
NULL is not an empty string
NULL is the unknown

Bob Razumich
Bob Razumich
Mr or Mrs. 500
Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)Mr or Mrs. 500 (536 reputation)

Group: General Forum Members
Points: 536 Visits: 1169
For all who look at the data in the URL, I agree that there is no explicit statement that one cannot have a 0 increment. I suppose the following line,

"If an identity column exists for a table with frequent deletions, gaps can occur between identity values. If this is a concern, do not use the IDENTITY property. "

infers that issue, if you add to the sentence "because the identity property may try to make a duplicate after you fill in a gap without proper coding to look for duplicates" etc.

If one does try to run the command, the actual error message that I got was "Identity column 'mainkey' contains invalid INCREMENT." So it's an "undocumented feature."

And no, I honestly didn't execute the command before I answered the question.
OCTom
OCTom
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2847 Visits: 4152
It makes sense to me that an identity increment can't be zero. An identity column is supposed to be a unique index on a row. If you had zero for the increment, all rows would have the same value; the starting value. That would make no sense at all.

Do we really need to have Microsoft tell us the perfectly obvious? w00t
Terri Walls
Terri Walls
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 85
BTW, the answer ,"Explanation: We cannot use 0 as the incremental seed of the primary key. " Is not accurate. The create statement does not mention primary key. It is an invalid increment of an identity column, nothing to do with the primary key or lack thereof.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search