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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Split
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 10/29/2010 :  07:48:55  Show Profile  Reply with Quote
hi,

i have a column name as "Helpdeskid" and value as

Helpdeskid

HD-001
HD-002
HD-003
---
HD-1000
HD-1000000
HD-10000000
--------------

i just waantto split and reslut must be
1
2
3
4
5
6
...
1000
100000
1000000
100000000
pl help me..

notmyrealname
Yak Posting Veteran

98 Posts

Posted - 10/29/2010 :  08:07:19  Show Profile  Reply with Quote
CAST(SUBSTRING([Helpdeskid], CHARINDEX('-', [Helpdeskid]) + 1, LEN([Helpdeskid])) AS int)

Search help for SQL String Functions. You will find lots of useful functions that help with this kind of stuff.

Edited by - notmyrealname on 10/29/2010 08:08:50
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8781 Posts

Posted - 10/29/2010 :  08:11:50  Show Profile  Visit webfred's Homepage  Reply with Quote
select convert(int,replace(Helpdeskid,'HD-',''))


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

India
843 Posts

Posted - 10/29/2010 :  08:29:00  Show Profile  Reply with Quote
select convert(int,RIGHT(helpdeskid, LEN(helpdeskid) - 3))

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page

notmyrealname
Yak Posting Veteran

98 Posts

Posted - 10/29/2010 :  08:30:51  Show Profile  Reply with Quote
quote:
Originally posted by webfred

select convert(int,replace(Helpdeskid,'HD-',''))


No, you're never too old to Yak'n'Roll if you're too young to die.



Why didn't i think of that! Nice!
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22864 Posts

Posted - 11/01/2010 :  07:28:20  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
or

select parsename(replace(Helpdeskid ,'-','.'),1)*1 from table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000