Below is the new data type that I created.
CREATE TYPE [dbo].[UpdateHotelTableType] AS TABLE(
[ID] [int] NULL,
[HotelID] [int] NULL,
[FromDate] [datetime] NULL,
)
Below is my stored procedure in which I used the above data type.
ALTER PROCEDURE [dbo].[SP_Hotel_Info_Update]
@XHotelInfoDetails UpdateHotelTableType READONLY,
AS
BEGIN
Update dbo.HotelInfo
SET
FromDate = r.FromDate,
from @XHotelInfoDetails r
Where HotelInfo.ID = r.ID
END
This works great for update results in a database. But I want to check if id exists, and if id does not exist, insert a row into the table. otherwise update the current record. Here I submit a list of data to update.
Can someone help me recreate the stored procedure to insert data by checking for an identifier.
source
share