0

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?

Alias
  • 415
  • 1
  • 6
  • 20

2 Answers2

1

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;
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
0

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%'
SRIRAM
  • 1,888
  • 2
  • 17
  • 17