Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am inserting values in a table directly without writing the query for create table.
The columns I am using are Id(uniqueidentifier,primarykey),Name(varchar).Now I can insert the Name values directly but how can the GUID can automatically generated when I move from one row to other row?Because when I dont insert anything thinking it would be generated and moving on to next row it is giving error :Column values cannot be null.How to fix it?

Thanks,..
Posted
Comments
Ankur\m/ 11-Sep-12 2:57am    
using uniqueidentifier as a primary key isn't considered a very good option from performance point of view. Moreover SQL Server would create a default clustered index on primary key which in this case can be a disaster as it causes high fragmentation. Review your design!

In the table designer, add "newid()" as "Default Value or Binding" for that column.
 
Share this answer
 
Comments
cutie1 11-Sep-12 3:04am    
Thank u .But when I add like this the rows are jumbled.They are not in the order like the ones Iam inserting.How can I get in the order in which I insert?
Bernhard Hiller 11-Sep-12 3:53am    
Guids are not generated in ascending order!
cutie1 11-Sep-12 3:56am    
k .Thank u
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900