StrataFrame Forum

GUID as foreign key

http://forum.strataframe.net/Topic6561.aspx

By Chan - 2/3/2007

Hi,

I am using GUID as PK in master table. I have another table which is 1-many relationship. When I save my child table, it hit error as below. Any ideas?



I have set mastertable.PK and childtable.FK as GUID in BO mapper.



Please advice.





--Conversion failed when converting from a character string to uniqueidentifier.



exec sp_executesql N'INSERT INTO [dbo].[Books] ([ItemID], [PublisherID], [LanguageID], [PaperTypeID]) VALUES (@ItemID, @PublisherID, @LanguageID, @PaperTypeID);

',N'@ItemID uniqueidentifier,@PublisherID uniqueidentifier,@LanguageID int,@PaperTypeID

int',@ItemID='264FA570-8942-4FD2-BF3D-590D9F7C2464',@PublisherID='494AE887-A731-42A9-8890-10AA147FAECD',@LanguageID=0,@PaperTypeID=0
By StrataFrame Team - 2/6/2007

I'm not sure about the conversion from NChar types to UIDs, you will most likely have to use either a CAST or a CONVERT to change the string to a GUID.  You'll need to check the SQL Server Books Online for the version of SQL Server you're using to see how to convert the string to a GUID.