Wrox Programmer Forums
|
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 February 27th, 2006, 12:03 PM
Registered User
 
Join Date: Dec 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default rtrim or substring? Help

Ok this is what my data looks like:

Zx002*111
Z04*2222
Y7*33

This is what I need my result to look like:

111
2222
33


 
Old February 27th, 2006, 01:00 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

declare @number varchar(20), @totlen integer, @theIndex integer, @FinalValue as varchar(10)

Set @number = '3333*94449'
Set @totlen = Len(@number)
Set @theIndex = CHARINDEX('*',@number)
Set @FinalValue = Right(@number, @totlen - @theIndex)

Select @number as 'The Value', @totlen as 'Total Length', @theIndex as 'The Index', @FinalValue as 'Final Value'

Hope this helps.



 
Old March 1st, 2006, 12:50 PM
Registered User
 
Join Date: Dec 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

:)
Thanks Rstelma, you solved my problem.

 
Old March 1st, 2006, 01:05 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

My pleasure. Glad I could help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
substring in c# sudhirbharti C# 1 February 21st, 2008 01:29 PM
substring-before() function. lafilip XSLT 1 July 11th, 2007 05:33 PM
Substring-after collation bonekrusher XSLT 2 May 11th, 2007 09:31 AM
SubString prasanta2expert Access VBA 1 November 17th, 2006 10:04 AM
rtrim, ltrim and len khronikles Pro VB Databases 1 June 5th, 2006 03:31 PM





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