SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

teamjai
Starting Member

India
42 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:

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

3549 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  
 New 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.03 seconds. Powered By: Snitz Forums 2000