Dotnet, DotnetCore, Azure, C#,VB.net, Sql Server, WCF, MVC ,Linq, Javascript and Jquery
2 December 2011
Dynamic Stored Procedure example in Sql Server
Dynamic Stored Procedure example in Sql Server
/*
EXEC Proc_get_gridCount 'MUser','StatusId=1'
--Dynamic Stored Procedure example , to get the table and name and Condition and get the result
*/
Create Procedure Proc_get_gridCount(
@Tablename as varchar(50),
@Condition as varchar(300)
)
as
begin
set nocount on
declare @StrSelectSQL as nvarchar(500) --It should be nvarchar, if you declare varchar error will come.
SELECT @StrSelectSQL = ''
SELECT @StrSelectSQL = @StrSelectSQL + ' Select Count(*) From '
SELECT @StrSelectSQL = @StrSelectSQL + @TableName
SELECT @StrSelectSQL = @StrSelectSQL + ' Where '
SELECT @StrSelectSQL = @StrSelectSQL + @Condition
-- print @StrSelectSQL
EXEC SP_EXECUTESQL @StrSelectSQL
END
Subscribe to:
Post Comments (Atom)
Implementing OAuth validation in a Web API
I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...
-
ViewBag, ViewData, TempData and View State in MVC ASP.NET MVC offers us three options ViewData, ViewBag and TempData for passing data from...
-
// Export Datatable to Excel in C# Windows application using System; using System.Data; using System.IO; using System.Windows.Forms; ...
No comments:
Post a Comment
Comments Welcome