To help declare variables of the right datatype and size while creating Stored Procedures, this stored procedure accepts the name of the table and returns the variable list with all necessary information.
Create proc sp_GetDataType@Name varchar(50)ASSELECT '@' + RTRIM(C.Name) + ' ' + RTRIM(T.Name) + case when (C.xtype = 167 or C.xtype = 175) then '(' +rtrim(cast(C.Length as char)) + ')' else '' End + ',' from sysobjects O, SYSCOLUMNS C, SYSTYPES TWHERE C.ID = O.IdAND O.name = @NameAND C.xtype = T.xtypeOrder by ColID--------------------------Result :--------------------------@EmployeeID int,@FirstName varchar(50),@LastName varchar(50),@DOJ smalldatetime,@SpecialUser bit,