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.
| Author |
Topic |
|
Rayman
Starting Member
39 Posts |
Posted - 2010-10-13 : 14:11:01
|
| I have a column with the information as follows:Table: johnColumn: database_nameDatabase_namedatabase 143database 2database 3database number 1I am trying to create a script to produce just the number in ordersuch as this example:database number 1 2 3 43My approach was to look at the string and print the interger. Do not seem to find a correct function or command to perform this feat.Any help would be appreciated. Thank you,Terry Lynn King |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-13 : 14:15:28
|
| Should it be 43 or 143 in the o/p ?PBUH |
 |
|
|
Rayman
Starting Member
39 Posts |
Posted - 2010-10-13 : 14:16:36
|
It should be 43quote: Originally posted by Sachin.Nand Should it be 43 or 143 in the o/p ?PBUH
Terry Lynn King |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-13 : 14:32:23
|
| But ur data has value 143Table: johnColumn: database_nameDatabase_namedatabase 143database 2database 3database number 1PBUH |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-10-13 : 14:34:42
|
| [code]select *, DB_Num =convert(int,reverse(substring(reverse(DB),1,charindex(' ',reverse(DB))-1)))from ( select DB = 'database 1' union all select DB = 'database 143' union all select DB = 'database 44' ) border by DB_Num[/code]Results:[code]DB DB_Num ------------ ----------- database 1 1 database 44 44 database 143 143 [/code]CODO ERGO SUM |
 |
|
|
Rayman
Starting Member
39 Posts |
Posted - 2010-10-13 : 14:53:11
|
| the desire output I am trying to produce is this:database number 1 2 3 43I am trying to look at the data and then produce the numbers in orderTerry Lynn King |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-13 : 15:36:42
|
what is the rule that makes 143 to 43?looks senseless without explanation. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|