December 12, 2014 at 7:51 am
Hi,first of all, sorry for my English...
After 8 years in oracle we are moving to MSql and i'm having some issues....
The first of them:
I have this pice of code:
declare
@a as varchar(25);
begin
set @a = 'q246_pantilla_normal';
select @a;
SELECT *
FROM imp.sdicd_section
WHERE
object_name=@a;
SELECT *
FROM imp.sdicd_section
WHERE
object_name='q246_plantilla_normal';
end;
The first select returns the value assigned to the variable, all ok.
The second query returns 0 rows, and the third one returns 2 rows.
Why the second query not return the same 2 rows than the third?
December 12, 2014 at 8:50 am
The reason that the second query returns zero data (as compared to third query) is because you have assigned the variable the value 'q246_pantilla_normal' (used in first and second queries) while the third query is looking for 'q246_plantilla_normal'.
note the extra 'l'
'q246_pantilla_normal' -- parameter
'q246_plantilla_normal' -- hard coded string
I remember making a similar mistake and pouring over my SQL for hours to try and track down the issue, only to find a simple misspelling. 😀
December 12, 2014 at 8:57 am
ohhh, sorry....
too much querys for me today....
Thanks!!
December 12, 2014 at 8:59 am
adiaz 16837 (12/12/2014)
ohhh, sorry....too much querys for me today....
Thanks!!
Or not enough coffee 😀
_________________________________________________________________________
SSC Guide to Posting and Best Practices
December 12, 2014 at 9:01 am
:-D:-D:-D:-D:-D
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply