Unix Technical Forum

Re: Generating custom keys

This is a discussion on Re: Generating custom keys within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi, We had a project where we where maintaining a table for primary to generate and use that value ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 05:58 PM
AMIT
 
Posts: n/a
Default Re: Generating custom keys

Hi,


We had a project where we where maintaining a table for primary to
generate and use that value in other table. From your eaxplanation i
little unclear about what exactly you are trying to do. Can you give
some breif overview of scenarion.

Thanks , Amit
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 05:59 PM
Matt Rellick
 
Posts: n/a
Default Re: Generating custom keys

They generate their keys by creating a key table for each data table.
The key table contains one row which stores the next value to be
inserted into the data table. (Actually they maintain 3 integers which
get concatonated together to form a Decimal(16), but the principle is
the same). So when ever they want to generate a new key, the select the
values from the key table, and then update the value in the table.

What I want to be able to do is to somehow be able to insert values from
a select statement into a table (somehow generating a new key) without
using a cursor. I'm not sure it's going to be possible, but I just
trying to see if someone has thought of a way to do this.

The only way that I think it could even be possible is to load the
values I want to insert into a temp table with an identity field. Get
the number of records in that table, and instead of incrementing the key
table by 1, increment it my the count of the temp table. Then create a
function that will generate the key value from the identity field and
the intitial value of the key table. I think this would work, but I
don't know if performance wise it would be any better than a cursor.

Any ideas or thoughts?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:41 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com