Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set up UniqueIdentifier column 1

Status
Not open for further replies.

wmdpontius

Programmer
Jun 23, 2000
4
US
Am I correct in assuming that the special numeric datatype<br>'UniqueIdentifier' (16 bytes) is dynamically generated<br>upon an INSERT statement? If so, how do I define it in<br>the table and what is the correct format for the INSERT?<br><br>---the book I have just gives the specs for this<br>datatype - but no examples---
 
You set the IDENTITY attribute for the column in the table definition.<br><br>You ignore the column in INSERT statements and the database fills the value automatically.<br><br>Hope this helps<br>-pete
 
Thanks. The 'IDENTITY&quot; column wasn't the one to check,<br>but it got me to looking in the right direction.<br>It is the 'IS ROWGUIDE' column that needs to be checked.<br>(Some times I just need a bump in the right direction)<br>Thanks again.&nbsp;&nbsp;&nbsp;&nbsp;Bill
 
On the original question, I think you might need to use the NEWID() function to get the GUID value.<br><br>As you've already discovered, GUIDs are different from Identity columns, which are usually simply incremental integers.&nbsp;&nbsp;GUIDs, on the other hand, are supposed to be unique throughout the mapped universe. <p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br>
 
Right again, Robert. Since I posted the original question,<br>the author of the book &quot;Professional SQL Server 7.0<br>Programming&quot; wrote me:<br><br>CREATE TABLE Test2<br>(<br>&nbsp;&nbsp;&nbsp;&nbsp;MyID&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;IDENTITY&nbsp;&nbsp;&nbsp;&nbsp;PRIMARY KEY,<br>&nbsp;&nbsp;&nbsp;&nbsp;MyGUID&nbsp;&nbsp;&nbsp;&nbsp;uniqueidentifier<br>)<br><br>INSERT INTO Test2<br>&nbsp;&nbsp;&nbsp;&nbsp;VALUES<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(newid())<br><br>Thanks for the help.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top