Uniqueidentifier

  • Thread starter Thread starter Tommy Malone
  • Start date Start date
T

Tommy Malone

Is there another method besides using a uniqueidentifier column and
(newid()) default value to create a "transactionid" for entries into a
table? Is there a method with VB code to create a transactionid unique to a
table, possibly with formatting (such as 0000000001, and so on)?

Thanks.
 
Not sure what you mean by "transaction id".

If you mean a primary key you could use an auto increment number. you have
also the timestamp datatype. This column is automatically updated whenever
the row is updated.

If still something else tells us what is this "transaction id" used for...

Patrice
 
I'm intending "transactionid" to be synonymous with some unique number to
identify an entry into a table. Timestamp is not appropriate for my needs
because it changes as the row may change. I prefer a 7 or 8 digit numeric
value, unique to each row if possible.
 
This is a primary key. You could then use the first option I described (auto
increment number) :

create table autonum(
pk int identity not null primary key,
somedata varchar(40) not null)
go

insert into autonum values ('Hello')
insert into autonum values ('World !')
select * from autonum
 
So your reply is SQL and needs to be executed against the table or it's what
gets entered into the default value property of the column.
 
Back
Top