Following is new data type that I created.
CREATE TYPE [dbo].[UpdateHotelTableType] AS TABLE(
[ID] [int] NULL,
[HotelID] [int] NULL,
[FromDate] [date
You can Simply do 2 Queries: 1. "Update" command 2. "Insert" command.
ALTER PROCEDURE [dbo].[SP_Hotel_Info_Update]
-- Add the parameters for the stored procedure here
@XHotelInfoDetails UpdateHotelTableType READONLY,
AS
BEGIN
UPDATE dbo.HotelInfo
SET FromDate = r.FromDate,
FROM dbo.HotelInfo
JOIN @XHotelInfoDetails X ON X.Id = HotelInfo.Id
INSERT INTO dbo.HotelInfo (Col1,Col2)
SELECT X.Col1,
X.Col2
FROM @XHotelInfoDetails X
WHERE NOT EXISTS
(
SELECT 1
FROM dbo.HotelInfo InnerTable
WHERE X.Id = InnerTable.Id
)
END