Use MERGE
MERGE INTO Delegates D
USING (values(@MemNo, @FromYr,@ToYr)) X ([MemNo],[FromYr],[ToYr])
ON (insert unique key join)
WHEN NOT MATCHED BY TARGET THEN
INSERT ([MemNo],[FromYr],[ToYr]))
VALUES (X.[MemNo],X.[FromYr],X.[ToYr]);
More Related Contents:
- I dont know sql syntax for my table [closed]
- Unable to Subtract Dates SQL Server
- Insert local .csv data in remote SQL Server via already working connection string
- Syntax combine two stored procedure into one [closed]
- How to delete duplicate rows in SQL Server?
- CROSS JOIN vs INNER JOIN in SQL
- How to cast the DateTime to Time
- How can I schedule a job to run a SQL query daily?
- Reset identity seed after deleting records in SQL Server
- How to avoid the “divide by zero” error in SQL?
- Multiple INSERT statements vs. single INSERT with multiple VALUES
- Real life example, when to use OUTER / CROSS APPLY in SQL
- Common Table Expression, why semicolon?
- T-SQL split string based on delimiter
- SQL Server 2008: how do I grant privileges to a username?
- How do I find duplicates across multiple columns?
- Select a Column in SQL not in Group By
- Split values over multiple rows [duplicate]
- How to do an inner join on row number in sql server
- How can I alter this computed column in SQL Server 2008?
- How to get the size of a varchar[n] field in one SQL statement?
- Stored procedure that exports data into csv files only exports to one file
- SQL Server: should I use information_schema tables over sys tables?
- TSQL – How to use GO inside of a BEGIN .. END block?
- SQL take just the numeric values from a varchar
- Cumulative Total in MS Sql server [duplicate]
- How to write a WHERE Clause to find all records in a specific month?
- How to make a view column NOT NULL
- Flattening of a 1 row table into a key-value pair table
- SQL Server equivalent of WM_CONCAT function [duplicate]