ssurekha2000 (5/1/2014)
i think query is unclearTranscation tbl has transcationdate, amount and cid
Mas_C has cid and cname
Transcation date displayed will be from & todate passed from the application
1) the output needed is in all conditions
transcationdate, amount
if @<>type''
output shld be transcationdate, amount
if @cid<>''
output shld be transcationdate, amount cname
It's unclear what you want to do. You almost certainly don't need dynamic sql. How many result sets are you expecting from this? Try to write the query(ies) without using dynamic sql and post back if it doesn't work.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden