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 |
|
rvan
Starting Member
28 Posts |
Posted - 2007-01-24 : 19:42:39
|
| Hello to All,I needs help to combine these together but how would I eliminate necessarily zero in front of "PropertyHouseNumber".Table: DirectHomeColumn fields....... PropertyHouseNumber, PropertyStreetDirection, PropertyStreetName, PropertyMODE 0000001091 , W , 000026TH , RD Thank youRV |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-24 : 19:47:09
|
| [code]declare @s varchar(200)select @s = '0000001091'select @s, '_' + replace(ltrim(replace(@s, '0', ' ')), ' ', '0') + '_'[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-24 : 19:50:03
|
is PropertyHouseNumber only contain numeric ?select convert(varchar(10), convert(bigint, PropertyHouseNumber)) KH |
 |
|
|
rvan
Starting Member
28 Posts |
Posted - 2007-01-25 : 11:33:54
|
quote: Originally posted by khtan is PropertyHouseNumber only contain numeric ?select convert(varchar(10), convert(bigint, PropertyHouseNumber)) KH
Hi, KHData type for PropertyHouseNumber is contain Char only.thank youRV |
 |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2007-01-25 : 12:04:18
|
| So then your whole expression is going to beSELECT replace(ltrim(replace(PropertyHouseNumber, '0', ' ')), ' ', '0') + ', ' + PropertyStreetDirection + ', ' + replace(ltrim(replace(PropertyStreetName, '0', ' ')), ' ', '0') + ', ' + PropertyMODE |
 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2007-01-26 : 10:04:45
|
Hi all,Here's an alternative...declare @s varchar(200)select @s = '0000001091'select substring(@s, patindex('%[^0]%', @s), 200)Ryan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
|
|
|
|
|
|