Amudhan Kuppan

Amudhan Kuppan

  • NA
  • 378
  • 29.9k

Stored Procedure

Mar 23 2018 5:56 AM
hi
anyone clear my doubt
i will send one SP please check
My question is that query ID is an identity column
if ID is an identity column are how to find out?
my idea is go to table and right click of the table click design and click identity specification so now iam see ID part increment column is set to yes or not correct?
this is my idea
my colleague say please check script and tell me how to find ID is an identity column in see the script.......
  1. use master  
  2. go  
  3. CREATE PROCEDURE dbo.MergeDataType  
  4. @ID int = NOTNULL,  
  5. @Name nvarchar(255),  
  6. @Address nvarchar(255)  
  7. AS  
  8. BEGIN  
  9. SET NOCOUNT ON;  
  10. WITH [source](ID, Name, [Address]) AS  
  11. (  
  12. SELECT @ID, @Name, @Address  
  13. )  
  14. MERGE dbo.student AS T  
  15. USING dbo.student as S ON T.ID = S.ID  
  16. WHEN MATCHED THEN  
  17. UPDATE SET T.Name = @Name,  
  18. T.Address = @Address  
  19. WHEN NOT MATCHED THEN  
  20. INSERT (Name, Address)  
  21. VALUES (@Name, @Address);  
  22. END  
  23. GO  

Answers (2)