Reputation: 413
Here is the code that doesn't work:
DECLARE @myTable TABLE (colName nvarchar(500), tableName nvarchar(500))
insert into @myTable
SELECT c.COLUMN_NAME AS colName, c.TABLE_NAME AS tableName, TABLE_SCHEMA tableSchema
FROM information_schema.COLUMNS as c
WHERE c.COLUMN_NAME like '%password%'
select * from @myTable
My error is:
[Error] Script lines: 1-7 -------------------------- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @myTable TABLE (colName nvarchar(500), tableName nvarchar(500))
insert ' at line 1
Anyone have any ideas?
Upvotes: 0
Views: 153
Reputation: 74108
Mysql is a bit different:
create table myTable (colName nvarchar(500), tableName nvarchar(500));
insert into myTable (colName, tableName)
SELECT COLUMN_NAME, TABLE_NAME
FROM information_schema.COLUMNS
WHERE COLUMN_NAME like '%password%';
select * from myTable;
Upvotes: 1
Reputation: 1888
you can try this
insert into myTable
SELECT c.COLUMN_NAME AS colName, c.TABLE_NAME AS tableName
FROM information_schema.COLUMNS as c
WHERE c.COLUMN_NAME like '%password%'
Upvotes: 0