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

Results 1 to 3 of 3
  1. #1
    127.0.0.1 goldenfox is offline
    MemberRank
    Jan 2007 Join Date
    202Posts

    idea T-SQL Fill GM warehouse with BOK+5 with Unique Serial

    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.

    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.


  2. #2

    Re: T-SQL Fill GM warehouse with BOK+5 with Unique Serial

    Approved it is.

  3. #3
    Enthusiast deivisszz is offline
    MemberRank
    May 2007 Join Date
    26Posts

    Re: T-SQL Fill GM warehouse with BOK+5 with Unique Serial

    Thankyou



Advertisement