Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ALTER PROCEDURE [dbo].[GetFirstIdInGapprint]
- (@tableName varchar(50),
- @column varchar(50), @prefix varchar(1) )
- AS
- IF @tableName IS NOT NULL and @column IS NOT NULL
- BEGIN
- exec ('declare @result int select @result = min(AccountTemplate) from Management_Information..AccountTemplate
- left join (select cast (dbo.udf_GetNumeric ('+ @column + ') as int) as dimcode from ' + @tableName +' where cucode like ''' + @prefix + '%'') sl on dimcode = AccountTemplate
- where dimcode is null
- and ReservedDate < dateadd ( mi, -10, getdate())
- update Management_Information..AccountTemplate
- set RESERVEDDATE = getdate()
- where AccountTemplate = @result
- SELECT @result AS CUCODE');
Add Comment
Please, Sign In to add comment