Hi,

Made a stored procedure to edit a field in table and having a problem doing it exactly what I want to do.

Here's the stored procedure I've made:
PHP Code:
CREATE proc sp_deposit @accountName varchar(60),@itemData char(12)
as declare @
sql char(7000),@hexbin varchar(4600),@moneybit char(24)

set @hexbin=(select dbo.fn_hexstring(blobITEMS,1from SHO..tblGS_BANK where txtACCOUNT=@accountName)
set @moneybit=reverse(substring(reverse(@hexbin),1,24))
set @moneybit=substring(reverse(@hexbin),1,24)
set @sql='UPDATE tblGS_BANK SET blobITEMS=(SELECT CONVERT(BINARY(2250),(SELECT STUFF((SELECT TOP 1 blobITEMS FROM tblGS_BANK WHERE txtACCOUNT='''+@accountName+'''),1,0,0x'+@itemData+'0000000000000000)))) WHERE txtACCOUNT='''+@accountName+''''

exec sp_sqlexec @sql

set 
@hexbin=(select dbo.fn_hexstring(blobITEMS,1from tblGS_BANK where txtACCOUNT=@accountName)
set @hexbin=(select reverse(STUFF(reverse(@hexbin),1,24,@moneybit)))
set @hexbin=(select STUFF(@hexbin,3,12,@itemData) )
set @sql='UPDATE tblGS_BANK SET blobITEMS='+@hexbin+' WHERE txtACCOUNT='''+@accountName+''''

exec sp_sqlexec @sql

GO 
What this basically does is inserts the new @itemData into the tblGS_BANK table at the very start, keeping the data already in there intact.

What I want it to do, ideally, is insert the @itemData at a specific place and keeping the data already in there intact. I want to do this at the 3361'th bit (there's 4500 in total).

set @hexbin=(select STUFF(@hexbin,3,12,@itemData) )

I've tried editing this from STUFF(@hexbin,3,12,@itemData) to STUFF(@hexbin,3363,12,@itemData), but it inserted @itemData at the START and at the 3363'th bit (whereas I only want it at the 3363'th bit).

Is there some tweaking I could do to this? Or is there a simpler method? Alls I basically want to do is insert new @itemData into the 3363'th bit.

(@itemData is always 12 bits)

Thanks ._.