hecrus

fm_human_getItem

Oct 10th, 2020
886
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE PROCEDURE [dbo].[fm_human_getItem]
  2.     @itemID int,   
  3.     @username nvarchar(256)
  4. AS
  5. BEGIN
  6.     if (@itemID>0) begin
  7.         select fio, depID, phone, freelancer,
  8.         'Руководитель: '+ isnull((select top 1 fio from hr_humans
  9.                            where id in (select managerID from hr_departments where id = h.depID )), '<i>Нет руководителя</i>' ) info
  10.         from hr_humans h
  11.         where h.id = @itemID
  12.  
  13.         select (select fio from hr_humans h where h.id = @itemID) as Title, '' Subtitle
  14.         from hr_humans h where h.id = @itemID
  15.  
  16.     end else begin
  17.         select null
  18.         select '' as Title, '' Subtitle
  19.     end
  20. END
RAW Paste Data