database - deleting certain rows with multiple tables T-SQL -


i have database multiple tables. want remove entries has column id value. there way in t-sql given there might tables might not have column id?

you use dynamic sql create command delete records tables column 'id' in database:

declare @idtodelete varchar(max) = '10'  declare @sql nvarchar(max) = ''  set @sql = ( select 'delete ' + object_name(c.object_id) + ' id = ' + @idtodelete +  char(10) sys.columns c      join sys.objects o on o.object_id = c.object_id     join sys.schemas s on s.schema_id = o.schema_id         , s.name = 'dbo' c.name = 'id'      xml path('') )  print @sql  exec sp_executesql @sql 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -