Input Parameters from a SQL Table

By Rakesh Kalluri Jan 07, 2014
This blog defines the input parameters from an SQL Table.
This blog defines the input parameters from an SQL Table.

use test
-- simple script for getting the input parameters from a sql table
create table tbl_inputparm
ID int primary key identity(1,1),
Name varchar(50),
Age Int ,
Address varchar(100)

Most of the SQL developer’s need to write stored procedures. When creating the stored procedures we need to pass some of the input parameters. Here is a simple script for Getting the Parameters from the SQL Table.

declare @tableName varchar(max)='tbl_inputparm'
select '@In_'' '+cast( as varchar(max) )+ cast((case when'varchar') then
'('+cast(c.max_length as varchar(max))+')' when'decimal') then '('+cast(c.precision as varchar(max))+','+cast(c.scale as varchar(max))+')'
else '' end) as varchar(max)) +'=null ,'[columnname] from sys.objects s join sys.columns c on s.object_id=c.object_id
join sys.types t on t.system_type_id=c.system_type_id where s.Type='U' and
@In_ID int=null ,
@In_Age int=null ,
@In_Name varchar(50)=null ,
@In_Address varchar(100)=null ,

Rakesh Kalluri

I am .net Developer. I did my bachelor degree. I love sql Query writing and also interested in MSBI. I started my journey .NET Developer. I have Worked in ASP.NET ,ADO.NET,MVC,Jquery,Javascript, MVC ,C#,LINQ,Enitity ... Read more



Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs