September 23, 2013 at 8:59 pm
Comments posted to this topic are about the item Dynamic Query
[font="Verdana"] There is no Wrong time to do a Right thing [/font]
September 23, 2013 at 9:03 pm
September 23, 2013 at 10:28 pm
easy one to start the day
September 23, 2013 at 10:36 pm
While using SELECT it will give the output in a commented lines while using EXEC it gives the error :crazy:
declare @var Varchar(1000)
set @var = '-- /* select ''Samith'' name
*/'
select @var
--Output: '-- /* select 'Samith' name */'
set @var = @var + ' select ''sas'''
select @var
--Output:' -- /* select 'Samith' name */ + select 'sas''
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
September 23, 2013 at 10:38 pm
Nice and simple one.
September 23, 2013 at 10:40 pm
Good basic question.
September 23, 2013 at 10:45 pm
Change to Text mode [Ctrl+t]
and check the result
You can see the difference
[font="Verdana"] There is no Wrong time to do a Right thing [/font]
September 24, 2013 at 12:47 am
kapil_kk (9/23/2013)
While using SELECT it will give the output in a commented lines while using EXEC it gives the error :crazy:
declare @var Varchar(1000)
set @var = '-- /* select ''Samith'' name
*/'
select @var
--Output: '-- /* select 'Samith' name */'
set @var = @var + ' select ''sas'''
select @var
--Output:' -- /* select 'Samith' name */ + select 'sas''
True.
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
September 24, 2013 at 12:52 am
kapil_kk (9/23/2013)
While using SELECT it will give the output in a commented lines while using EXEC it gives the error :crazy:
declare @var Varchar(1000)
set @var = '-- /* select ''Samith'' name
*/'
select @var
--Output: '-- /* select 'Samith' name */'
set @var = @var + ' select ''sas'''
select @var
--Output:' -- /* select 'Samith' name */ + select 'sas''
Maybe, you have the resultset in grid mode! Change it to text mode and you'll see the "*/" at newline
September 24, 2013 at 12:54 am
Although I was pretty sure that this is another tricky question and my answer will be wrong when I pressed Submit button; but surprisingly it was correct
exec @variable; hmmm always good to refresh the mind with hidden & forgotten basics.
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
September 24, 2013 at 1:03 am
I LOVE TRICKY QUESTIONS ALWAYS... THANKS SAMITH..
September 24, 2013 at 1:17 am
Nice easy question for me.
September 24, 2013 at 1:42 am
I had to think about it for a while before answering. Good one.
September 24, 2013 at 1:53 am
ksatpute123 (9/24/2013)
I had to think about it for a while before answering. Good one.
same here.Thanks Smith
Pramod
SQL Server DBA | MCSE SQL Server 2012/2014
in.linkedin.com/in/pramodsingla/
http://pramodsingla.wordpress.com/
September 24, 2013 at 2:01 am
Very nice question, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 15 posts - 1 through 15 (of 38 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy