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 |
|
Jason2112
Starting Member
17 Posts |
Posted - 2009-06-30 : 14:11:00
|
| I have an nvarchar field (size=4) that is used to identify an item number. The item number is made up of 3 distinct identifiers: family (digit 1), class (digit 2), sub-class (digits 3-4). I need some help with creating the select statement to look at each digit in the field. Probably easy, but I couldn't find anything in older posts. Thanks. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-30 : 14:12:43
|
What do you mean with "Look at each digit"? N 56°04'39.26"E 12°55'05.63" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-30 : 14:13:26
|
| [code]SELECT LEFT(field,1) AS family,SUBSTRING(field,2,1) AS class,RIGHT(field,2) AS sub_classFROM YourTable[/code] |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-30 : 14:16:56
|
1. Why NVARCHAR?2. Why VARCHAR at all? N 56°04'39.26"E 12°55'05.63" |
 |
|
|
Jason2112
Starting Member
17 Posts |
Posted - 2009-06-30 : 15:29:40
|
quote: Originally posted by visakh16
SELECT LEFT(field,1) AS family,SUBSTRING(field,2,1) AS class,RIGHT(field,2) AS sub_classFROM YourTable
Thank you that worked perfect! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-01 : 11:52:34
|
| welcome |
 |
|
|
|
|
|
|
|