Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to concatenate a value to a prexisting value during an update

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-05-11 : 09:04:07
chris writes "I'm Stumped....
I'd like to tack on '00' to the beginning of all of the varchar series numbers in a column. I've tried several variations of the following stored procedure and keep getting an update of 0 for the entire column.

CREATE PROCEDURE [SERIES_NO_FIX] AS

DECLARE @old_no varchar(8)
DECLARE @pre_fix varchar(2)
DECLARE @size int
DECLARE @hold varchar(8)

set @pre_fix = '00'

DECLARE cr_Series CURSOR For SELECT series_no From test_number

OPEN cr_Series

While (0 = 0)
BEGIN
FETCH NEXT FROM cr_Series INTO @old_no
IF (@@Fetch_Status <> 0) BREAK

UPDATE test_number SET series_no = str(@pre_fix) + str(@old_no)



END

CLOSE cr_Series
DEALLOCATE cr_Series


Not sure why the column updates to 0 instead of 00number.

Thanks in advance

Chris"
   

- Advertisement -