Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Data files

Author  Topic 

nikke
Starting Member

7 Posts

Posted - 2003-11-26 : 03:32:37
Hi everybody!

When I create a database in SQL Server Enterprise Manager it creates the data file and log file on the server's data directory. How is this done? What I mean is that, I as the client, don't have authorities to write on that directory.

Why I'm asking is to find a way to copy a data file from SQL server to my local machine with my program. Is this possible?

Thanks in advance.

/Nicke

xpandre
Posting Yak Master

212 Posts

Posted - 2003-11-26 : 04:36:41


http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q208/8/88.asp&NoWebContent=1

HTH
Sam
Go to Top of Page

nikke
Starting Member

7 Posts

Posted - 2003-11-26 : 05:16:52
Thanks for your answer but this is not exactly what I want. I want to physically copy the mdf file from the server.

/Nicke
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2003-11-26 : 10:11:37
Only the sql server service needs permission on the directory - the user doesn't have access to the file only through sql server.
If the server has permission on your machine (you can create a share and give everyone full control) and you have permission to use xp_cmdshell then you could use that to do the copy. You won't be able to do it if the database is attached though. If you want a copy it is is better to take a backup and copy that - will be smaller too.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Granick
Starting Member

46 Posts

Posted - 2003-11-26 : 12:40:28
It always kind of surprises me how much I have been able to use xp_cmdshell for in the past. I have surprised a couple Network admins at a previous employer with the abilty to get to files using this proc that they had no idea that they were being stubborn in giving me access to.

:)
Go to Top of Page

nikke
Starting Member

7 Posts

Posted - 2003-11-27 : 03:55:16
This is really cool, thank you very much.

BTW, not that I care but in other words you have full access to the file system if you have a password for any users in the sysadmins role? I can browse any computer at my company that have a sql server with blank password for sa?

Is this really safe?

/Nicke
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2003-11-27 : 05:22:03
It's not really safe no.

-------
Moo. :)
Go to Top of Page
   

- Advertisement -