| Author |
Topic  |
|
|
teamjai
Starting Member
India
33 Posts |
Posted - 01/16/2013 : 02:39:36
|
i have problem in insert the data , here this is my table
PhaseList Table:
Name PhaseListID - Primary key
MainPhase table:
Name PhaseID - Primary key PhaseListID - Foreign key (PhaseList)
SubPhase table:
Subname Subid - Primary key Phaseid - Foreign key (MainPhase)
Query
Insert Into dbo.PhaseList_C Select Name,Replace(CONVERT(varchar(255), NewID()),'-','') where camosGUID = @PhaseListGuid
Insert 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
Flowing Fount of Yak Knowledge
1515 Posts |
Posted - 01/16/2013 : 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 |
 |
|
| |
Topic  |
|
|
|