i need add bunch of c# code test values against table. connecting directly data source out of question (this needs static code).
the output
x.addcolumn("columnname",columnvalue);
i sql statement that, table returns above pattern, listing each column of row, iterating through every row in table.
i hoping select statement in db copy , paste result set of, ideally 1 went through columns dynamically save me doing below each table wish output.
select 'x.addcolumn("columnname1", ' + convert(varchar, columnname1, 100) +');' col1 ... 'x.addcolumn("columnnamen", ' + convert(varchar, columnnamen, 100) +');' coln schema.table1
of top of head, 2 step process:
run statement below. create query each of columns of table (something select 'x.addcolumn("column1", ' + convert(varchar, column1, 100) +' )' dbo.table1
)
select 'select ''x.addcolumn("' + c.column_name + '", ''+ convert(varchar, ' + c.column_name + ',100)+'' )'' ' + c.table_schema + '.' + c.table_name information_schema.columns c c.table_name = 'table1' , c.table_schema = 'dbo'
copy output of statement above , run it. should give desired output.
Comments
Post a Comment