Sure it could be done by Dynamic sql, you will get all your needed table into a temp table with an identity column [id].
CREATE TABLE #temp ---identity column will be used to iterate
(
id INT IDENTITY,
SchemaName VARCHAR(20),
TableName VARCHAR(20),
ColumnName VARCHAR(20)
)
INSERT INTO #temp
SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
-- choose your own results with where conditions
DECLARE @SQL VARCHAR(MAX)
DECLARE @Count INT = 1
DECLARE @Schema VARCHAR(20)
DECLARE @Table VARCHAR(20)
DECLARE @Column VARCHAR(20)
WHILE @COUNT <= (SELECT COUNT(*) FROM #temp)
BEGIN
SELECT @Schema = SchemaName FROM #temp WHERE id = @Count
select @table = TABLENAME FROM #temp WHERE id = @Count
SELECT @Column = COLUMNNAME FROM #temp WHERE id = @Count
SELECT @sql = 'DELECT FROM '+@Schema+'.'+@Table+ 'WHERE ID = 19'
--PRINT @SQL
SET @Count = @Count + 1
END
change PRINT to Exec if your printed query looks good to you.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…