Import MS Access to sql 2008 with c# coding

I write the following code. When execute AccessCommand, show this error message." ODBC--call failed." Can anyone help me? Thanks.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
protected void btnImportToSql_Click(object sender, EventArgs e)
System.Data.OleDb.OleDbConnection AccessConnection = new System.Data.OleDb.OleDbConnection("OLE DB SERVICES=0;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\attBackup11Feb2014.mdb;Persist Security Info=False;");
try
AccessConnection.Open();
System.Data.OleDb.OleDbCommand AccessCommand = new System.Data.OleDb.OleDbCommand("SELECT * INTO [USERINFO] IN '' [ODBC;Driver={SQL Server};Server=(local);Database=ERP_RL;Trusted_Connection=yes] FROM [USERINFO]", AccessConnection);
AccessCommand.ExecuteNonQuery();
AccessConnection.Close();
catch (Exception ex)
labErrorMessage.Text = ex.Message;

....OleDbCommand("SELECT * INTO [USERINFO] IN '' [ODBC;Driver={SQL Server};Server=(local);Database=ERP_RL;Trusted_Connection=yes] FROM [USERINFO]", AccessConnection);
Why do you have a kind of connection string in your SQL statement? That will never work. If your data souce is a SQL Server, why are you using
System.Data.OleDb namespace and not
System.Data.SqlClient, which is dedicated for SQL Server?
Olaf Helper
[ Blog] [ Xing] [ MVP]

Similar Messages

  • Accessing MS Sql Server with Java classes - problem connecting to socket

    I found an example at this location which uses java classes to connected to MS Sql Server.
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    --bummer - it is a login location - so I will include the article
    Anyway, the example is using Websphere, but I am still on Jbuilder (will get wsad soon). So I planted the classes from the example in
    C:\Borland\JBuilder\jkd1.4\jre\lib\ext\...the classes
    Then I copied the code from the example to my jpx project and got an error that it could not connect to the socket. The only thing I changed in the code was the connection string:
    --original string from example:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    I was getting an error with the 2 argument version of DriverManager - and the second argument here was empty (properties argument). Here was my connection string:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    I am only using the 1 argument version of DriverManager. Note that the password=" is blank because my RnD workstation is standalone - no one accesses the sql server except me - so no password. I also left out the last semicolon I noticed. Any suggestions appreciated how I could fix this.
    Thanks
    source of article:
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    iSeries 400 Tips:
    TIPS & NEWSLETTERS TOPICS SUBMIT A TIP HALL OF FAME
    Search for: in All Tips All search400 Full TargetSearch with Google
    PROGRAMMER
    Sample code: Accessing MS SQL Server database from the iSeries
    Eitan Rosenberg
    09 Mar 2005
    Rating: --- (out of 5)
    Nowadays with the help of Java the iSeries can be integrated with other databases quite easy. This tip shows you how. The code included here uses the free Microsoft driver that can be downloaded from here. (SQL Server 2000 Driver for JDBC Service Pack 3)
    If your SQL server does not include the Northwind Sample Database you can find it here.
    http://www.microsoft.com/downloads/details.aspx?familyid=07287b11-0502-461a-b138-2aa54bfdc03a&displaylang=en
    The download contains the following files:
    msbase.jar
    mssqlserver.jar
    msutil.jar
    Those files needs to be copied to the iSeries directories (/home/r_eitan/ExternalJARs).
    Here's the directory structure (on the iSeries) for this sample:
    /home/r_eitan/ExternalJARs - Microsoft files (msbase.jar,mssqlserver.jar,msutil.jar)
    /home/r_eitan/JdbcTest02 - My code (Main.java,Main.class)
    The Java code
    import java.sql.*;
    import java.io.*;
    class Main {
    * Connect to Microsoft SQL server and download file northWind.products as tab
    * seperated file. (products.txt)
    public static void main(String args[]) {
    try {
    PrintStream outPut = new PrintStream(new BufferedOutputStream(new FileOutputStream("products.txt")));
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    //Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    System.out.println("Connection Done");
    connection.setCatalog("northWind");
    String sqlCmdString = "select * from products";
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery(sqlCmdString);
    ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
    int columnCount = resultSetMetaData.getColumnCount();
    // Iterate throught the rows in resultSet and
    // output the columns for each row.
    while (resultSet.next()) {
    for (int index = 1; index <=columnCount; ++index)
    String value;
    switch(resultSetMetaData.getColumnType(index))
    case 2 :
    case 3 :
    value = resultSet.getString(index);
    break;
    default :
    value = """ + resultSet.getString(index) + """;
    break;
    outPut.print(value + (index < columnCount ? "t" : ""));
    outPut.println();
    outPut.close();
    resultSet.close();
    connection.close();
    System.out.println("Done");
    catch (SQLException exception)
    exception.printStackTrace();
    catch (Exception exception)
    exception.printStackTrace();
    --------------------------------------------------------------------------------------------------

    My guess is that the server's host name isn't right. It necessarily (or even usually) the "windows name" of the computer. Try with the numeric IP address instead (type "ipconfig" to see it).
    First aid check list for "connection refused":
    - Check host name in connect string.
    - Check port number in connect string.
    - Try numeric IP address of server host in connect string, in case name server is hosed.
    - Are there any firewalls between client and server blocking the port.
    - Check that the db server is running.
    - Check that the db server is listening to the port. On the server, try: "telnet localhost the-port-number". Or "netstat -an", there should be a listening entry for the port.
    - Try "telnet serverhost the-port-number" from the client, to see if firewalls are blocking it.
    - If "telnet" fails: try it with the numeric ip address.
    - If "telnet" fails: does it fail immediately or after an obvious timeout? How long is the timeout?
    - Does the server respond to "ping serverhost" or "telnet serverhost" or "ssh serverhost"?

  • Any way of importing from Access to SQL Server?

    I have a huge store of information in Access. But now I'm required to use SQL Server.
    Is there any way of importing the information from Access to SQL Server by Java programming?
    Or is there a manual way of doing that?
    Thank you in advance.

    I need to use Java because this is for a client. I
    can't expect the client to follow those steps. As a
    result, I want to create something simple for the
    client to convert from Access to SQL Server.
    Any other way of doing that?
    That argument does not make sense.
    There is no way that a 'client' is going to be able to manage MS SQL Server without understanding how it works. MS SQL Server is a complex database and requires at least some dedicated support, even if it is only part time.
    For example consider the following:
    -MS Access does not have a log file. MS SQL Server does. How is the log file going to be sized?
    -If the log file fills up (like for a run away query) MS SQL Server comes to a screeching halt. How is that problem going to be fixed?
    Now maybe you are going to provide that support, which means you can run those scripts. Or the client is going to support it in which case they need to have someone who understands it - and they will need to know how to run those scripts (since it is rather basic knowledge.)

  • Compatability of ECC DEV&QAS on Win 2008/SQL 2008 with Prdn on Win 2003/Win

    We are planning our  upgrade of my SAP landscape (ECC 6.0 , Portal & BI) . Would it be feasible and do-able to migrate sandbox, dev, and qas to Windows 2008 & SQL 2008 , allow the support team to use the 2008 landscape.  That means that my Dev. environments would be on Wind 2008 & SQL 2008 while my production would still be Win 2003 & 2008.   I'm not feeling like this is workable for the transport domain? will I have issues with transports across to production?
    So the question is
    Is it possible to transport from Windows 2008 SQL 2008 landscape over to a production landscape that is on Windows 2003 SQL 2005?
    Any other issues I should be aware of ?
    BTW, we would have Portal and BI setup in the same way  DEV & QAS on the newer releases and Production on the Older release.
    NOTE: this would be for about 3 - 4 weeks
    Please advise
    Maria

    Thank you,
    So you're saying that if I had the DEV environment in Win 2008 SQL 2008 (being the transport domain) , and the production environment in win 2003 sql 2005, IF we had to transport across this type of landscape there should be NO issues. 
    Nothing else to think of as posing risk?
    Maria

  • Accessing MS SQL database with two Windows accounts simultaneously

    Hello,
    I have ASP.NET web application started under PC\UserName account, and Windows Service Application that runs under Local System Account (NT\System). Both applications should access MS SQL database simultaneously. They are using same connection string:
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\mydb.mdf;Initial Catalog=mydb;User=MyUser;Password=MyPassword;" providerName="System.Data.SqlClient"
    />
    The problem occurrs every time when second app tries to fetch data from database. So, app which connects first can fetch data normally, but the other one gets "Login for
    MyUser failed" exception every time.
    Everything works as expected when i start windows service app under PC\UserName credentials. But the problem is that i have to do that login every time manually, and when User changes password I have to change it in service settings also.
    Does anyone know how to solve this problem?
    Thanks,
    Mladen 

    add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\mydb.mdf;Initial Catalog=mydb;User=MyUser;Password=MyPassword;" providerName="System.Data.SqlClient"
    Hello Mladen,
    You are using a User Instance
    of SQL Server and when the first app start this user instance with the MDF in exclusive Access; no other can use this MDF = Single User mode.
    Better attach the database file as a regular database, then you can use several connections to access the database.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How to get clients connected in WMS on windows server 2008 with c# coding

    Sorry to bother anyone about this question.
    Can anyone knows how to retrieve amount of client connection to Windows Media Server in real time same as WMS does on server console by c# programming ?
    I got logfiles of WMS in system32 directory for details but it must be off-line of all connections which will able to get those informations for doing anything,but in this case I want real time client connection
    at online when a client connects to WMS that I will get amout of that client also.
    I have tried to search Windows Media Service SDK to develop this on my Windows 7 OS,but I did not find that really.
    Can anyone knows this,please ?
    Regards,
    BigBerm

    Hi SYaGCi,
    Denis is right this is actually documented in the Supported Platforms Documentation:
    "Windows 7 and Windows Server 2008 R2 are new platform support additions in Service Pack 3 which are only available for support on the SP3 full release install of SAP BusinessObjects Enterprise. The SP3 patch only release of SAP BusinessObjects Enterprise does not provide support for these two new platforms."
    Kind regards,
    John

  • Linking Tables in SQL 2008

    I am running SQL server 2008 and want to link to a table in Access 2007. I have read many articles but most say to import from Access into SQL. Importing the table will not serve my needs as the data will not be dynamic. Is it possible to link to an Access
    table from SQL?
    Bruce

    You can create a linked server in SQL Server to connect to Access and query the table in Access
    http://msdn.microsoft.com/en-us/library/ff772782(v=sql.105).aspx
    YOu need to use the OLE DB provider for Jet inorder for Access.
    http://msdn.microsoft.com/en-us/library/ms175866(v=sql.105).aspx
    Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

  • I want to impersonate user when I access Microsoft SQL Server from powershell

    Hi,
    Actually I have to perform some SQL operation on my MSSQL server database. but problems is that I have given all credentials (windows fix login/password which can access database) in connection string. but when I execute the script then it is always using
    my windows login and password and then giving error that not able to connect with it.
    My personal windows credentials does not have access to my enterprise database that is why I am using service ID.
    I came to know that I have to do user impersonation of user when i access database but how to do that?? can you guys give me the syntax for that as i have to perform all sql operation using impersonation.
    Please reply me as soon as possible as i stuck since long
    Vipul Mistry Sr. Embedded Engineer www.eInfochips.com

    Hi Guys,
    thanks a lot for your support and replies but I found the solution. With below code i was able to do my task and I used $AuthType =3 for my purpose. Hope this will help others also.
    $varDBServer = "N0SQL104,1675"
    $varDBInstance = ""
    $varDBSchema = "Data_Dev"
    $varDBUser = "S0060VMSD"
    $varDBPassword = "SDCFG345D"
    #### Choose authentication type (0=SSO, 1= SQL, 2=Domain)
    $AuthType = 3
    #### Load the required assembly for sql server administration
    #### Requieres SQLServerNativeClient, SQLSysClrTypes and SharedManagementObjects
    [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
    $varSQLServer = New-Object -typeName Microsoft.SqlServer.Management.Smo.Server -argumentList "$varDBServer\$varDBInstance"
    switch ($AuthType) {
    1 {
    #### Access the SQL-Server with your current credentials (pass-through)
    $varSQLServer.ConnectionContext.LoginSecure = $true
    2 {
    #### Access the SQL-Server with SQL-Server credentials in mixed mode authentications
    $varSQLServer.ConnectionContext.LoginSecure = $false
    $varSQLServer.ConnectionContext.Login = $varDBUser
    $varSQLServer.ConnectionContext.Password = $varDBPassword
    3 {
    #### Access the SQL-Server with given domain user credentials
    $varSQLServer.ConnectionContext.LoginSecure = $true
    $varSQLServer.ConnectionContext.ConnectAsUser = $true
    $varSQLServer.ConnectionContext.ConnectAsUserName = $varDBUser
    $varSQLServer.ConnectionContext.ConnectAsUserPassword = $varDBPassword
    } default {
    Write-Host "Please select an authentication type: 0=SSO, 1= SQL, 2=Domain"
    exit -1
    #### Try connection to SQL-Server with given parameters
    Write-Host "`nTry connection to SQL-Server with given parameters`n"
    try {
    $varBuildOfSQLServer = $varSQLServer.Version.get_Build()
    Write-Host "Build of SQL-Server '$varDBServer' is $varBuildOfSQLServer"
    } catch {
    Write-Host "ERROR: Cannot access SQL-Server '$varDBServer'. Exit script!"
    exit –1
    Vipul Mistry Sr. Embedded Engineer www.eInfochips.com

  • In place upgrade Windows 2008 and SQL 2008

    Hi all,
    We are planning to upgrade to Windows 2012 and SQL 2012 , can we take this in-place upgrade path in the following order ?
    Setup 1 Host with 2 VM's running Windows 2008 R2 on Host and Windows 2008 R2/sqL 2008 on VM's.
    1. Host1(running 2 VM's) - In-place upgrade windows 2008 R2 to windows 2012 R2
    2. VM1 on host1 - In place upgrade windows 2008 R2 to Windows 2012 R2
    3. VM2 on host1 - In place upgrade windows 2008 R2 to Windows 2012 R2 (AD Server)
    4. SQL running VM1 - In place upgrade SQL 2008 with DB/reporting services to SQL 2012 DB/reporting services
    All Servers ( including Host and VM's) are stand alone in a workgroup setup.( except one VM a stand alone AD server by itself).
    Thanks for your help.

    Hi,
    If you want migrate from windows 2008r2 to windows 2012r2, you must install windows server 2008r2 sp1.
    http://technet.microsoft.com/en-us/library/dn303416.aspx
    For the host 1 upgrade, please refer to the following:
    http://blog.powerbiz.net.au/server-2012/in-place-upgrade-from-windows-server-2008-r2-to-windows-server-2012/
    For the SQL in-place upgrade, i think you may need to ask in SQL forums:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?forum=sqlservermigration
    Hope this helps.
    Regards.
    Vivian Wang

  • Installing SP3 on MSSQL SERVER 2008 with Replication

    Hi there
    How would one go about installing SP3 on SQL 2008 with replication? Would i need to turn off replication to avoid schema changes taking place across the line?
    Our servers are across the country and wouldn't want all that data to replicate over the tiny line we have.
    Instead we would like to install SP3 at the publisher and then at the subscriber.
    During testing on the dev instances, after stopping all agents ( log reader and queue reader) then installing and turning them back on didnt seem to work.Are there any whitepapers on the proper process on how to install SP3?
    Thanks in advance

    Hello,
    You should apply the service pack on the distributor first, then the publisher, and finally the subscriber.
    To my knowledge, replication should be suspended while the service pack will be applied on the distributor. Transaction will remain on the publisher until the distributor is
    available again.
    When you apply the service pack on the subscriber, the replicaction from the distributor to the subscriber will be suspended, and transaction will be on the distributor until the subscriber is available again.
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • P6 v.7 configuration question (SQL 2008)

    I'm in the process of creating a server to test a client/server deployment of P6 before we go live with it, but in reviewing the tested configurations in the Oracle knowledgebase I do not see our config, and I just wanted to see if anyone has successfullly used the one I want to go with. The config is:
    Windows Server 2008 X64 R2 SP1 on a Virtual in Hyper V (4 GB RAM, 2 Virtual processors)
    SQL 2008 with SP2
    Specifically looking for if anyone has tested it with SQL 2008 SP2. We can forego installing the service packs on SQL if they seem to cause issues.
    Thanks for any advice you all can give.

    While I have not personally tested SQL 2k8 SP2 I doubt you will have any issues.
    What you may be concerned with however is that when running on an unofficially-supported platform the vendor may chose not to assist you should something go severely wrong down the road. In Primavera's case I have never seen this to be a problem but now that Oracle has taken over things could potentially be different (especially in the case of MS SQL as I imagine they will eventually stop supporting it altogether).

  • BPC 70 SP4 and SQL 2008 SP1 build 10.00.2531

    I am preparing a single server environment to host BPC 70 SP4.  The prerequisites indicate SQL 2008 with cumulative update pack 2 is supported (build 10.00.1779).  Will SQL 2008 SP1 (build 10.00.2531) work also?

    John,
    It will work but due to a critical issue of CU1. I recommend using CU2 or later.
    Thanks.
    James Lim.

  • SQL Exoress 2008 import export Wizard wont import Access 2003 mdb to SQL 2008 DB

    Just installed SQL Express with Tools, including SSME and Import Export Wizard.
    Attempted to transfer Access 2003 DB tables from an mdb file to a SQL 2008 Express DB.
    I can view the data in the tables in Access, however, when I tell it to  do the deed, it begins the process and then errors out with a Error 0xc020801c:
    "TITLE: SQL Server Import and Export Wizard
    Could not connect source component.
    Error 0xc020801c: Source - ParentingStats [1]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "SourceConnectionOLEDB" failed with error code 0xC0202009.  There may be error messages posted before this with more information on why the AcquireConnection method call failed.
    ADDITIONAL INFORMATION:
    Exception from HRESULT: 0xC020801C (Microsoft.SqlServer.DTSPipelineWrap)"
    I am unable to find anything that translates this into something mere mortals can deal with.  This is repeatable.
    Steps in the wizard:
    1.  Source: Data Source selected is "Microsoft Access".  The filename is correct.  The username is correct.  The password is blank (there is no password in the Access db).  Clicking on the "Advanced..." button, I get the opportunity to "Test Connection".  I test the connection and the test is successful.
    2.  Destination: I select my server name and the SQL Native Client, select Windows Authentication, and Select my SQL 2008 Express db from the dropdown list.
    3.  Specify Tabloe Copy or Query: I select Table copy
    4.  Select Table or Views: I check the tables I want to copy and successfully preview the data in each table that I checked.  I click on "Edit Mappings ..." and verify that I want to create a new table for each checked table.
    5.  Run package: I accept the pre-checked "Run Immediately" and click the NEXT button
    6.  I get the following:
    "Source Location : C:\Users\wb5rvz\Documents\StatisticsApp_V3_69.mdb
    Source Provider : Microsoft.Jet.OLEDB.4.0
    Destination Location : SHACK_PC\SQLEXPRESS
    Destination Provider : SQLNCLI
    Copy rows from `ParentingStats` to [dbo].[ParentingStats]
    The new target table will be created.
    Copy rows from `Statistics` to [dbo].[Statistics]
    The new target table will be created.
    Copy rows from `StatsSummary` to [dbo].[StatsSummary]
    The new target table will be created.
    Copy rows from `Volunteers_Confidential` to [dbo].[Volunteers_Confidential]
    The new target table will be created.
    Copy rows from `YearMonthTbl` to [dbo].[YearMonthTbl]
    The new target table will be created.
    The package will not be saved.
    The package will be run immediately.
    Provider mapping file : c:\Program Files\Microsoft SQL Server\100\DTS\MappingFiles\JetToMSSql9.xml"
    7.  I click the FINISH button and I get
    "Initializing Data Tasks .... Success"
    "Initializing Connections ...Success"
    "Setting SQL Commend ....20% Compoete"
    "Setting Source Connection ...Error (and an error link)"
    (All following tasks were "Stopped"
    Error detail is:
    ===================================
    Could not connect source component.
    Error 0xc020801c: Source - ParentingStats [1]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "SourceConnectionOLEDB" failed with error code 0xC0202009.  There may be error messages posted before this with more information on why the AcquireConnection method call failed.
     (SQL Server Import and Export Wizard)
    ===================================
    Exception from HRESULT: 0xC020801C (Microsoft.SqlServer.DTSPipelineWrap)
    Program Location:
       at Microsoft.SqlServer.Dts.Pipeline.Wrapper.CManagedComponentWrapperClass.AcquireConnections(Object pTransaction)
       at Microsoft.SqlServer.Dts.DtsWizard.Execute.SetSourceConnection(Exception& ex, TransformInfo ti)
    OS is Vista Home Premium SP1 (32 bit)
    Processor = Intel core 2 duo E7200 @ 2.5 GHz
    SQL Server Software was just downloaded yesterday, so it is whatever is current on the download site:
    SQL Express with Tools
    So, how do I get this transform to work?  I do not have nor do I want/afford to put Access 2003 on this machine.
    Thanks
    RRR

    I had this similar problem - 32-bit SQL Server 2005 trying to import tables from Access 2000 .mdb file, same error:
    Error 0xc020801c: Source - ParentingStats [1]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "SourceConnectionOLEDB" failed with error code 0xC0202009.  There may be error messages posted before this with more information on why the AcquireConnection method call failed.
     (SQL Server Import and Export Wizard)
    ===================================
    Exception from HRESULT: 0xC020801C (Microsoft.SqlServer.DTSPipelineWrap)
    I know you said you clicked "Advanced..." and Test Connection when you chose your Access database - but that is what resolved the error for me.  I chose my .mdb file, username is admin, password is blank, but if I don't click the Advanced button and test the connection before continuing on, the import fails with above error message.  Go figure, since the username/blank password is correct. 
    FWIW, sorry if that doesn't help you though.

  • Client access from W7 to Server 2008 with SQL Express 2008 R2 not possible anymore (since installing yesterdays patches)

    Hi everyone!
    We are suddenly having Problems to access our SQL Express Server from our Clients (SBS 2008 with W7 clients).
    Till yesterday evening everything was working fine. At night we installed the latest MS patches für our Server 2008 (SBS2008).
    Since then we are not able to connect to the SQL Express Server over the Network. Locally (on the Server) it runs fine.
    Switching the Windows Firewall off on the Server also lets the clients connect ...
    The Windows Firewall still has all the ports open needed for SQL Server, we havn't changed anything.
    All the incoming rules that worked for years are still there (untouched).
    We just deinstalled all the latest patches, but problem still is here ... not sure if this was just a coincidence ...
    Any ideas what could be the Problem?
    Thanks in advance for your help
    Best regards
    Thomas

    Check firewall rules
    enable traffic on TCP 1433 and UDP 1434 (if isn't a named instance) or check sql using ports.
    Check Sql Server Browser in Configuration Manager and also net protocols.
    let's know about it
    Best regards,
    P.Ceglie
    Questo post è fornito "così com'è". Non conferisce garanzie o diritti di alcun tipo. Ricorda di usare la funzione "segna come risposta" per i post che ti hanno aiutato a risolvere il problema e "deseleziona come risposta" quando
    le risposte segnate non sono effettivamente utili. Questo è particolarmente utile per altri utenti che leggono il thread, alla ricerca di soluzioni a problemi similari. ENG: This posting is provided "AS IS" with no warranties, and confers no rights.
    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • How to export data with column headers in sql server 2008 with bcp command?

    Hi all,
    I want know "how to export data with column headers in sql server 2008 with bcp command", I know how to import data with import and export wizard. when i
    am trying to import data with bcp command data has been copied but column names are not came.
    I am using the below query:-
    EXEC master..xp_cmdshell
    'BCP "SELECT  * FROM   [tempdb].[dbo].[VBAS_ErrorLog] " QUERYOUT "D:\Temp\SQLServer.log" -c -t , -T -S SERVER-A'
    Thanks,
    SAAD.

    Hi All,
    I have done as per your suggestion but here i have face the below problem, in print statment it give correct query, in EXEC ( EXEC master..xp_cmdshell @BCPCMD) it was displayed error message like below
    DECLARE @BCPCMD
    nvarchar(4000)
    DECLARE @BCPCMD1
    nvarchar(4000)
    DECLARE @BCPCMD2
    nvarchar(4000)
    DECLARE @SQLEXPRESS
    varchar(50)
    DECLARE @filepath
    nvarchar(150),@SQLServer
    varchar(50)
    SET @filepath
    = N'"D:\Temp\LDH_SQLErrorlog_'+CAST(YEAR(GETDATE())
    as varchar(4))
    +RIGHT('00'+CAST(MONTH(GETDATE())
    as varchar(2)),2)
    +RIGHT('00'+CAST(DAY(GETDATE())
    as varchar(2)),2)+'.log" '
    Set @SQLServer
    =(SELECT
    @@SERVERNAME)
    SELECT @BCPCMD1
    = '''BCP "SELECT 
    * FROM   [tempdb].[dbo].[wErrorLog] " QUERYOUT '
    SELECT @BCPCMD2
    = '-c -t , -T -S '
    + @SQLServer + 
    SET @BCPCMD
    = @BCPCMD1+ @filepath 
    + @BCPCMD2
    Print @BCPCMD
    -- Print out below
    'BCP "SELECT 
    * FROM   [tempdb].[dbo].[wErrorLog] " QUERYOUT "D:\Temp\LDH_SQLErrorlog_20130313.log" -c -t , -T -S servername'
    EXEC
    master..xp_cmdshell
    @BCPCMD
      ''BCP' is not recognized as an internal or external command,
    operable program or batch file.
    NULL
    if i copy the print ourt put like below and excecute the CMD it was working fine, could you please suggest me what is the problem in above query.
    EXEC
    master..xp_cmdshell
    'BCP "SELECT  * FROM  
    [tempdb].[dbo].[wErrorLog] " QUERYOUT "D:\Temp\LDH_SQLErrorlog_20130313.log" -c -t , -T -S servername '
    Thanks, SAAD.

Maybe you are looking for