You may have multiple instances on the same machine.
Double check that you are running this query in your instance correctly.
i am executing a query but it doesnt work like i want to
hi guys i am executing;
select name from sys.Databases
it only shows me system databases like master ect.
but i have lots of databases in my instance
2 answers
Sort by: Most helpful
-
Jingyang Li 5,891 Reputation points
2022-05-14T03:05:56.463+00:00 -
Erland Sommarskog 101K Reputation points MVP
2022-05-14T06:29:05.983+00:00 when i made this program i made users selecting the instance
When i execute this query on ssms there is no problem it shows every database but when i use c# to do it it only shows system databases
Debugging time, I guess!
First add this query to your C# program:
SELECT @@servername
to verify that you are connecting to the server you think you are connecting to.
Would that be the case, then add this query:
SELECT SYSTEM_USER, * FROM sys.fn_my_permissions(NULL, NULL)
Do you see VIEW ANY DATABASE in the list? Is the user the expected one?