-- This script accepts a user's input for @cServerFileName, -- @cLocalFilePath, @cMKDirLocal, to update the softwareupdate table. -- This script mocks the array which does not exist in T-SQL to allow -- multiple update or insert. -- This is made possible by a mocked array and a while loop DECLARE @nDownloadOrder as int, @cFileName varchar(50), @cLocalFilePath varchar(50), @cMKDirLocal varchar(50), @aryFileNames varchar(200), @iLength int, @iStart int, @iEnd int, @iNumOfItem int -- Begin: User should not touch the following -- SET @iStart = 1 SET @nDownloadOrder = 1 SET @aryFileNames = ',' SET @iNumOfItem = 0 -- End: User should not touch the following -- -- Begin: User must define the following ---- SET @cLocalFilePath = '\' SET @cMKDirLocal = '' -- Begin: Set File -- SET @cServerFileName = 'file1.dll' -- Begin: User should not change the following ---- SET @aryServerFileNames = @aryServerFileNames + @cServerFileName + ',' SET @iNumOfItem = @iNumOfItem + 1 -- End: User should not change the following ---- -- End: Set File -- -- Begin: Set File -- SET @cServerFileName = 'file2.xml' -- Begin: User should not change the following ---- SET @aryServerFileNames = @aryServerFileNames + @cServerFileName + ',' SET @iNumOfItem = @iNumOfItem + 1 -- End: User should not change the following ---- -- End: Set File -- -- Begin: Set File -- SET @cServerFileName = 'file3.exe' -- Begin: User should not change the following ---- SET @aryServerFileNames = @aryServerFileNames + @cServerFileName + ',' SET @iNumOfItem = @iNumOfItem + 1 -- End: User should not change the following ---- -- End: Set File -- -- End: User must define the following ---- WHILE @nDownloadOrder <= @iNumOfItem BEGIN SET @iStart = (SELECT CHARINDEX( ',', @aryFileNames, @iStart ) ) + 1 SET @iEnd = (SELECT CHARINDEX( ',', @aryFileNames, @iStart ) ) SET @iLength = @iEnd - @iStart SET @cFileName = SUBSTRING(@aryFileNames, @iStart, @iLength) -- The following updates the <Table> -- UpdateTable @nDownloadOrder, @cFileName, @cLocalFilePath, @cMKDirLocal SET @nDownloadOrder = @nDownloadOrder + 1 END********