Guest User

Untitled

a guest
Jan 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. ALTER PROCEDURE [dbo].[GetFirstIdInGapprint]
  2. (@tableName varchar(50),
  3. @column varchar(50), @prefix varchar(1) )
  4. AS
  5. IF @tableName IS NOT NULL and @column IS NOT NULL
  6. BEGIN
  7.  
  8. exec ('declare @result int select @result = min(AccountTemplate) from Management_Information..AccountTemplate
  9. left join (select cast (dbo.udf_GetNumeric ('+ @column + ') as int) as dimcode from ' + @tableName +' where cucode like ''' + @prefix + '%'') sl on dimcode = AccountTemplate
  10. where dimcode is null
  11. and ReservedDate < dateadd ( mi, -10, getdate())
  12.  
  13.  
  14. update Management_Information..AccountTemplate
  15. set RESERVEDDATE = getdate()
  16. where AccountTemplate = @result
  17.  
  18. SELECT @result AS CUCODE');
Add Comment
Please, Sign In to add comment