Click here to Skip to main content
15,884,986 members

Comments by Aarti Meswania (Top 200 by date)

Aarti Meswania 7-Oct-19 2:04am View    
5ed! :)
Aarti Meswania 4-Oct-19 1:15am View    
Hi Akshay,

That is called "dynamic query" for which you can refer link I have mentioned above. but I am trying to say that it is not safe as well as it might give you results slower. in above link see example of dynamic query
DECLARE @SQLString AS NVARCHAR(MAX);
SET @SQLString = N'SELECT ' +@columnnames+N' FROM ' + @tablename;
EXEC(@SQLString);


Let me suggest another approach, You have to find data in table so that columns are fixed. you want to filter 10 columns - 15 columns or 100 columns no matter, it's fine...
you can do that easily without dynamic query.
How???
WHERE
(tsn.SurveyorName= @SurveyorName OR @SurveyorName IS NULL)
AND (state = @state OR @state IS NULL)

kind of this you can write as many as you want.
and pass value to particular parameter(s) which you want, and avoid passing value to parameter(s) which you don't want, and see the magic :) It will give you exact output you seek. moreover, it's good and maintainable approach to write code:)
Aarti Meswania 1-Oct-19 3:26am View    
Glad to help you through this platform. However, I can't exchange the contact information, irfan. also I am not too much sharp in ASP.net.
Codeproject members are active n helpful to each other. you can post your queries here on codeproject and people who have knowledge in relevant topic would help you :)
Aarti Meswania 30-Sep-19 9:46am View    
Irfan, first of all I am a female :) you can say aarti instead of sir.
so....
here, (select sum(Qty) from inv where VouDt< i.VouDt) as OpnQty
means collecting qty field values which falls into less than running date and sum up qty to retrieve opening qty. for running date.
you can learn subquery for further details
Aarti Meswania 30-Sep-19 6:01am View    
vusamozi asked question in which stock is considered.
and when you sell something qty reduce not add up.