sql - Execute dynamic query result using stored procedure -


the below query return 60 rows, how can execute statements using stored procedure in single go.

select 'update temp1 set ' + column_name + '= 0' + ' '+column_name+ ' null' information_schema.columns  table_name = 'temp1' , data_type = 'float'  , column_name not in('sales','net_margin'); 

here 1 way it:

declare @sql nvarchar(max) = ''  select @sql = @sql + 'update temp1 set ' + column_name + '= 0' + '  '+column_name+ ' null; ' information_schema.columns  table_name = 'temp1' , data_type = 'float'  , column_name not in('sales','net_margin');  print @sql -- remark row once check sql , unremark next 1 execute  --exec(@sql) 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -