Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1112131415»»

What will be the output of the following? Expand / Collapse
Author
Message
Posted Tuesday, June 29, 2010 12:51 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 5:59 PM
Points: 31,082, Visits: 15,529
Once it's edited on the site, it will go out as the corrected version.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #944964
Posted Tuesday, June 29, 2010 12:53 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 5:59 PM
Points: 31,082, Visits: 15,529
Slight correction. It goes out edited in the next day's newsletter if it's not already scheduled. Sometimes we are scheduled out 2-3 days in a row.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #944966
Posted Wednesday, June 30, 2010 12:03 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, December 28, 2011 6:08 AM
Points: 2, Visits: 19
in identity (-1,1) no first paramaeter shows number start from and second parameter shows number increment by mentioned. in that case "mainkey" will start from -1 and increased by 1. so Result will be

-1,0,1.

inf u will execute insert into MyTable default values

then mainkey will be -1

next time : insert into MyTable default values

mainkey =mainkey +1

so it will be 0


next time : insert into MyTable default values

mainkey =mainkey +1

so it will be 1

is it right ?
Post #945218
Posted Wednesday, June 30, 2010 8:33 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 5:59 PM
Points: 31,082, Visits: 15,529
You are correct. The question was edited on the website to be (-1,-1). When you click through from the newsletter, that is what is shown.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #945532
Posted Wednesday, June 30, 2010 10:53 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, April 22, 2011 10:44 AM
Points: 2, Visits: 23
I object.

The question presented in the email had:
mainkey int not null identity (-1,1)

but the code in the question and answer on the web site had:
mainkey int not null identity (-1,-1)

Post #945649
Posted Wednesday, June 30, 2010 10:57 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, September 5, 2014 2:00 PM
Points: 2,160, Visits: 2,191
Sadowy,

I think it is very common for the questions/answers to be corrected/edited between when they are email and when you may get to the web site. Being on the west coast of the US corrections are normally made before I get up and attempt the question.

Given that I don't pay much attention to the question in the email, I always read and answer what is on the web site.
Post #945652
Posted Wednesday, June 30, 2010 11:16 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, December 7, 2010 8:13 AM
Points: 436, Visits: 322
sadowy (6/30/2010)
I object.

The question presented in the email had:
mainkey int not null identity (-1,1)

but the code in the question and answer on the web site had:
mainkey int not null identity (-1,-1)



EDIT: Removing grumpy comment that I added. Sorry, it has been a tough day.
The reason the email and question are different is explained in the 13 previous pages. You probably do not have to look much past page 2.
Post #945668
Posted Wednesday, June 30, 2010 2:19 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, April 22, 2014 12:46 PM
Points: 100, Visits: 135
This may have been covered but can someone tell me why the answer says the order will be -1,-2,-3 since in the create table NO PK IS DEFINED? I understand that this is the order the data was inserted, but without a PK or more specificly a clustered index how can you be assured of the data sort order.
Post #945778
Posted Wednesday, June 30, 2010 2:40 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, September 5, 2014 2:00 PM
Points: 2,160, Visits: 2,191
badatthis: Yes, that issue has been brought up more than once. And I think it goes further than that, even with a PK/clustered index you aren't guaranteed a sort order unless you specify ORDER BY in your SELECT statement. (If I am wrong on this can somebody correct me?)
Post #945785
Posted Wednesday, June 30, 2010 4:06 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Monday, September 22, 2014 6:13 AM
Points: 20,578, Visits: 9,618
UMG Developer (6/30/2010)
badatthis: Yes, that issue has been brought up more than once. And I think it goes further than that, even with a PK/clustered index you aren't guaranteed a sort order unless you specify ORDER BY in your SELECT statement. (If I am wrong on this can somebody correct me?)


no you're right.
Post #945835
« Prev Topic | Next Topic »

Add to briefcase «««1112131415»»

Permissions Expand / Collapse