June 21, 2022 at 9:29 pm
Hello friends,
I have a requirement where I have to compare the two fields using regular expressions.
Example, I have a parameter with value 'ABCDEF.%30a.3%a' or 'BBBB.%10a.5%a' where %30a or %10a tells the length of the name of the file, first set before '.' says the prefix and last one says the extension like '.abc' or '.pdf' or '.ghijk'. how can I compare with another Param where I send the name ?
Are there any specific functions which help reduce the comparison ?
June 22, 2022 at 4:04 am
Hello friends,
I have a requirement where I have to compare the two fields using regular expressions.
Example, I have a parameter with value 'ABCDEF.%30a.3%a' or 'BBBB.%10a.5%a' where %30a or %10a tells the length of the name of the file, first set before '.' says the prefix and last one says the extension like '.abc' or '.pdf' or '.ghijk'. how can I compare with another Param where I send the name ?
Are there any specific functions which help reduce the comparison ?
A multi-value column is always going to lead to performance issues especially when you're trying to do comparisons. I''d likely add 3 computed columns with each part split out into a separate column. You can easily do that here with PARSENAME.
https://docs.microsoft.com/en-us/sql/t-sql/functions/parsename-transact-sql
--Jeff Moden
Change is inevitable... Change for the better is not.
June 22, 2022 at 8:42 am
Just to be clear, you are comparing the values of two parameters, is that right? Because you also mention 'fields', and it's not clear whether you mean values in a database, parameter values or something else.
Can you provide a specific example? It would help us understand better.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
June 22, 2022 at 10:07 am
Yes, parameters.
June 22, 2022 at 10:11 am
Yes, parameters.
OK, please provide a couple of examples, along with the desired result.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
June 22, 2022 at 3:11 pm
I don't think there any built-in functions that would directly help with that.
As Phil suggested, post examples and he can help you with custom code to do it.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
June 22, 2022 at 8:10 pm
Yes, parameters.
PARSENAME will still help in this case.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply