Last post Sep 23, 2020 10:16 AM by XuDong Peng
Sep 22, 2020 05:05 AM|robby32|LINK
I have a db I can see in SSMS named MyTestDB. The server is Case Sensitive with collation SQL_Latin1_General_CP1_CS_AS
i am wanting to see if a db exists . I do the following
SELECT name from sys.databases WHERE name = 'MYTESTDB', notice the upper case.
If it were a Case Insensitive DB it would return one row.
How can i do the select to return one row in a case sensitive db ?
Sep 23, 2020 10:16 AM|XuDong Peng|LINK
According to your description, I built a database for testing and tried your query statement. I found that the collation has no substantial effect on this statement.
You need to specify the collation in the conditional statement.
Just like this:
select name from sys.databases where name='databaseName' COLLATE SQL_Latin1_General_CP1_CS_AS