hecrus

Humans UpdateField

Oct 10th, 2020 (edited)
724
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE PROCEDURE [dbo].[crud_humans_updateField]
  2.     @itemID int,
  3.     @field nvarchar(64),
  4.     @value nvarchar(max),
  5.     @username nvarchar(64)
  6. AS
  7. BEGIN
  8. -- обновление поля таблицы
  9. -- для приведения типов используйте try_cast(@value as int), Для даты try_convert(date, @value, 104)
  10.  
  11. if(@field = 'freelancer') begin
  12.     update hr_humans set freelancer = try_cast(@value as bit) where id = @itemID   
  13. end else if(@field = 'statusID') begin
  14.     update hr_humans set statusID = try_cast(@value as int) where id = @itemID 
  15. end else begin
  16.     select 'Невалидный код свойства' Msg, 0 Result
  17.     return
  18. end  
  19. select '' Msg, 1 Result
  20.  
  21. END
  22.  
RAW Paste Data