Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Generate stored procedure parameter list based on table Expand / Collapse
Author
Message
Posted Thursday, November 12, 2009 10:49 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, November 13, 2012 5:08 AM
Points: 3, Visits: 52
Comments posted to this topic are about the item Generate stored procedure parameter list based on table
Post #817992
Posted Friday, December 04, 2009 6:34 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 15, 2013 12:06 AM
Points: 8, Visits: 57
It is very good stored procedure for tables having many columns and complex names.
One suggestion is - Instead of using default length of 5o for varchar use c.length column to get actual lenght.
Post #828832
Posted Sunday, December 27, 2009 11:49 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, November 13, 2012 5:08 AM
Points: 3, Visits: 52
Thank you Paras. I've made the enhancement.
Post #839276
Posted Monday, October 18, 2010 11:26 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, October 19, 2010 7:37 AM
Points: 1, Visits: 3
I get "incorrect syntax near "c.length" when trying this.

Tim

paras.halingale (12/4/2009)
It is very good stored procedure for tables having many columns and complex names.
One suggestion is - Instead of using default length of 5o for varchar use c.length column to get actual lenght.
Post #1006432
Posted Wednesday, October 12, 2011 9:54 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, November 13, 2012 5:08 AM
Points: 3, Visits: 52
Hey,
I've just had to use this again and have made some changes, I realise I only really need to the length of the column for text columns so here it is:
select c.name as name, 	
' = ',
'@' + c.name as _name_param,
c.name + '_DESC' as name_ordered,
t.name + '(' + cast(c.prec as varchar(50)) + ')' as [col_def],
coldefinition =
case t.name
when 'nvarchar' then 'nvarchar' + '(' + cast(c.prec as varchar(50)) + ')'
when 'varchar' then 'nvarchar' + '(' + cast(c.prec as varchar(50)) + ')'
when 'char' then 'char' + '(' + cast(c.prec as varchar(50)) + ')'
when 'nchar' then 'nchar' + '(' + cast(c.prec as varchar(50)) + ')'
else t.name
end
+ ' = NULL'
from sysobjects s
inner join sys.syscolumns c on s.id = c.id
inner join sys.types t on t.user_type_id = c.xtype
where s.xtype='U'
and s.name = 'PolicyZoneMembership'

Post #1189270
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse