Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Problem in Copy -paste
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

52 Posts

Posted - 01/16/2013 :  02:39:36  Show Profile  Reply with Quote
i have problem in insert the data , here this is my table

PhaseList Table:

PhaseListID - Primary key

MainPhase table:

PhaseID - Primary key
PhaseListID - Foreign key (PhaseList)

SubPhase table:

Subid - Primary key
Phaseid - Foreign key (MainPhase)


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

3873 Posts

Posted - 01/16/2013 :  06:43:29  Show Profile  Reply with Quote
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000