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
 Transact-SQL (2000)
 Removing the last character in a string

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-18 : 09:53:55
Shnaek writes "I have concatenated a string with several statements like this:

if @F2 is not null set @Order = @Order + @F2 + ','

and I want to remove the trailing comma. I have tried this code and variations of it:

@Order = left(len(@Order)-1)

But I keep getting an error. I'd appreciate help as I am very new to this. Cheers,
Sean."

izaltsman
A custom title

1139 Posts

Posted - 2002-03-18 : 10:00:02
set @Order = left(@Order, len(@Order)-1)



Go to Top of Page

Nazim
A custom title

1408 Posts

Posted - 2002-03-19 : 00:25:10
you can also use Substring function
select @Order=substring(@order,1,len(@Order)-1)


--------------------------------------------------------------
Go to Top of Page
   

- Advertisement -