Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have attached a few databases to my sql server instance. I wonder about the different behavious, while DBs have been attached the same way.
When I try to copy the folder that contains the files, some files do not copy and give error that file is in use, while some other, attached to the same instance and in the same folder, copy without any problem.
Please advise what is the difference?
Thanks
The proper way to copy the files are as follows, this only applies to user databases:
To move a data or log file as part of a planned relocation, follow these steps:
Run the following statement.
ALTER DATABASE database_name SET OFFLINE;
Move the file or files to the new location.
For each file moved, run the following statement.
ALTER DATABASE database_name MODIFY FILE ( NAME = logical_name, FILENAME = 'new_path\os_file_name' );
Run the following statement.
ALTER DATABASE database_name SET ONLINE;
Verify the file change by running the following query.
SELECT name, physical_name AS CurrentLocation, state_desc FROM sys.master_files
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
My PC is running slow. I want to format it but my asp project database is in SQL Server 2008, I know how to backup the database but a friend of mine told me it won't be restored if you format your system, backup only gets restored if you use same computer, SQL Server. I'm really confused, but I have to format my PC in any case. Can anyone tell me what I need to do to save my database?
Right Click on your Database which you want to take as backup .Then Go to Task>Backup
While doing backup select the drive which you are not going to Format and keep back there.
For Restoring. Right Click on Databases{Top one} and select Restore option.
Select From Device option.
While Restoring Select the file which you created as backup by browsing. If you are not able to find that backup file, then make sure you have specified Files Type as All.
and yes your Friend is wrong :)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I want to generate portable script file of a SQL Server database by using backup (.bak) so that we will be able to create database (with all objects and data) without backup file.
I don't want to restore backup file to SQL Server Management Studio to achieve it.
Is it possible?
How can I achieve it?
Follow the normal procedure to restore DB then on the last screen generate script rather than clicking OK:
Then you can use the same script or modify it to do what you are after.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am working on a micro-finance software. A module 'special savings' i added with the software but before that the client did it manually (There was no software posting). So i like to develop a conversion tool to take the previous manual entry. But all member information and organization information in previous SQL db, where i develop the tool in Access DB. So i need to import some data with same table name to Access from SQL. I want to do the importing against a button instead of any wizard. So i want to export all data of my required tables including table name to my access file from SQL.
If you have same table schema available in Access DB, you can
read all data from Sql Server and write into Access tables.
Create a DTS package to do the export and call it when user clicks on "Data Import"
Create a linked table in Access then use
INSERT INTO AccessTable (Column1, Column2, ...)
SELECT Column1,Column2,... FROM SqlServerTable
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have a remote database on a shared host, and I can connect to it through SSMS if I specify the db name in advanced options. If I try to expand the "Databases" section of the object explorer, it times out and won't list the available databases.
I need to back it up locally, so scripting it seems to be the only way. However, you need to right-click the db name to do that, which isn't possible. Is there a SQL script that I can run to export a db's structure and data?
Usually in the control panel provided by the hosting company, there's a "Database" option, and if you go to that, you can find a "Backup Database" (sub)option.
Usually this will back up the database to a folder called "db" or "data" off the root folder of your hosting account. Then you can connect with FTP & download (or upload & restore from there).
An alternative might be to use the "BACKUP DATABASE TO DISK='XXXXXX'" SQL statement. But then you have to know the XXXXXX value to use (and this depends on whether you have the permission to execute this action). The XXXXXX would be the local path of your hosting account, which would probably be something like:
C:\domains\yourdomain.com\db
(...depending on how the hosting company has that set up).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I have a SQL Server 2008 Database running on Express. I want to copy only the schema and data to an exact copy of this database. How can I do it and what are the steps involved?
My original database has a huge log file, so i do not want to copy that.
P.S: I do undersand that since this is a LIVE database, there could some amount of live data that will not be copied. I am OK with that.
You could use the "Generate Scripts" option to create a sql file with all of your schema and data. See this MS article: http://msdn.microsoft.com/en-us/library/ms178078.aspx