[Release] T-SQL Fill GM warehouse with BOK+5 with Unique Serial

Life

Well-Known Member
Joined
Nov 13, 2008
Messages
1,367
Reaction score
509
This is a T-SQL script to fill GM warehouse with BOK+5 with unique serials.

HOW: Add an SQL Agent Job and paste this code there. Don't forget to adjust the schedule to your liking. Not much to say. :blush:

If you can enhance it and feel like posting an update please do.

Code:
DECLARE @gm varchar(255), @pos int, @gmID varchar(255), @i int, @bok nvarchar(4000), @UpdateGMVault nvarchar(4000)

SET @gm = 'nukerz,blasters,duperz,hackerz,scammers'

SET @pos = 0

if right(rtrim(@gm),1) <> ','
  set @gm = @gm  + ','

set @pos = patindex('%,%' , @gm)

while @pos <> 0 
begin
	set @gmID = left(@gm, @pos-1)
	
	SET @bok = '0x'
	SET @i = 1

	while (@i < 121 )
	
	BEGIN
		-- BOK + 5 (box of luck +12)
		SET @bok = @bok + 'CB6000' + LEFT(newid(),8) + '800000'
		SET @i = @i + 1
	END

	SET @UpdateGMVault = 'update warehouse set items = ' + @bok + ' where AccountID = ''' + @gmID + ''''

	EXEC(@UpdateGMVault)

	set @gm = stuff(@gm, 1, @pos, '')
	set @pos = patindex('%,%' , @gm)
end

If you have no SQL Server Agent, you can still use this code and save it as Stored Procedure then call this code via Task Scheduler in Windows using a php script.

I hope it will help a lot.
 
  • Like
Reactions: GTI
build a module would be good to see inventory and trunk show.
 
suck my pen*s oligofren ;)