Drop column from multiple tables in particular schema in SQL Server -



Drop column from multiple tables in particular schema in SQL Server -

i have many table containing column "rowid" in different schema dbo, stg, tmp etc want drop column of stg schema tables.

please give script followed above condition.

thanx in advance

back first

declare @sqlstatement varchar(max) select @sqlstatement = coalesce(@sqlstatement, '') + 'alter table [stg].' + quotename(table_name) + ' drop column [rowid];' + char(13) information_schema.tables t inner bring together sys.objects o on o.name=t.table_name inner bring together sys.columns c on o.object_id= c.object_id table_schema = 'stg' , c.name='rowid' print @sqlstatement

once shure, execute dinamyc sql statement

exec sp_executesql @sqlstatement

sql-server-2008-r2 alter-table alter

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -