how can I export a SQL Server table to Mysql ? I guess I need to export a .sql file compatible...
thanks
Solution: Right Click on database Icon > Tasks > Generate Scripts
follow istructions and export a specific table as .cvs
One way is to BCP the data out into a CSV or some other format flat file and import those into mySQL.
Another way is to use a SSMS add-in called SSMS Tools Pack which has the option to generate insert statements.
please see the below link, maybe it can help you.
MSSQL to MySQL
Related
I have SQL Server installed in Ubuntu 18.04 LTS but I am trying to generate a backup or script for a specific table data for example products table. I do not know how to generate a script or backup for product table because I have no GUI because it is a virtual machine server. This is how I access to server database:
I cannot find information in the internet how to generate a script for a specific table since most of the documentation shows how to generate a script using a GUI, but I am not. How do I solve this?
You can use the bcp command to import/extract data from your db in a shell script. Ref: https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-migrate-bcp?view=sql-server-ver15
Below link talk about this solution and export data to csv file
Export table from database to csv file
I'm trying to import a flat file into SQL Server and I'm having some issues. The column delimiter is ;~ and the row delimiter is |~. I'm using the SQL Server Import and Export Wizard but keep getting errors. Have any of you every had a similar issue? I think I'm doing it wrong from the start of the wizard. Can any of you talk me through the steps. Thanks.
Here is the import error:
It's a familiar-sounding problem, but difficult to be sure without a data file to play with - perhaps one of these posts has your answer:
Text was truncated or one or more characters had no match in the target code page including the primary key in an unpivot
Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column
SQL Server Import wizard fails with incomprehensible message
Thanks to all of you who responded.
My solution was to first create the tables in SQL Server using the varchar(max) data type for each column and then executing a BULK INSERT statement. Definitely not ideal, but the goal was not to create a database but rather delimit the data so I could upload it to an application. Thanks again.
Given the DAT file and the DDL file for each table in a DB2 database, can I import this data to SQL Server? I have no access to the original server or any copy of a DB2 server so connecting to a live instance isn't an option.
Can I do this without a live instance of DB2 or should I go back to the client and ask for CSV files? Is there a procedure or tool that makes this process smoother? I've tried to find a file-based connection string to use to connect to a set of DB2 files with no luck. I've also tried SwissSQLDB2ToSQLServer and SqlLinesData to see if they have a file-based option built in.
OK, given the comment above, you can't import DB2's container files (DAT, LRG, or anything else) directly. You need a CSV or equivalent. Yes, one way to get this is run the EXPORT utility on a live DB2 database. HTH!
I know PhpStorm can connect to a database and work with it. Is it possible to export the database to a myDb.sql file with phpstorm?
As of this writing (2018.1), right clicking on a database gives you the option to "Dump with 'mysqldump'".
No, in phpstorm there is no such option.
You only can export single Tables from the Database by clicking on ONE single Table (doesn't work if you mark more than one Table) and open Mouse-Menu (right mouseclick). There you choose "Save to File..." an Choose what you need (for example " SQL Insert Statements".
For having a good DB-Client to manage the whole Stuff, use DBeaver (Standalone Version), or MysqlWorkbench.
I preffer DBeaver.
As far as I know, you can export data from tables. Some types of database allows you to Copy DDL of any node.
More at
http://blog.jetbrains.com/phpstorm/2013/10/database-tools-and-sql-editor-changes-in-phpstorm-7/ section Exporting Data
http://www.jetbrains.com/phpstorm/webhelp/database-tool-window.html
In the latest editions you can right click on a Database and dump to file. It exports to individual files per table.
As of phpstorm 2019.2.5 you can
right-click your database/schema > Dump To FIle(s) > SQL Inserts
to export you DB Structure and Data, see below image for ref.
I need to migrate a database from Postgres 7 to SQL Server 2008. I am familiar with the SSIS Import and Export wizard but I am stumped about how to define the data source or define the data provider.
What is the best way to migrate Postgres to SQL Server, and how do I define data sources/drivers for postgres?
I was having problems using the Import Wizard in SQL Server 2008 R2 to import tables from PostgreSQL. I had the PostgreSQL ODBC driver installed, so for the Data Source in the Import Wizard I chose ".Net Framework Data Provider for Odbc" and supplied the DSN name for my PostgreSQL database. The wizard found the tables okay, but when I went to perform the import I got the error
Column information for the source and destination data could not be retrieved.
“Billing” -> [dbo].[Billing]:
– Cannot find column -1.
I found the solution in the Microsoft blog post here. Apparently the problem is that various ODBC drivers use different attribute names when reporting column metadata. To get the import to work I had to edit the "ProviderDescriptors.xml" file, which was located at
C:\Program Files\Microsoft SQL Server\100\DTS\ProviderDescriptors\ProviderDescriptors.xml
In the ...
<dtm:ProviderDescriptor SourceType="System.Data.Odbc.OdbcConnection">
... element I had to change the attributes from ...
<dtm:ColumnSchemaAttributes
NameColumnName = "COLUMN_NAME"
OrdinalPositionColumnName="ORDINAL_POSITION"
DataTypeColumnName = "TYPE_NAME"
MaximumLengthColumnName = "COLUMN_SIZE"
NumericPrecisionColumnName = "COLUMN_SIZE"
NumericScaleColumnName = "DECIMAL_DIGITS"
NullableColumnName="NULLABLE"
NumberOfColumnRestrictions="4"
/>
... to ...
<dtm:ColumnSchemaAttributes
NameColumnName = "COLUMN_NAME"
OrdinalPositionColumnName="ORDINAL_POSITION"
DataTypeColumnName = "TYPE_NAME"
MaximumLengthColumnName = "LENGTH"
NumericPrecisionColumnName = "PRECISION"
NumericScaleColumnName = "SCALE"
NullableColumnName="NULLABLE"
NumberOfColumnRestrictions="4"
/>
That is, I had to tweak the MaximumLengthColumnName, NumericPrecisionColumnName, and NumericScaleColumnName attribute values to "LENGTH", "PRECISION", and "SCALE", respectively.
Once that change was made the import from PostgreSQL to SQL Server ran successfully.
I wish you the best of luck in trying to import from PostgreSQL into SQL Server using SQL Server Import and Export Wizard. However, I have read numerous message board threads with people having trouble getting it to work. For example:
Import Data from Postgresql to SQL Server 08 Error
Here is the most helpful thread that I have found on the topic:
Import data from postgreSQL into SQL server 2005
To help someone who might be trying to achieve similar goal as mine. Instead of selecting the “PostgreSQL OLE DB Provider” in the data source drop down menu of SQL Server Import and Export Wizard, select “.Net Framework Data Provider for Odbc”
Then you have to make a DSN and provide a ConnectionString. Following ConnectionString worked for me
Driver={PostgreSQL};Server=localhost;Port=5432;Database=TestMasterMap;Uid=postgres;Pwd=;
To make a DSN you have to go into Administrative Toolsà Data Sources (ODBC) and create a user DSN. Once this is done you can supply the DSN name in the DSN text box of SQL Server Import and Export Wizard.
One commenter claimed that it worked, but that he got "Out of memory while reading tuples" errors on big tables. So for tables with more than 3 million rows, he had to break the import up into 3 million row chunks.
Also, there's a link to the native .NET provider for PostgreSQL in that thread.
Personally, if this is something that I only had to do once, and if I understood the schema and the data fairly well, I would try:
export the data from PostgreSQL as flat files
create the schema in SQL Server (without PKs or constraints)
use the SSIS Import/Export Wizard to import the flat files
then create PKs and necessary constraints
It might take you less time to do the above than messing with SSIS Import/Export Wizard and PostgreSQL for days (but it would be nice if those tools worked!)
As I finished commenting the answer above, I thought of trying SQL WorkbenchJ; it has a datapump feature that worked pretty well for me. I managed to export data from my PostgreSQL database to an SQL server instance.
Those who'd like to run this in batch mode (via shell), here's how to do it: Google Groups Thread. The WbCopy command mentioned on the discussion isn't really documented anywhere I could find, but you can generate one through the datapump interface and then change whatever you need.
To give a little more practical example of how you can achieve what's described in marked answer; you can export from PostgresQL to flat files then use bcp Utility to import in SQL Server.
e.g. in a .bat file, for a single table (and you need to have the table already created in the destination SQL DB):
#echo off
set DbName=YOUR_POSTGRES_DB_NAME
set csvpath=C:\PATH_TO_CSV\CSV_NAME.csv
set username=YOUR_POSTGRES_DB_USERNAME
:: Export to CSV, note we're using a ~ delimiter to avoid issues with commas in fields
psql -U %username% -d %DbName% -c "COPY (select * from SOURCE_TABLE_NAME) TO STDOUT (FORMAT CSV, HEADER TRUE, DELIMITER '~', ENCODING 'UTF8');" > %csvpath%
:: Import CSV to SQL Server
set logpath=C:\bcplog.txt
set errorlogpath=C:\bcperrors.txt
set sqlserver=YOUR_SQL_SERVER
set sqldb=YOUR_DB_NAME
:: page code 65001 = UTF-8
bcp DESTINATION_TABLE_NAME IN %csvpath% -t~ -F1 -c -C65001 -S %sqlserver% -d %sqldb% -T -o %logpath% -e %errorlogpath%