Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
teamjai
Yak Posting Veteran
52 Posts |
Posted - 2013-01-16 : 02:39:36
|
i have problem in insert the data , here this is my tablePhaseList Table:Name PhaseListID - Primary keyMainPhase table:NamePhaseID - Primary keyPhaseListID - Foreign key (PhaseList)SubPhase table:SubnameSubid - Primary keyPhaseid - Foreign key (MainPhase)QueryInsert Into dbo.PhaseList_C Select Name,Replace(CONVERT(varchar(255), NewID()),'-','') where camosGUID = @PhaseListGuidInsert Into dbo.MainPhase_C Select Name,Replace(CONVERT(varchar(255), NewID()),'-',''),Replace(CONVERT(varchar(255), NewID()),'-','')where PhaseListID = @PhaseListGuid (From PhaseList table)Insert Into dbo.SubPhase_C Select Name,Replace(CONVERT(varchar(255), NewID()),'-',''),Replace(CONVERT(varchar(255), NewID()),'-','')where PhaseListID = @PhaseListGuid(from MainPhase table) I am trying to insert data into a table, but Subphase table data is missing .Can somebody help ? |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-01-16 : 06:43:29
|
There seems to be something not quite right with the example you have provided. None of the tables have a column named camosGUID, yet you are using that in the where clause in the first query. Also, when you use NEWID each time, it creates a new GUID. So the way you have written the query, the GUID inserted into the first table would not be the one that gets inserted into the second and so on.Rather than storing the GUID as a string, it is better to store it as a UNIQUEIDENTIER |
|
|
|
|
|
|
|