Query statements that have specific columns in multiple tables and find and delete conditions for their values

Asked 1 years ago, Updated 1 years ago, 123 views

The following are the actions I want to do.

SQL statement that returns a complete list of tables with a specific column name

SELECT TABLE_NAME FROM information_schema.COLUMNS where COLUMN_NAME = 'The name of the column you want to find'

But I can't use it like this.

 DELETE (sentence above) where column name = erasure value

The problem is that there is no variable in the place where the table name should be

I'd appreciate it if you could share your know-how.

mssql sql

2022-09-21 22:16

1 Answers

Turn the procedure for loop to check if each table has a corresponding column,

Wouldn't it be possible to delete it if there is?


2022-09-21 22:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.