Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2004, 07:33 AM
Registered User
 
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Remove Leading and Trailing Zeros

Does anyone know of an efficient way to remove leading and trailing zeros from a numeric string?
 
Old January 30th, 2004, 06:49 AM
Authorized User
 
Join Date: Jan 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ankur_vachhani
Default

    first find at which pos 0 starts by 'Charat' function
    and then use
            LTRIM and RTRIM funcitons to supress zeros

          Hope this may help
 
Old February 4th, 2004, 12:10 PM
Authorized User
 
Join Date: Jun 2003
Posts: 77
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is the best i could come up with:

Code:
declare @str nvarchar(10)

set @str = '001012300'

select replace(ltrim(rtrim(replace(@str, '0', ' '))), ' ', '0')
defiant.
 
Old April 1st, 2008, 08:23 AM
Authorized User
 
Join Date: May 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to shaileshk Send a message via Yahoo to shaileshk
Default

Hi
Please do visit on below article for the remove all zero from the string
http://codegroups.com/blog/index.php...-the-starting/



shailesh kavathiya





Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I keep leading and trailing whitespaces? 2BOrNot2B XSLT 2 October 31st, 2008 11:35 AM
Removing leading zeros from a string value vikkiefd XSLT 2 June 12th, 2008 03:30 AM
SQL - removing trailing zeros skywalker1981 SQL Server 2000 4 April 1st, 2008 08:32 AM
Remove the trailing whitespace ksskumar XSLT 1 October 13th, 2006 06:23 AM
Printing leading and trailing blank spaces chakravarthy_vr Reporting Services 0 May 5th, 2006 01:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.