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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 String Compare, Help needed.

Author  Topic 

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2011-08-17 : 08:32:32
Good Morning every one. Having some issues to compare the two strings in one column. Here is the sample data.

quote:

Tax Rate: 10.0000% Tax Amount: 14.00 Tax Accrued: 14.00
Tax Rate: 10.0000% Tax Amount: 23.02 Tax Accrued: 23.02
Tax Rate: 10.0000% Tax Amount: 16.72 Tax Accrued: 16.72
Tax Rate: 9.9800% Tax Amount: 1.29 Tax Accrued: 1.29
Tax Rate: 0.0000% Tax Amount: 0.00 Tax Accrued: 0.00
Tax Rate: 0.0000% Tax Amount: 0.00 Tax Accrued: 0.00
Tax Rate: 0.0000% Tax Amount: 0.00 Tax Accrued: 0.00
Tax Rate: 0.0000% Tax Amount: 0.00 Tax Accrued: 0.00



Can some one help me to compare the tax amount(14.00) and tax Accrued(14.00)?

Thank you
Krishna

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-17 : 09:57:47
are all these in same column? or are they in different columns?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-17 : 09:59:11
you need to use PATINDEX and take substring and then compare based on that if they're all in same column. Can i ask why you're storing multiple field values in same column? have you heard of 1 NF?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2011-08-17 : 10:00:58
Same column. It is not a multiple column. It is just a description.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-18 : 04:39:50
you can get column values like this

select ltrim(rtrim(substring(strcol,PATINDEX('%Tax Amount:%',strcol)+11,PATINDEX('%Tax Accrued:%',strcol)-PATINDEX('%Tax Amount:%',strcol)-12+1))) as [Tax Amount],
ltrim(rtrim(substring(strcol,PATINDEX('%Tax Accrued:%',strcol)+12,LEN(strcol)))) as [Tax Accrued]
FROM Table


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -