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
 extract last 6 of 9 digits in a column

Author  Topic 

chevyww1936
Starting Member

2 Posts

Posted - 2009-02-12 : 18:04:54
Hello, i am new to sql and i am having a hard time figuring out how i can write a select statement that will return the last 6 digits out of a column that has a character length of 9. select ss_id from id_table gives me everyones id and we need the last 6 for their passwords. Any help would be appreciated. Thanks

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-12 : 18:08:37
[code]Select RIGHT(ssid,6) from table[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-12 : 20:31:38
also SUBSTRING(ssid,4,6)
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2009-02-13 : 00:42:25
Also try this but it is not optimized but another different way to get last 6 characters

declare @str CHAR(9)
SELECT @str = '123456789'
SELECT REVERSE(LEFT(REVERSE(@str),6))
Go to Top of Page

chevyww1936
Starting Member

2 Posts

Posted - 2009-02-13 : 09:21:47
I tryed the top two reply and i got invalid identifier. I'm sorry but the 3rd reply doesn't look familiar to me. like i said i am new. I am normally the Network Specialist, and ERP Application Admin. But now i have to learn sql to administer these new applications. I am using Toad and SQL Plus against a Banner Oracle Database. and i get invalid identifier on both applications
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-13 : 09:34:43
quote:
Originally posted by raky

Also try this but it is not optimized but another different way to get last 6 characters

declare @str CHAR(9)
SELECT @str = '123456789'
SELECT REVERSE(LEFT(REVERSE(@str),6))



Why you need this? With flip-flop.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-13 : 09:35:10
quote:
Originally posted by chevyww1936

I tryed the top two reply and i got invalid identifier. I'm sorry but the 3rd reply doesn't look familiar to me. like i said i am new. I am normally the Network Specialist, and ERP Application Admin. But now i have to learn sql to administer these new applications. I am using Toad and SQL Plus against a Banner Oracle Database. and i get invalid identifier on both applications



So you are not using SQL Server?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-13 : 09:42:18
quote:
Originally posted by chevyww1936

I tryed the top two reply and i got invalid identifier. I'm sorry but the 3rd reply doesn't look familiar to me. like i said i am new. I am normally the Network Specialist, and ERP Application Admin. But now i have to learn sql to administer these new applications. I am using Toad and SQL Plus against a Banner Oracle Database. and i get invalid identifier on both applications


invalid identifier? what was exact error message?
Go to Top of Page
   

- Advertisement -