GUID as foreign key


Author
Message
Chan
Chan
Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
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

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search