From: Mukul Jain on 25 May 2010 09:48 Hi, We have three fields in a table with primary and foreign key relationship. Field1 data type 'nvarchar' Field2 data type 'Int' and Field3 data type is 'Int' Now I am trying to move a field from different table where the data type for that field is UniqueIdentifier. I am not able to do this. Please help how can i move the UniqueIdentifier data type field into 'Int'. Thanks in Advanced. Mukul
From: John Bell on 25 May 2010 09:58 On Tue, 25 May 2010 06:48:01 -0700, Mukul Jain <MukulJain(a)discussions.microsoft.com> wrote: >Hi, > >We have three fields in a table with primary and foreign key relationship. >Field1 data type 'nvarchar' >Field2 data type 'Int' and Field3 data type is 'Int' >Now I am trying to move a field from different table where the data type for >that field is UniqueIdentifier. >I am not able to do this. Please help how can i move the UniqueIdentifier >data type field into 'Int'. > >Thanks in Advanced. >Mukul Hi Mukul Why would you want to convert a uniqueidentifier which is a GUID e.g. FFFFFFFF-31BB-4D83-8B3C-3878EB6E0D22 to an integer? John
From: Gert-Jan Strik on 25 May 2010 12:56 Mukul Jain wrote: > > Hi, > > We have three fields in a table with primary and foreign key relationship. > Field1 data type 'nvarchar' > Field2 data type 'Int' and Field3 data type is 'Int' > Now I am trying to move a field from different table where the data type for > that field is UniqueIdentifier. > I am not able to do this. Please help how can i move the UniqueIdentifier > data type field into 'Int'. > > Thanks in Advanced. > Mukul Mukul, Internally, a uniqueidentifier requires 16 bytes of storage. An int only 4. You cannot convert a uniqueidentifier to an int (without significant loss of precision). If this is a one time only conversion, you could test if CHECKSUM(my_nvarchar) results in a unique int value for each uniqueidentifier and go with that. Otherwise, you will have to map each each individual uniqueidentifier ("map" them). -- Gert-Jan
|
Pages: 1 Prev: Locking Diagnostics Next: Receiving from Service Broker Queue |