Can we have 2 versions of bulk copy utility on the same server? - ssis

We have 2 SSIS packages.
One of the packages needs bcp version 12 and the other needs bcp version 15.
Can we have 2 versions of the bulk copy utility on the same server.

Yes, BCP allows for multiple installations on a machine. For example, on my machine
C:\>cd "Program Files"
C:\Program Files>dir /s /b bcp.exe
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\bcp.exe
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\bcp.exe
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\bcp.exe
C:\Program Files>cd "\Program Files (x86)"
C:\Program Files (x86)>dir /s /b bcp.exe
C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\bcp.exe
I can see that I have the 64 bit version of bcp that corresponds to 110 (SQL Server 2012), 130 (SQL Server 2016), and .. I have no idea what 170 is as 2019 is 150. Whatever, we can ask the utility itself what version it is and they report back that I have version 11, 14 and 15 installed
C:\Program Files (x86)>"C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\bcp.exe" -v
BCP - Bulk Copy Program for Microsoft SQL Server.
Copyright (C) Microsoft Corporation. All Rights Reserved.
Version: 15.0.2000.5
C:\Program Files (x86)>"C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\bcp.exe" -v
BCP - Bulk Copy Program for Microsoft SQL Server.
Copyright (C) Microsoft Corporation. All Rights Reserved.
Version: 14.0.3445.2
C:\Program Files (x86)>"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\bcp.exe" -v
BCP - Bulk Copy Program for Microsoft SQL Server.
Copyright (C) Microsoft Corporation. All Rights Reserved.
Version: 11.0.2100.60
The only "trick" is to ensure when you invoke them that you provide the correct path otherwise, the first entry in the users PATH windows environment variable will take precedent.

Yes, you can Bulk copy the data from one server to another instance server.
for more details for BCP utility.
follow this link.
https://learn.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-ver16&redirectedfrom=MSDN&viewFallbackFrom=sql-server-2014

Related

How to attach database in SQL Server 2008 which was created in SQL Server 2012

I have two database files named as .mdf and .ldf which are created in SQL Server 2012 and now on my pc I installed Visual Studio 2010 and SQL Server 2008 Express.
When I try to attach these database files to SQL Server 2008 it gives me error.
The database 'C:\PROGRAM FILES\MICROSOFT SQL
SERVER\MSSQL10.SQLEXPRESS\MSSQL\DATA\CMS_DB.MDF' cannot
be opened because it is version 706. This server supports version 655
and earlier. A downgrade path is not supported.
Could not open new database 'C:\PROGRAM FILES\MICROSOFT SQL
SERVER\MSSQL10.SQLEXPRESS\MSSQL\DATA\CMS_DB.MDF'. CREATE
DATABASE is aborted.
An attempt to attach an auto-named database for file C:\Program
Files\Microsoft SQL
Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\CMD_DB.mdf failed. A
database with the same name exists, or specified file cannot be opened,
or it is located on UNC share.
When open database in ssms 2008 then error :
Attach database failed for Server 'MATRIX-PC\SQLEXPRESS'. (Microsoft.SqlServer.Smo)
Additional information:
An exception occured while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
The database 'C:\USERS\RAJ\DESKTOP\COLLEGE MANAGEMENT SYSTEM(.NET 4.5)\ COLLEGE MANAGEMENT SYSTEM\BIN\DEBUG\CMD_DB.MDF' cannot be opened because it is version 706.
This server supports version 655 and earlier. A downgrade path is not supported.
Could not open new database 'C:\USERS\RAJ\DESKTOP\COLLEGE MANAGEMENT SYSTEM(.NET 4.5)\COLLEGE MANAGEMENT SYSTEM\BIN\DEBUG\CMD_DB.MDF'. CREATE DATABASE is aborted.
(Microsoft SQL Server, Error: 948)
No, you can only move forward.
This means, you can restore the database from 2005 or 2008 to 2012 version but can not do it in reverse order. The next most popular question I receive is if we can’t restore a SQL Server 2012 database to earlier version what is the next best option?
I have personally faced this issue once before and I had manually created T-SQL script using Script and Data Generator Wizard in SQL Server 2012 and rebuild my database in
SQL Server 2008R2. If you have many different databases which you want to address, you can use SSIS to
automate the script generation.
As noted if you want to access a 2012 db from 2008 you will have to migrate the database back to 2008. This will only be possible if you have not used 2012-specific features in the db. If you have and still want to perform the migration you should first try and identify these where they occur and fix those first.
As noted above one option is to generate T-SQL scripts and use these to regenerate the db in 2008. However for a large db this could be time consuming and hard work to get to actually work.
A better option than using the SSMS scripting wizard is to use a similar tool available on Codeplex called SQL Database Migration Wizard - http://sqlazuremw.codeplex.com/releases/view/32334. You want the latest version v4.x to work with SQL Server 2012.
The tool is originally intended to be used for migrating databases between SQL Server and Azure. However the tool works just as well between SQL Server 2012 and SQL Server 2008. The trick is to set SQL Server rather than Azure as the target in the advanced options.
The reason this is a better option than the SSMS scripting wizard is that it uses BCP for the data transfer rather than TSQL and so is much more efficient. I migrated a 7GB database in about 2 hours with this with most of the time spent drinking tea while the machine worked away. Importantly, it all just worked with no requirement for me to start editing files to fix problems like too many commands, timeouts etc.

How do I overcome Microsoft SQL Server, Error: 1827: restore failed...exceed licensed limit?

I'm attempting to extract data from a SQL Server backup provided by vendors with whom we no longer work.
I only need data from some tables, but I need to examine the database structure to determine exactly what I need.
This is the only use I have for SQL Server and I don't what to buy in big.
I tried SQL Server Express to restore the .bak file locally and received the error:
Restore failed...
CREATE DATABASE or ALTER DATABASE failed because the resulting cumulative database size would exceed your licensed limit of 4096 MB per database.
RESTORE DATABASE is terminating abnormally. (Microsoft SQL Server, Error: 1827)
I am having difficulty determining what alternative approach or minimum license I need to purchase to get me past this database size limit. The database seems to be only marginally over the limit.
I used RESTORE FILELISTONLY, HEADERONLY and LABELONLY commands to extract what metadata I could.
HEADERONLY
BackupSize: 4958099456
I'm running SQL Server Express 2008 on a Win XP 32 bit platform, which could be part of my problem.
The version I'm running:
Microsoft SQL Server 2008 (SP3) - 10.0.5500.0 (Intel X86)
Sep 22 2011 00:28:06
Copyright (c) 1988-2008 Microsoft Corporation
Express Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3)
Can anyone tell me the least expensive and most efficient way out of this problem?
Thanks,
Neale
SQL Server 2008 R2 or 2012 Express have a 10GB limit so you can use one of those.

Find SQL 2008 setup.exe for command line uninstall

I'm writing a little .Net app that stores data in a named SQL instance. I need to be able to uninstall the instance programatically. It's easy enough to call setup.exe with the uninstall parameters (I figured them out in this post: https://stackoverflow.com/questions/16068490/how-do-i-remove-an-sql-2008-instance-from-command-prompt-w-o-removing-the-server), but the hard part is reliably finding setup.exe.
I've found copies of setup.exe in
C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\
C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2\
and finally I found "setup100.exe" in
C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2\x86
How do I know which one to use? So far I've found I have to use the one in:
C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\
but I'm still not sure why I found a setup.exe in that SQLServer2008R2 folder.
There are ways to query for the uninstall command but they're unreliable when you uninstalling a named instance... :(. Win32_Product works but it breaks things when it's called. Windows.Installer logs everything that was ever installed so if I've had a few versions of SQL installed (surprisingly common) I can't tell which to use.
Right now I'm just querying the DB for it's install location, using what I find in
"\100\Setup Bootstrap\setup.exe"
and hoping for the best :P.
Edit: Found another one :P
"C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Release\x86\setup100.exe"
You can look in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\100\Bootstrap
The key you want is BootstrapDir.
FWIW, I don't have either (setup100.exe or setup.exe) in the Setup Bootstrap folder, only in the SQLServer2008R2 subfolder. This is perhaps because I don't have SQL Server 2008 installed, only 2008 R2.
So what do you plan to do when the file you're after is not found (either because 2008 isn't already installed, or because the user deleted it in an ill-advised attempt to free up some space)?

Installation of SharePoint 2010 with SQL Server 2008

I am trying to install SQL Server 2008 to F: drive. Initially I was getting the following error:
"The INSTANCESHAREDWOWDIR command line value was not specified"
Then I copied the configuration file .ini from SQL location and changed the location to the F: drive and placed this config to F: location.
Then I tried installation of SQL Server 2008 from command prompt and used the following command:
setup.exe
-/Action=Install
-/INSTALLSHAREDDIR="F:\Microsoft Sql Server\\"
-/INSTALLSHAREDWOWDIR="F:\Microsoft Sql Server(x86)\\"
I was able to install successfully, but still when I Install SharePoint 2010 server, it creates all the database to C: drive by default. I have the LDF and MDF files copied to F: drive manually.
What I want is for these databases to be created on drive F: when I install SharePoint. Anyone have any guidance or suggestions?
You need to change the Database default locations paths in Server Properties:
Source: Changing the default location of SQL Server Data and Log files

Sqlserver 2008 : Restored Failed for Server 'System 16'(Microsoft.Sqlserver.smoextended'

I am getting the following error when i tried to restore the bak file i have
TITLE: Microsoft SQL Server Management Studio
------------------------------
Restore failed for Server 'SYSTEM16'. (Microsoft.SqlServer.SmoExtended)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.0.1600.22+((SQL_PreRelease).080709-1414+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Restore+Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
System.Data.SqlClient.SqlError: The database was backed up on a server running version 10.50.1600. That version is incompatible with this server, which is running version 10.00.1600. Either restore the database on a server that supports the backup, or use a backup that is compatible with this server. (Microsoft.SqlServer.Smo)
Can any one tell how to resolve this.
The answer appears to be in your error message. It looks like you may have taken the backup from SQL 2008 R2 and are trying to restore it to SQL 2008 R1. You can't restore backups taken on newer versions of SQL Server to older versions.