Groups | Blog | Home
all groups > sql server programming > february 2004 >

sql server programming : Key Generation



Satya Rao
2/8/2004 10:29:59 PM
hai,

declare @askey char(16)
declare @asno varchar(6)
declare @asalfa varchar(10)
set @asno = '2569'
1. ) set @asalfa = ''
2. ) -- set @asalfa = 'a'

--set @askey = replicate(' ', 6 - len(@asno)) + @asno + replicate(' ', 10 -
len(@asalfa)) + @asalfa

-- print len(@askey)

I want to generate the 16 length key with above script . It is working file
with 2.) but not with 1.) i.e @asalfa = ''

Help me




Roji. P. Thomas
2/9/2004 12:13:24 PM
What you mean by Not working?
I tried it and it is working.

the Len() returns 6 because your datatype is varchar
and you are replicating with spaces.

Try printing Len(@askey + 'Z')
it will return 17

If your key is fixed 16 char then change the datatype as char.


HTH
Roji



[quoted text, click to view]

AddThis Social Bookmark Button