March 7, 2012 at 7:40 am
Golden_Behzad (3/7/2012)
For Create Function For SequenceID YouCan Use This Function But This Function Is Very Bad Performance and If multi user call this in some time generate duplicate id .to generate almost sequence id i can use guid as binary in last code to generate unique id but not sequence
That's what I've been trying to tell you. Creating your own sequence function will be nothing but a performance mess and possibly cause duplicate ID's. The auto-numbering of the sequential numbers of an IDENTITY type of column are absolutely bullet-proof and incredibly fast. You'll need to add an extra column to hold the result of your function, anyway, so why not use what's built in?
--Jeff Moden
Change is inevitable... Change for the better is not.
March 8, 2012 at 7:59 am
how to use?
March 8, 2012 at 8:02 am
Golden_Behzad (3/8/2012)
how to use?
As explained previously in this thread, it is an IDENTITY.
http://msdn.microsoft.com/en-us/library/ms186775.aspx
_______________________________________________________________
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/
March 8, 2012 at 8:05 am
Golden_Behzad (3/8/2012)
how to use?
Please lookup IDENTITY column in Books Online. It's nothing more than a simple autonumbering column that you would add to each table and make it the clustered index instead of the GUID. The GUID could still be the PK. You wouldn't have to change any of the logic that uses the GUID.
You would STILL have to make sure you did regular index maintenance on your GUID column but that's true for any index.
In some cases and depending on the content of the table, you might not have to add an IDENTITY column. You could make the clustered index on a combination of a date column (to make the clustered index "ever increasing") and the GUID (to make the clustered index "unique").
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply