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 2008 Forums
 Transact-SQL (2008)
 Query Help

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2012-07-02 : 16:58:32
how to get the desired results from the following ip

TableA

Ip
-------------------------------
5.46.200.1.462222.2.1.2.3.4.5.1
5.46.200.1.462222.2.1.2.3.4.5

Expected output:

Ip
-------------------------------
5.46.200.1.462222.2.1.2.3.4.5
5.46.200.1.462222.2.1.2.3.4

thanks for your help in advance

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-07-02 : 17:05:32
What is your business requirement? Just chop off the last 2 characters?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2012-07-02 : 17:21:27
Yes ..exclude the last 2 characters.
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2012-07-02 : 17:24:37
declare @whyalwaysme table(id varchar(max))
insert @whyalwaysme
select '5.46.200.1.462222.2.1.2.3.4.5.1'
union
select '5.46.200.1.462222.2.1.2.3.4.5'

select left(id, len(id) -2) from @whyalwaysme

<><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2012-07-02 : 17:31:14
Thanks a lot it works..
Go to Top of Page
   

- Advertisement -