0

I want to create a query that generates the table name. I tried something like this :

SELECT TABLE_NAME 
FROM INFORMATION_SCHEMA.TABLES
WHERE  TABLE_SCHEMA='mytableName'

but it return an empty query. So , any ideas ? Thx

Attila Naghi
  • 2,535
  • 6
  • 37
  • 59

3 Answers3

0

There is incorrect syntax at "WHERE AND".

You should execute:

SELECT TABLE_NAME 
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='mytableName'

You should try TABLE_SCHEMA='dbo', it looks like your schema 'mytableName' is really empty.

Valin
  • 2,285
  • 1
  • 15
  • 10
0

Why WHERE AND TABLE_SCHEMA='mytableName' The AND is invalid at this point.

Besides the Tablename is in the column TABLE_NAME not TABLE_SCHEMA, maby you should try to filter using the schema name instead of the table name like:

SELECT TABLE_NAME 
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='YOUR_SCHEMA_NAME'

Or if you need information regarding a specific table:

SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME='YOUR_TABLE_NAME'
CloudyMarble
  • 36,908
  • 70
  • 97
  • 130
0

To start with: that query is invalid (remove the AND).

2nd it's empty because there are no tables within the schema (also called database) named mytableName.

Also take a look at SHOW TABLES (documentation) and SHOW DATABASES (documentation)

Peter van der Wal
  • 11,141
  • 2
  • 21
  • 29