Click here to Skip to main content
16,010,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this problem to find the path of MSSSQL instance and in that the DATA folder containing .mdf and .ldf files. I have to search for this programmatically in c#. Condtion is that i should be able to find this path irrespective of where and in which drive the SQL server is installed in. Any suggesstions??

**********************************************************************************
The path which was returned was Backup directory and i required a DATA directory..Any changes that i might have to do.
Posted
Updated 12-Jun-14 18:58pm
v2

1 solution

Google will find you several examples or you could start with this CP article http://www.codeproject.com/Articles/684020/Checking-MS-SQL-Server-database-files-default-path
Put this code into a stored procedure which you can call from c# for example
 
Share this answer
 
Comments
Anshumaan Chaturvedi 12-Jun-14 9:59am    
So this gets me all the instances of SQL server installed on local machine or on network also??
Finally this stored procedure will give me a path name or what ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900