Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear All
I am doing a project winform by c# language. my application has a module is backup database into .bak and save in folder in same server.
But I don't know how to get directory of server by account SQL server.
it is display like when find file to attach to SQL server.
Posted
Comments
Bernhard Hiller 31-Oct-13 7:04am    
I do not understand why you need that. There is a SQL command "BACKUP TODISK", and there you tell the server where to write it too. And when it comes to attaching a database, actually any location where the server has write access will do.

1 solution

If any backup of any database already present in that server then you can get the file path by the following query:

select physical_device_name from msdb.dbo.backupmediafamily


among those paths you can get any one and execute following query to create backup of your database:

SQL
BACKUP DATABASE @DBName
TO DISK = @Path
   WITH FORMAT;
 
Share this answer
 

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



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