TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Riddhi Valecha
442
3.3k
415.1k
Count(*) for Dynamic Search Query
May 23 2014 2:57 AM
Hi All....
Please help me out in dynamic search query in sql stored procedure....
----
My procedure is as -
@CompanyCode varchar(max) = null,
@Document varchar(max) = null,
@Status varchar(max) = null,
@Location varchar(max) = null
declare @SQL as nvarchar(max)
set @SQL = 'select * from Table where 1=1'
if @CompanyCode is not null
set @SQL = @SQL + 'and Table.CompanyCode = '+@CompanyCode
if @Document is not null
set @SQL = @SQL + 'and Table.Document = '+@Document
Same way, for the rest of the parameters.
-----------
Now, my query is, how do we get the total records from this query ??
i.e.
select @Totalrecords = count(*) from Table + where clause.
There are 50000 records in the table, but only 10000 satisfy the conditions.
SO, I want 10000 count as a output variable.
How do I get this??
PLease help....
Reply
Answers (
3
)
Pass multiple values- Query string - Javascript
show the button in run time like