Looking to list database names from a SQL server instance on this way
I will take that result and put it on a NAME IN () statement, inside the parenthesis I mean.
I tried this, but I am but still missing one single quote:
DECLARE @DBList VARCHAR(MAX) SELECT @DBList = COALESCE(@DBList + ''',', '') + name FROM sys.databases ORDER BY name SELECT @DBList
That adds the 2nd single quote, but not the initial one.
Any ideas how can I accomplish this?