dbTalk Databases Forums  

Default value of a GUID field?!

microsoft.public.sqlserver.clients microsoft.public.sqlserver.clients


Discuss Default value of a GUID field?! in the microsoft.public.sqlserver.clients forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Allan Bentsen
 
Posts: n/a

Default RE: Default value of a GUID field?! - 10-26-2006 , 05:16 AM






Hı Leon

Have you consıdered to create the guid from code and then insert it into the
table, in stead of letting the sql server generate it for you ?. Otherwise it
is possible to query the table for the inserted row, and reading the guid.
(if the guid isn't the primary key)

Hope this helps.

--
TIA
/Allan


"Leon_Amirreza" wrote:

Quote:
I have a column named "ID" and its type is "uniqueidentifier" in SQL Server
2005 Express.
this column is the primary key and its default value is "newid()" in SQL
Server.

I have generated a DataSet in C# that has this column but its default value
is DBNull what can I do to make the default value be the return value of
this function ( or I want the Id be generated by default in the DataSet)?

System.Guid.NewGuid()





Reply With Quote
  #2  
Old   
Leon_Amirreza
 
Posts: n/a

Default Default value of a GUID field?! - 10-27-2006 , 01:00 AM






I have a column named "ID" and its type is "uniqueidentifier" in SQL Server
2005 Express.
this column is the primary key and its default value is "newid()" in SQL
Server.

I have generated a DataSet in C# that has this column but its default value
is DBNull what can I do to make the default value be the return value of
this function ( or I want the Id be generated by default in the DataSet)?

System.Guid.NewGuid()




Reply With Quote
  #3  
Old   
Arnie Rowland
 
Posts: n/a

Default Re: Default value of a GUID field?! - 10-29-2006 , 09:29 AM



Ouch!! That's not a good idea.

GUID -Identity and Primary Keys
http://sqlteam.com/item.asp?ItemID=2599

GUID -Is not Always GOOD
http://bloggingabout.net/blogs/welli...03/15/598.aspx

GUID -The Cost of GUIDs as Primary Keys
http://www.informit.com/articles/art...p?p=25862&rl=1

GUID -Uniqueidentifier vs. IDENTITY
http://sqlteam.com/item.asp?ItemID=283


--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf


"Leon_Amirreza" <amirreza_rahmaty (AT) yahoo (DOT) com> wrote

Quote:
becuase I am using offline Typed DataSets and the GUID field is the
Primary Key of the table

"Leon_Amirreza" <amirreza_rahmaty (AT) yahoo (DOT) com> wrote in message
news:uhK4HNz%23GHA.4472 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
Thanks but this gets very tricky

and sorry for the clock problem

"Allan Bentsen" <Allan.Bentsen (AT) discussions (DOT) microsoft.com> wrote in
message news:6FDCD5BC-DC5F-4FC9-A4E4-D23E855F651F (AT) microsoft (DOT) com...
H? Leon

Have you cons?dered to create the guid from code and then insert it into
the
table, in stead of letting the sql server generate it for you ?.
Otherwise it
is possible to query the table for the inserted row, and reading the
guid.
(if the guid isn't the primary key)

Hope this helps.

--
TIA
/Allan


"Leon_Amirreza" wrote:

I have a column named "ID" and its type is "uniqueidentifier" in SQL
Server
2005 Express.
this column is the primary key and its default value is "newid()" in
SQL
Server.

I have generated a DataSet in C# that has this column but its default
value
is DBNull what can I do to make the default value be the return value
of
this function ( or I want the Id be generated by default in the
DataSet)?

System.Guid.NewGuid()











Reply With Quote
  #4  
Old   
Leon_Amirreza
 
Posts: n/a

Default Re: Default value of a GUID field?! - 10-30-2006 , 02:24 AM



Thanks but this gets very tricky

and sorry for the clock problem

"Allan Bentsen" <Allan.Bentsen (AT) discussions (DOT) microsoft.com> wrote

Quote:
H? Leon

Have you cons?dered to create the guid from code and then insert it into
the
table, in stead of letting the sql server generate it for you ?. Otherwise
it
is possible to query the table for the inserted row, and reading the guid.
(if the guid isn't the primary key)

Hope this helps.

--
TIA
/Allan


"Leon_Amirreza" wrote:

I have a column named "ID" and its type is "uniqueidentifier" in SQL
Server
2005 Express.
this column is the primary key and its default value is "newid()" in SQL
Server.

I have generated a DataSet in C# that has this column but its default
value
is DBNull what can I do to make the default value be the return value of
this function ( or I want the Id be generated by default in the DataSet)?

System.Guid.NewGuid()







Reply With Quote
  #5  
Old   
Leon_Amirreza
 
Posts: n/a

Default Re: Default value of a GUID field?! - 10-30-2006 , 02:27 AM



becuase I am using offline Typed DataSets and the GUID field is the Primary
Key of the table

"Leon_Amirreza" <amirreza_rahmaty (AT) yahoo (DOT) com> wrote

Quote:
Thanks but this gets very tricky

and sorry for the clock problem

"Allan Bentsen" <Allan.Bentsen (AT) discussions (DOT) microsoft.com> wrote in message
news:6FDCD5BC-DC5F-4FC9-A4E4-D23E855F651F (AT) microsoft (DOT) com...
H? Leon

Have you cons?dered to create the guid from code and then insert it into
the
table, in stead of letting the sql server generate it for you ?.
Otherwise it
is possible to query the table for the inserted row, and reading the
guid.
(if the guid isn't the primary key)

Hope this helps.

--
TIA
/Allan


"Leon_Amirreza" wrote:

I have a column named "ID" and its type is "uniqueidentifier" in SQL
Server
2005 Express.
this column is the primary key and its default value is "newid()" in SQL
Server.

I have generated a DataSet in C# that has this column but its default
value
is DBNull what can I do to make the default value be the return value of
this function ( or I want the Id be generated by default in the
DataSet)?

System.Guid.NewGuid()









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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.