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
 General SQL Server Forums
 New to SQL Server Programming
 Right 10 digits from column

Author  Topic 

kiddofatso
Starting Member

5 Posts

Posted - 2014-10-07 : 10:44:09
Hi All.....following function in not giving me correct output:

update dbo.raw
set PhnNumber = RIGHT(calling_pty,10)





What I want is....if in case column "calling_pty" i have values like 911111111111 so it should give me the output in column "PhnNumber" as 1111111111 means only right 10

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-10-07 : 11:54:25
That's what it's doing already. Here's a quick test given the info you provided:

declare @s varchar(20)

set @s = '911111111111'

select right(@s, 10)

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

kiddofatso
Starting Member

5 Posts

Posted - 2014-10-08 : 04:17:49
i mean to say there are so many calling numbers with their respective states codes so what i want here is that i will get only right 10 digits of mobile number as an output in my column "PhnNumber" from "Calling_Pty" column
quote:
Originally posted by tkizer

That's what it's doing already. Here's a quick test given the info you provided:

declare @s varchar(20)

set @s = '911111111111'

select right(@s, 10)

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-10-08 : 12:35:01
That's what your code is doing already. Please show us sample data and expected output if there is a data issue.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -