BCP Utility vs SQL Server compatibility - sql-server

I am planning to use the BCP utility for bulk import & export from SQL Server. So just want to know if is there a compatibility matrix of versions between BCP Utility & SQL Server.

There is not and there is not need: bcp will be fine.
Only be careful with "Native Data File Support". From documentation:
In SQL Server, the bcp utility supports native data files compatible
with SQL Server versions starting with SQL Server 2000 (8.x) and
later.
And, of course, you must have compatible data types.
I did this a ton of times.

Related

MS SQL Server 2019 export db from commandline

I need to export data from my MS SQL Server 2019, but I need to do so from the command line.
How can I achieve this? What are the best practices for exporting schemas?
As per comments below, I wanted to just use the mdf file but was encouraged not to.
Use the bcp command line utility that allows for exporting data to flat files from tabular.
The utility is part of the sql server setup and is available on your system
https://learn.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-ver15

How to make SQL Server 2008 compatible to SQL Server 2000

I have to run the backup of SQL Server 2000 in SQL Server 2008.
While restoring the database from the .bak file, I got the error
specified cast is invalid
After doing google I feel there is compatibility issue. Therefore I want to make the database compatibile to SQL Server 2000.
And run the below query
ALTER DATABASE DBNAME
SET COMPATIBILITY_LEVEL = 80
but nothing help. Any help will be appreciated.
You CANNOT do this - you cannot attach/detach or backup/restore a database from a newer version of SQL Server (like 2008) down to an older version (like 2000) - the internal file structures are just too different to support backwards compatibility.
You can either get around this problem by
using the same version of SQL Server on all your machines - then you can easily backup/restore databases between instances
otherwise you can create the database scripts for both structure (tables, view, stored procedures etc.) and for contents (the actual data contained in the tables) either in SQL Server Management Studio (Tasks > Generate Scripts) or using a third-party tool
or you can use a third-party tool like Red-Gate's SQL Compare and SQL Data Compare to do "diffing" between your source and target, generate update scripts from those differences, and then execute those scripts on the target platform; this works across different SQL Server versions.
Changing the compatibility level will get you closer to SQL 2000 but there were breaking changes (more likely they came in when 2005 did), unfortunately you will need to find where you get things that break and manually fix them.
Ed

How to Import Oracle .DMP file into SQL Server?

I have a .dmp file (oracle data) and I have to import this file into SQL Server 2008 R2. I tried google but get no clear solution. Oracle is on other machine and SQL Server is on other machine. This .DMP file has only tables and data only nothing else.
Any body has any idea?
You can't get there from here. The files that the Oracle export utility (classic or DataPump) generate (which, by convention, frequently use the DMP extension) are proprietary binary files. They can only be consumed by the Oracle import utility (classic or DataPump) which will only allow you to load the data into another Oracle database.
You could load the DMP file into a new Oracle database but then you'll still need to move the data from Oracle to SQL Server. It may well be easier to ignore the DMP file and pull directly from the original Oracle database. There are a variety of tools that can be used to move data from an Oracle database to a SQL Server database. If you want SQL Server to control the process, you could SQL Server Integration Services (SSIS). You could also create a linked server in SQL Server that references the Oracle database and write queries against the Oracle database via that connection. If you wanted Oracle to push the data, you could also use the Oracle Transparent Gateway with Heterogeneous Services to create a database link from Oracle to SQL Server and issue SQL against the remote SQL Server database.
There is a nice StackOverflow thread on moving data from Oracle to SQL Server. The SSIS logic is extremely similar if you're pulling from Oracle to SQL Server or pushing from SQL Server to Oracle.
Oracle Dumps is not readable by SQL.
Simply it cannot be, But you have different solutions
SQL server integration services (SSIS)
Link between oracle and SQL (Oracle Gateway) but it works with SQL Ent.
Export the data from oracle in a delimited format and insert it into SQL, but it will takes time if data is huge.
When I faced with the same problem, I tried to investigate the format manually (in my case the dump file was generated by Oracle EXP). I found that:
Table definitions come as Oracle CREATE TABLE statement that can be converted into MS SQL format easily
Most kind of data ca be extracted quite easy (text goes "as is", numeric values are stored according to IEEE 754 format)
LOBs are stored in quite complicated way, I failed to recognize it
Then I found the tool that was able to do my migration task: https://www.convert-in.com/ord2mss.htm
Vendor said that it can migrate both exp and expdp to sql server, but I have tested it on EXP format only.

How do I bring an Oracle BLOB into SQL Server?

I have two databases: Oracle 10G and SQL Server 2000.
Inside the Oracle database, I have several MS Word documents stored as BLOBs. What I need to do is extract the files from Oracle and place them into SQL Server. I am curious as to how I do this?
I have heard something about DTS but not sure if that is something to look into.
In sql server 2000, your choices for blob storages is either binary/varbinary or image.
binary/varbinary can be used if the blob is <=8000bytes and image should be use when blob is larger than 8000 bytes.
Personally I would use perl DBI to extract the files from oracle and insert them into sql server since I'm comfortable with perl.
You can also use oracle's hsodbc to make a link between oracle and the sql server and attempt to insert data from one to the other.
If you are more comfortable in sql server then DTS is a option. I'm not sql server person so I would favor a different approach.

Releasing a database build consistently via isql

I am releasing a database build to SQL Server 2000 via a batch file using isql. The batch file is used so multiple files are released consistently to different SQL Servers (development, test, live).
The SQL Server uses ANSI code page 1252 (from sp_helpsort) but isql is an OEM client using code page 437. This means that all extended characters (with ASCII code > 128) are converted when the scripts are run, leading to inconsistent results when characters like “£” are included in the script. Differences are explained in this Microsoft knowledgebase article.
Possible solutions are: -
Save the script using Unicode and
use osql.
Turn off the AutoAnsiToOem setting using the SQL Server Client Network Utility (that writes a registry key).
Both these options rely on various people doing things consistently. All have to select the same code page option when saving a file OR all people performing the builds have to have the same option set for AutoAnsiToOem.
Is there a way to force the use of a code page either in the SQL script OR in the batch file that calls it, so that the build is always released consistently, regardless of how the file is saved or the various settings of whoever performs the release?
isql is obsolete. It isn't included in SQL Server 2005 or later, because it uses the DB-Library connections, which are also obsolete. For the reasons why, and the effects this has, see Connecting Early Version Clients to SQL Server 2000.
osql uses ODBC connections to connect to SQL Server. For completeness, this has been supplemented by sqlcmd in SQL Server 2005, which uses OLE DB with the SQL Native Client provider.
Further to the accepted answer, I have tested using sqlcmd against a SQL Server 2000 database and it works. You obviously have to run sqlcmd from a machine with the SQL Server 2005 client tools installed.

Resources