It will be a lot easier if you were to tell me what do you want to script or create so that I can give you a sample procedure call. The procedure depends on the CLR aggregate posted with the code. By default all options are turned off for proc sp_scriptmain and all create only options and printsql turned on for proc sp_script (which calls sc_scriptmain with turned on options). Parameters have default blank values therefore they are not mandatory. The first parameter is @ObjectName therefore if no parameter name is passed and only one parameter is passed that parameter will be passed into @Objectname.

-- The parameters below is used for filtering tables @ObjectName SYSNAME = NULL, -- SchemaName.TableName (if this is set the other filters ignored) @SchemaName SYSNAME = NULL, -- SchemaName (used in like '%test%schema%', it can be used together or not with TableName) @TableName SYSNAME = NULL, -- TableName(used in like '%test%table%', it can be used together or not with SchemaName) @TableList XML = NULL, -- xml input for specific tablename + schemaname, check procedure comments