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 |
|
sangeeta
Starting Member
16 Posts |
Posted - 2007-02-08 : 16:08:24
|
| Hi -I am new to SQL server and was wondering if someone can help me with this one. ThanksMy table holds 2 columns (SECTOR and TERM) with following example valuesSECTOR TERMHybrid 6/1 8Hybrid 9/1 9Hybrid 10/1 7Hybrid 3/1 3I would like to find out the rows where my values from SECTOR before '/' does not equal TERMi.e. Row 1 where 6<>8and row 3 where 10<>7Thanks. |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
sangeeta
Starting Member
16 Posts |
Posted - 2007-02-08 : 17:11:55
|
| Brett -Hybrid 6/1 is in Sectorand 8 is in term1 is some value that I don't care about. I am trying to map 6 with 8Thanks. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-09 : 01:04:15
|
| [code]-- prepare sample datadeclare @test table (sector varchar(20), term int)insert @testselect 'Hybrid 6/1', 8 union allselect 'Hybrid 9/1', 9 union allselect 'Hybrid 10/1', 7 union allselect 'Hybrid 3/1', 3-- Show the resultSELECT SectorFROM @TestWHERE CAST(Term AS VARCHAR) <> SUBSTRING(Sector, CHARINDEX(' ', Sector) + 1, CHARINDEX('/', Sector) - CHARINDEX(' ', Sector) - 1)[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
sangeeta
Starting Member
16 Posts |
Posted - 2007-02-09 : 10:31:39
|
| Thanks a lot Peter.I have never played with parsing features in sql. I should |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-02-09 : 10:34:06
|
quote: Originally posted by sangeeta Thanks a lot Peter.I have never played with parsing features in sql. I should
You should not unless you are out of options. These things can be better handled at Front-end.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|