Posty bez odpowiedzi |oraz Aktywne tematy Dzisiaj jest 2024-03-28, 15:58x



Odpowiedz w temacie  [ Posty: 3 ] 
przeniesienie bazy danych sql 
Autor Wiadomość

Rejestracja: 2011-04-20, 15:57
Posty: 1
Post przeniesienie bazy danych sql
problem
symfonia forte zainstalowana na dysku c
baza danych tez na c:
kończy sie miejsce na dysku c:
dysk d: praktycznie pusty

czy mozńa w prosty sposób np przekopiować bazę danych na d: ?
np przenosząc cała kartotekę z baza?


2011-04-21, 09:07
Wyświetl profil
Autor Wiadomość
 


Ekspert
Ekspert

Rejestracja: 2007-11-16, 15:08
Posty: 3982
Pomógł: 445
Post 
Attaching and Detaching Databases on SQL Server
By Alexander Chigrik


Introduction
If you need to move a database, or database file to another server or disk, and you do not want to backup the database, copy the backup on another server, and then re-create the database from the backup, you can use the sp_detach_db and sp_attach_db system stored procedures to detach the database and then attach it again. Detaching and attaching databases can be used when you want to move the database files to a different physical disk from the disk that has run out of disk space and you want to expand the existing file rather than add a new file to the database on another disk.

To move a database using detach and attach, you should make the following steps:

    •Detach the database.
    •Move the database file(s) to the desired location on another server or disk.
    •Attach the database specifying the new location of the moved file(s).

After detaching, the database will be removed from SQL Server but will be intact within the data and transaction log files that compose the database. You can use these data and transaction log files to attach the database to any instance of SQL Server, including the server from which the database was detached. After attaching, the database will be available in exactly the same state it was in when it was detached.

Detaching a Database
To detach an SQL Server 2000 database, you can use the sp_detach_db system stored procedure. This stored procedure can also run UPDATE STATISTICS on all tables before detaching. The syntax for sp_detach_db system stored procedure is as follows:

Kod:
sp_detach_db [ @dbname = ] 'dbname'
             [ , [ @skipchecks = ] 'skipchecks' ]


In the above, the parameters to the stored procedure are as follows:

    •[@dbname =] 'dbname' is the database name. 'dbname'is nvarchar(128), a default value is NULL.
    •[@skipchecks =] 'skipchecks' The 'skipchecks' parameter indicates will be can UPDATE

STATISTICS run or skipped. The 'skipchecks' is nvarchar(10), a default value is NULL. If 'skipchecks' is true, UPDATE STATISTICS is skipped. If 'skipchecks' is false, UPDATE STATISTICS is run.
The following example detaches the pubs database and runs UPDATE STATISTICS on all tables before detaching:

Kod:
EXEC sp_detach_db 'pubs', 'false'


Attaching a Database
When you attach a database, you must specify at least the name and physical location of the primary data file. If one or more of the database files have changed location since the database was detached, you must specify the name and physical location of these files in addition to the primary file.

To attach SQL Server 2000 database, you can use the sp_attach_db system stored procedure. The syntax for sp_attach_db system stored procedure is as follows:

Kod:
sp_attach_db [ @dbname = ] 'dbname',
             [ @filename1 = ] 'filename_n' [ ,...16 ]


In the above command:

    •[@dbname =] 'dbname' is the database name. dbname is nvarchar(128), a default value is NULL.
    •[@filename1 =] 'filename_n' is the database file name. filename_n is nvarchar(260), a default value is NULL. There can be up to 16 file names specified.

This is the example to attach the pubs database which contain two files pubs.mdf and pubs_log.ldf from the C:\MSSQL\Data directory:

Kod:
EXEC sp_attach_db @dbname = 'pubs',
     @filename1 = 'C:\MSSQL\Data\pubs.mdf',
     @filename2 = 'C:\MSSQL\Data\pubs_log.ldf'


Attaching a Single-File Database
A single-file database is a database that has only one data file. When a database comprises only one data file , the database can be attached to an instance of SQL Server 2000 without using the transaction log file. When the data file will be attached, SQL Server will create a new transaction log file automatically.

To attach a single-file database, you can use the sp_attach_single_file_db system stored procedure. The syntax for sp_attach_single_file_db system stored procedure is as follows:

Kod:
sp_attach_single_file_db [ @dbname = ] 'dbname'
    , [ @physname = ] 'physical_name'


    •[@dbname =] 'dbname' is the database name. 'dbname' is nvarchar(128), a default value is NULL.
    •[@physname =] 'phsyical_name' is the database file name. 'phsyical_name' is nvarchar(260), a default value is NULL.

This is the example to attach only one data file of the pubs database from the C:\MSSQL\Data directory:

Kod:
EXEC sp_attach_single_file_db @dbname = 'pubs',
     @physname = 'C:\MSSQL\Data\pubs.mdf'


Troubleshooting Lost Users
When you move a database to another server and there are existing users in the detached database, you can lose users after attaching the database on the new server. For example, if you move the Sales database from the Product server to the Test server (for the test purposes) and the user Alex exists in the Sales database, you should manually link the relationship between the Alex user and the appropriate login on the Test server.

You can use the sp_change_users_login system stored procedure to link the specified user in the current database to the appropriate login. The following example links the user Alex in the current database to the Alex login:

Kod:
EXEC sp_change_users_login 'Update_One', 'Alex', 'Alex'


See SQL Server Books Online to get more information about the sp_change_users_login stored procedure.

Tekst pochodzi ze strony
http://www.databasejournal.com/features ... Server.htm

_________________
Skontaktuj się z Ekspertem | Zamów dodatek

tel. 22 7 538 538
ekspert@mojaSymfonia.pl
http://www.mojaSymfonia.pl


2011-04-21, 13:13
Wyświetl profil
Ekspert
Ekspert
Awatar użytkownika

Rejestracja: 2008-04-18, 18:52
Posty: 5169
Pomógł: 59
Post 
Moze prosciej..... :)

Wyjdz z FK i innych, zatrzymaj commona jesli masz

Wejdz do SQL management studio znajdz tam te swoją baze kliknij w nia prawym wybierz properties /files - zapamietaj gdzie sa pliki tej bazy......

potem znow w nia prawym - poszukaj detach - wykonaj....

wejdz do katalogu z plikami bazy (zazwyczaj to 2 pliki ldf i mdf) przenies je na inny dysk np D:

Wroc do SQL manag - na galezi databases - kliknij prawym - wybierz attach - podaj gdzie przegrales te pliki....

No i najwazniejsze - zrob backup - zanim zaczniesz to powyższe robic :) :) :)


2011-04-21, 14:23
Wyświetl profil
Wyświetl posty nie starsze niż:  Sortuj wg  
Odpowiedz w temacie   [ Posty: 3 ] 
   Podobne tematy   Autor   Odpowiedzi   Odsłony   Ostatni post 
Na tym forum nie ma nowych nieprzeczytanych postów. Przeniesienie bazy danych ze starej Symfonii

w Techniczne

Marek74

1

4094

2010-06-07, 23:08

wrob Wyświetl najnowszy post

Na tym forum nie ma nowych nieprzeczytanych postów. Mała Księgowość przeniesienie danych do istniejącej bazy

w Programy Księgowe

michal.polewka

0

1746

2021-05-25, 11:39

michal.polewka Wyświetl najnowszy post

Na tym forum nie ma nowych nieprzeczytanych postów. Załączniki Zmiana bazy danych z Prevasive na SQL

[ Przejdź na stronę: 1, 2 ]

w Techniczne

wojoxxx

24

13147

2011-04-13, 15:45

adokladny Wyświetl najnowszy post

Na tym forum nie ma nowych nieprzeczytanych postów. Struktura bazy danych - wersja MS SQL

w Techniczne

MBOROW

4

5037

2016-01-20, 14:31

mastercomp Wyświetl najnowszy post



Kto jest online

Użytkownicy przeglądający to forum: Nie ma żadnego zarejestrowanego użytkownika i 13 gości


Nie możesz tworzyć nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz dodawać załączników

Szukaj:
Przejdź do:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Support forum phpbb by phpBB Assistant