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
 insert data from 2 tables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sanjeevka08
Starting Member

India
11 Posts

Posted - 10/11/2012 :  02:57:37  Show Profile  Reply with Quote
i am having a TVP data as input for a Stored procedure..

what i want is to insert data into another table with TVP data as one column and second column from another table that corresponds to TVP data
ALTER PROCEDURE [dbo].[RHLeaveEmployee]
@rhdays [RHHolidayID] readonly,
@empid int
AS
BEGIN
DECLARE @RHDaysList TABLE ( rhdays int,rhid int)
INSERT INTO @RHDaysList (rhdays,rhid)
SELECT RD.RHName,RH.RHID FROM @rhdays RD JOIN RHHoliday RH ON RD.ID = RH.RHID

DELETE FROM RHXrefHoliday WHERE EmployeeID=@empid

INSERT INTO RHXrefHoliday (EmployeeID,RHHoliday) SELECT @empid,RHName FROM @rhdays

END


HEre @rhdays is TVP. i want to insert into temporary table @RHdaysList with one column as data in TVP and second column taken from another table RHHoliday using condition @rhdays.id=RHHoliday.ID

sunitabeck
Flowing Fount of Yak Knowledge

5152 Posts

Posted - 10/11/2012 :  07:00:55  Show Profile  Reply with Quote
Your code seems to be consistent with your description. Is it not working as expected?
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.05 seconds. Powered By: Snitz Forums 2000