Tuesday

ms sql split string into columns

here is excellent example how to split string into columns in TSQL (microsoft SQL server)
  
Declare @products varchar(200) = 'one::two::tree'
Declare @individual varchar(20) = null
declare @res table(ident int identity(1,1),val varchar(20))


WHILE LEN(@products) > 0
BEGIN
IF PATINDEX('%::%',@products) > 0
BEGIN
SET @individual = SUBSTRING(@products, 0, PATINDEX('%::%',@products))
Insert into @res (val) values (@individual)
SET @products = SUBSTRING(@products, LEN(@individual + ';;') + 1,
LEN(@products))
END
ELSE
BEGIN
SET @individual = @products
SET @products = NULL
Insert into @res (val) values (@individual)
END
END

Select * from @res p
Pivot( max(p.val) for p.ident in ([1],[2],[3]) ) as PIV


.bat random number generator

here is example how to use random in bat files in simple 'guess number' game.
to call it : game.bat [total numbers to pick from] [your number]
for example : game.bat 6 3
 
set /a NUM = ( %1 * %random% ) / 32768 + 1
IF "%NUM%" EQU "%2" (echo "winner!") else (echo "loose %NUM%")


imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...