June 22, 2012 at 4:23 pm
Hi Guys,
I have this query:
SET @STRSQL = ('UPDATE BULK_CONTRIBUINTES_21
SET VALIDO_BULK = 0,
MOTIVO_IRREGULAR_BULK =''NIF''
FROM
BULK_CONTRIBUINTES_21 A with (nolock), '+@DB+'.DBO.CONTRIBUINTES B with (nolock)
WHERE
A.NIF+ISNULL(A.FILIAL_NUMBER,'''') = B.NIF+ISNULL(A.FILIAL_NUMBER,'''')
AND
A.NIF_ANTIGO <> B.NIF_ANTIGO
AND
A.VALIDO_BULK IS NULL')
EXEC (@STRSQL)
It takes too long to execute because of the:
A.NIF+ISNULL(A.FILIAL_NUMBER,'''') = B.NIF+ISNULL(A.FILIAL_NUMBER,'''')
If I do it like this:
A.NIF= B.NIF
The query executes on a normal time.
The problem is when I concaten the value NIF with the value Filial_number.
Can someone help?
Thanks
June 22, 2012 at 4:38 pm
Maybe this is a silly question, but why do the concatenation at all? You're putting the same string on the end of both values, so if they are equal once concatenated, they'd be equal without the added string.
June 22, 2012 at 4:42 pm
David Webb-200187 (6/22/2012)
Maybe this is a silly question, but why do the concatenation at all? You're putting the same string on the end of both values, so if they are equal once concatenated, they'd be equal without the added string.
I wonder the same thing. I could understand it better if it were B.FILIAL_NUMBER instead of A.FILIAL_NUMBER on one side of the condition, but it is A.FILIAL_NUMBER on both sides.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
June 22, 2012 at 4:53 pm
Yes, that would make sense, but if it's really the same concatenation, then I gotta wonder....
June 23, 2012 at 6:34 am
That was the problem.
I should had B in one of the places instead of having A in both.
Thank you very much.
Problem solved.
June 23, 2012 at 10:14 am
Good to hear that it is resolved.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply