December 17, 2021 at 8:07 am
Hi
I am getting data from Cte
I want if @ICode parameter is not null then select statement should execute with parameter else all data
SELECT * from cteCab where icode = @ICode
else select * from ctetab
Thanks
December 17, 2021 at 9:30 am
I answered this question yesterday. Why are you asking it again?
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
December 17, 2021 at 4:35 pm
When I run into problems like the one's you're having, I go back to the basics.
The first step is to get out of the dynamic SQL world and get some regular code to work properly first. Then, you can work on making it dynamic and you'll be much more successful.
In fact... I lied a bit. I don't run into problems like the one's you're having because I always start with working code first. Then I convert it to dynamic SQL one parameter at a time.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 21, 2021 at 5:30 pm
Seems like this user is posting exam questions on the forum.
----------------------------------------------------
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply