I apologize if I have a fundamental misunderstanding but basically I wanted to know if there is a way to go directly from ONLY .bcp files to creating a SQL Server database. I have not dealt with .bcp files before and have no format files or know anything about the schema of the database we are trying to re-create. Is there some sort of utility wihtin SQL server management studio that can do what I am asking or do I just not have enough resources to create a database out of this data. Any help is appreciated.
BCP only builk insert the data. So you need to have a blank database first to insert to with the bcp files.
You can use the bcp command line to run with those bcp files. But you need to know the order of the files to run if the db has FKs.
Related
I have heard about .sql file in SQL Server, But i don't know what it holds also is this file helpful for recovery purpose?
.sql file is the script file of sql server that contain the all command of particular database...
Including
- Create
- Select
- Insert
- Store Processor
- View
SQL, or Structured Query Language files contain SQL code used to modify the contents of a database. They may contain statements for creating or modifying database structures, insertions or updates, deletions.
Your result will be based on what your code in .SQL says.
I've created the structure of my database first in PhpMyAdmin and exported it to a .sql file.
Now I'm looking everywhere in SQL Server Management Studio where I can import/add the data in a new database.
Does anybody where to look or what to click?
I'm using the 2014 version (CTP2)
If you have a .sql file which contains SQL statements, you can just copy and paste the contents (or open the file in a query window) and run it. This assumes it has all of the create table etc. statements to create the schema/structure and not just insert statements for the data.
Check the top of the file to make sure that it is first selecting the correct database, if not add a USE statement to select the correct database.
You didn't say how big the file was, but if it is quite large and has the insert statements (data as well as schema), then you'll probably want to run by CLI using sqlcmd command. Much faster and SSMS won't freak out.
Another alternative option to running the .sql file/code is to set up a data source for mysql and just use odbc to access the database itself.
Bear in mind that there are real and very annoying differences between mysql and t-sql that can make migration a pain. If you're just creating a few tables, it may not be an issue, but if there are a ton of tables with lots of fields of different data types, you may run into issues.
If you are looking to import table structure, you can copy-paste the content and run inside SSMS in a query window. Beware of syntax differences with MySQL and SQL Server. You will most likely get errors. You need to convert your SQL script from MySQL dialect to SQL Server dialect (or just add them manually if they are not too many). If you set the databases to a SQL standard-compatibility mode at the very beginning, you will have much less trouble.
If you are ONLY looking just to import the data into existing tables inside the SQL Server only, you can do the same (i.e. copy-paste and run in query window). You will have less trouble with that.
Open the server, open "Databases" and right click the database, go to "Tasks" and then Import Data...
I have had the most 'trouble free' success importing to SQL via a flat file method (comma delimited .txt file), the only stipulation when creating a flat file (i.e from Access) make sure the text identifier is set to {none} and not "".
To import the file: in the SQL Server Management Studio right click on Databases and create a new database. Then right click on the new database -> Tasks -> Import Data... The import window opens: in the DATA SOURCE option select Flat File Source and select the .txt file...click NEXT. In the DESTINATION field select SQL Server Native Client 11.0 and go through the import process. This worked very well for me.
I have 2 DB with the same schema on different servers.
I need to copy data from table T to the same table T in test database in different server and network.
What is the easiest way to do it?
I heard that data can be dumped to flat file and than inserted into database. How does it works?
Can this be achieved using sqlplus and oracle database?
Thank you!
Use Oracle export to export a whole table to a file, copy the file to serverB and import.
http://www.orafaq.com/wiki/Import_Export_FAQ
You can use rsync to sync an oracle .dbf file or files to another server. This has problems and syncing all files works more reliably.
For groups of records, write a query to build a pipe-delimited (or whatever delimiter suits your data) file with rows you need to move. Copy that file to serverB. Write a control file for sqlldr and use sqlldr to load the rows into the table. sqlldr is part of the oracle installation.
http://www.thegeekstuff.com/2012/06/oracle-sqlldr/
If you have db listeners up on each server and tnsnames knows about both, you can directly:
insert into mytable#remote
select * from mytable
where somecolumn=somevalue;
Look at the remote table section:
http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_9014.htm
If this is going to be an ongoing thing, create a db link from instance#serverA to instance#serverB.
You can then do anything you have permissions for with data on one instance or the other or both.
http://psoug.org/definition/CREATE_DATABASE_LINK.htm
I came across this blog post when looking for a quicker way of importing data from a DB2 database to SQL Server 2008.
http://blog.stevienova.com/2009/05/20/etl-method-fastest-way-to-get-data-from-db2-to-microsoft-sql-server/
I'm trying to figure out how to achieve the following:
3) Create a BULK Insert task, and load up the file that the execute process task created. (note you have to create a .FMT file for fixed with import. I create a .NET app to load the FDF file (the transfer description) which will auto create a .FMT file for me, and a SQL Create statement as well – saving time and tedious work)
I've got the data in a TXT file and a separate FDF with the details of the table structure. How do I combine them to create a suitable .FMT file?
I couldn't figure out how to create the suitable .FMT files.
Instead I ended up creating replica tables from the source DB2 system in SQL Server and ensured that that column order was the same as what was coming out from the IBM File Transfer Utility.
Using an Excel sheet to control what File Transfers/Tables should be loaded, allowing me to enable/disable as I please, along with a For Each Loop in SSIS I've got a suitable solution to load multiple tables quickly from our DB2 system.
I want to copy the ms access database(.mdb) to sql server database(.mdf). I did it with sql server Import and export data service. But I want it copy the data regularly or a specific time. Is it possible or not. I have tried to create a batch file
copy /y "E:\Dinesh Work\for-reports.mdb" "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\for-reports.mdf"
but it gives the following error:
The process cannot access the file because it is being used by another process.
I have same tables in my sql server database as msaccess database. Is there any solution with batch file or something else.
Any suggestion will be appreciated.
Thanks in Advance.
This sounds like you want to use the Access database to edit the data in the SQL Server database.
Is that correct?
If yes, do you really need to copy the data?
You could also link from Access to the SQL Server tables.
This way, you have tables in Access that look like normal local Access tables, but they are really just links to SQL Server tables. You can edit data in these tables in Access, but you are actually writing directly into the SQL Server database.
Here are some examples how to set this up:
Link to SQL Server data
Access to SQL Server: Linking Tables
MDB and MDF files are wildly different types. You can't just copy them.
You might try setting up an SSIS task to do a regular data transfer - something like ETL if you're familiar with that term.
EDIT: The reason you're seeing the file locked error is because SQL Server maintains that lock on the MDF file while the database is running. In order to move or copy it you need to take that particular database offline.
As #Yuck said, you can not just copy the file and rename it, you need something like ETL or just a tool to export data.
I did xportdsl to copy from a h2database to a mssql and mssql to oracle
http://code.google.com/p/xportdsl/
I used gorm and a hacky dsl that worked and it is still working
You can script a bat file to execute something like this java -jar xportdsl.jar test001.txt