IMHO du bør ikke bruge INFORMATION_SCHEMA
for noget af dette
. Følgende vil fungere for en tabel eller en visning:
SELECT UPPER(name)
FROM sys.columns
WHERE OBJECT_NAME([object_id]) = N'mutable';
Følgende vil fungere for et synonym (et krav du ændrede senere):
SELECT UPPER(name)
FROM sys.columns AS c
CROSS APPLY
(
SELECT name
FROM sys.synonyms
WHERE name = N'mutable'
AND OBJECT_ID([base_object_name]) = c.[object_id]
) AS x;
Du kan også bare sige:
DECLARE @obj INT;
SELECT @obj = OBJECT_ID([base_object_name])
FROM sys.synonyms WHERE name = N'mutable';
SELECT UPPER(name) FROM sys.columns WHERE [object_id] = @obj;