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 |
|
zeeshan13
Constraint Violating Yak Guru
347 Posts |
Posted - 2006-03-28 : 11:46:10
|
| Hi All,In a Table Sales I have a column UPC(nvarchar) type.In UPC, the records are like this:027200008513- UN000000008544- P2I just want the part before hyphen - (That is I need the first 12 digits). But I also need the left most 0' to be removed.In a select statement, I want to get the above records like this:272000085138544Any quick help would be appreciated.Thanks, |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2006-03-28 : 11:49:44
|
Here you go...  --datadeclare @t table (v varchar(30))insert @t select '027200008513- UN'union all select '000000008544- P2'--calculationselect cast(left(v, 12) as bigint) from @t Ryan Randallwww.monsoonmalabar.comIdeas are easy. Choosing between them is the hard part. |
 |
|
|
|
|
|