(This version work only
in Postgres)
SELECT whatever
FROM t --- you missed the FROM
WHERE (col1, col2) --- parentheses here
IN ((val1, val2), (val1, val2), ...)
In SQL Server use this:
The following examples uses the table value constructor to specify multiple values in the FROM clause of a SELECT statement.
SELECT OBJECT_SCHEMA_NAME(object_id) as 'schema', OBJECT_NAME(object_id) as 'table', name as 'column'
FROM sys.columns s
JOIN
(VALUES ('dbo', 'TableName1'),('dbo', 'TableName2')) AS V(schema_name,
table_name)
on
V.schema_name
= OBJECT_SCHEMA_NAME(object_id) and V.table_name = OBJECT_NAME(object_id)
You can made a connection between schema and table name as a one string:
SELECT OBJECT_SCHEMA_NAME(object_id) as 'schema', OBJECT_NAME(object_id) as 'table', name as 'column'
FROM sys.columns
WHERE OBJECT_SCHEMA_NAME(object_id) + '.' + OBJECT_NAME(object_id) IN ('dbo.TableName1', 'dbo.TableName2')
https://msdn.microsoft.com/pl-pl/library/dd776382%28v=sql.110%29.aspx
http://dba.stackexchange.com/questions/34266/selecting-where-two-columns-are-in-a-set
Brak komentarzy:
Prześlij komentarz