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 |
|
issammansour
Yak Posting Veteran
51 Posts |
Posted - 2007-09-28 : 16:48:15
|
| Hi,I have an item number as column on my table, this column is a char(10) size. Its look like this.Item_no-------010010001010010002010010003010020001010020002020020001The description of the field as follows:-xx is the catcodexxx is a subcodexxxxx is the serial numberHow to search the table look for item number with subcode of '002', normally we are using before str() function.Best Regards |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2007-09-28 : 17:32:00
|
| select * from table where substring(item_no, 3, 3) = '002'--Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand" |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-29 : 04:44:38
|
| select * from table where item_no LIKE '__002%'may be faster, although the leading wildcards may preclude that.It would be better to change your table structure so that this single field was not overloaded with three separate pieces of data, and put them in individual fields instead.Kristen |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-03 : 03:32:17
|
| oritem_no like '[0-9][0-9]002%'MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|