MS SQL server 2008 - Bulk copy from XML to DB table throws bcp_init error

I have MS SQL server 2008 installed ,
Windows version - Windows 7 Professional with SP1
Doing a bulk copy process using the SQL library function bcp_init function in c++ throws xml error and its not inserting the data into the tables.
Error received ,
XML Datatransfer error: XML data or another error occurred while reading file 'd:\temp\scripts\dbtoolscripts\table_data.xml':
But this works in others machines with the same windows version and SQL version.

We are using the same SQL lib function bcp_init , we have written a separate class to load the ODBC32.dll , sqlncli.dll  and use the  bcp_init and other SQL functions from that. As i mentioned earlier we all use the same application build , but
its not working in my machine only other machines its working.
There is no provision to load XML files when you use the BCP interface in sqlncli.dll. You can of course load XML files, but the BCP API does not know that it is XML, it only sees a number of bytes.
So that error message is not coming from the BCP API, but somewhere else. Maybe your own code in reaction to some error from the BCP API. But without any clue of that error message, we can't help you.
I think you will need to do some debugging or by some other means improve your diagnostics.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • Improve the performance in stored procedure using sql server 2008 - esp where clause in very big table - Urgent

    Hi,
    I am looking for inputs in tuning stored procedure using sql server 2008. l am new to performance tuning in sql,plsql and oracle. currently facing issue in stored procedure - need to increase the performance by code optmization/filtering the records using where clause in larger table., the requirement is Stored procedure generate Audit Report which is accessed by approx. 10 Admin Users typically 2-3 times a day by each Admin users.
    It has got CTE ( common table expression ) which is referred 2  time within SP. This CTE is very big and fetches records from several tables without where clause. This causes several records to be fetched from DB and then needed processing. This stored procedure is running in pre prod server which has 6gb of memory and built on virtual server and the same proc ran good in prod server which has 64gb of ram with physical server (40sec). and the execution time in pre prod is 1min 9seconds which needs to be reduced upto 10secs or so will be the solution. and also the exec time differs from time to time. sometimes it is 50sec and sometimes 1min 9seconds..
    Pl provide what is the best option/practise to use where clause to filter the records and tool to be used to tune the procedure like execution plan, sql profiler?? I am using toad for sqlserver 5.7. Here I see execution plan tab available while running the SP. but when i run it throws an error. Pl help and provide inputs.
    Thanks,
    Viji

    You've asked a SQL Server question in an Oracle forum.  I'm expecting that this will get locked momentarily when a moderator drops by.
    Microsoft has its own forums for SQL Server, you'll have more luck over there.  When you do go there, however, you'll almost certainly get more help if you can pare down the problem (or at least better explain what your code is doing).  Very few people want to read hundreds of lines of code, guess what's it's supposed to do, guess what is slow, and then guess at how to improve things.  Posting query plans, the results of profiling, cutting out any code that is unnecessary to the performance problem, etc. will get you much better answers.
    Justin

  • SQL server 2008 R2 downgrade from Enterprise to standard edition

    Hello,
    we are going to downgrade SQL server 2008R2 from enterprise to standard for a server whose databases are not using any of the enterprise features. 
    Per the link http://www.mssqltips.com/sqlservertip/3079/downgrade-from-sql-server-enterprise-edition-to-standard-edition/ we had made a plan to do so.
    However, we are not sure of two points:
    1) Do we need to import the SSIS packages, i.e. after downgrade would all the packages vanish? Therefore what should be done for the Integeration services on this instance?
    2) second would be related to reports configured. Would all the settings in reporting configuration also change? If yes what should be done while downgrading (removing the reporting services as well)
    Thanks, please suggest.

    Hello,
    I you copy the old system databases incl ReportServer Db as described in the article then you have all SSIS packages & reports available as before.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • SQL Server 2008 R2 - Connection from multiple sources makes the database drop.

    Hey,
    I have a database being accesses from multiple sources - IIS and WPF application.
    Once a user enters the website(which is connected to the database through a Connection String), The WPF application stops its communication with the database, or vise versa.
    The problem being solved once I restart the IIS service or the SQL instance service.
    Thanks in advanced.
    Nir.

    Hello Nir,
    Thank you for your question. I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 
    Thank you for your understanding and support.
    If you have any feedback on our support, please click
    here.
    Regards,
    Elvis Long
    TechNet Community Support

  • Unable to connect to SQL Server 2008 from OBIEE 11G(on 64 bit Linux box)

    We are unable to connect to connect to SQL Server 2008 from OBIEE 11G which is on 64 bit Red Hat Enterprise Linux.
    Infrastructure: OBIEE 11.1.1.5 64bit, on 64 bit Red Hat Linux Enterprise Linux 5.6 , MS SQL Server 2008 on 64 bit Microsoft Windows Server
    Issue Description: Unable to connect to SQL Server 2008 from OBIEE11G RPD
    Details: We are unable to connect to SQL Server 2008 from OBIEE which is on a 64 bit Linux box. We created the ODBC connection on Linux box to the SQL server. Whenever we try to import metadata it throws an error that says ‘Connection Failed’.
    Here are the steps we followed to setup the ODBC connection on Linux box.
    1) We updated the user.sh file with the LD_LIBRARY_PATH and LD_LIBRARY_PATH_64 values that point to $ORACLE_HOME/bifoundation/odbc/lib
    This is where we found the driver for SQL server SEmsss23.so.
    2) We updated the odbc.ini file with the entry for SQL server with the connection details
    SI_SQL_Server_DEV = SQL Server
    [SI_SQL_Server_DEV]
    Driver=/u001_OAS/Oracle/Middleware/Oracle_BI1/bifoundation/odbc/lib/SEmsss23.so
    Description=DataDirect 5.1 SQL Server Wire Protocol
    Address=10.230.216.52,54970
    AlternateServers=
    AnsiNPW=Yes
    ConnectionRetryCount=0
    ConnectionRetryDelay=3
    Database=SVBDW_NEW
    LoadBalancing=0
    LogonID=SIDatavalidation
    Password=~~~Password123
    QuoteID=No
    ReportCodePageConversionErrors=0
    3) We updated the IDENTIFIER_QUOTE_CHAR with single quotes instead of double quotes in the DB features of the RPD
    4) We updated the bash_profile file to point the ODBCINI variable to the path where the OBIEE odbc.ini file is present.
    Export ODBCINI=/u001_OAS/Oracle/Middleware/instances/instance1/bifoundation/OracleBIApplication/coreapplication/setup/odbc.ini
    The error in nqsserver.log file says “[nQSError: 16001] ODBC error state: IM002 code: 0 message: [DataDirect][ODBC lib] Data source name not found and no default driver specified.”

    Hi,
    Make sure SQL Configuration Manager make sure the TCP/IP enabled. please try below method
    Method 1
    Re Create a new ODBC & Oracle Bi Server DSN Configuration test it and use it in the connection pools.
    define your ODBC data source in your server where the BI Server is installed. Check your DB connections in your physical layer and make they are defined on your BI Server as well.
    Method 2:
    try using the complete TNS in below format in the datasource name section:
    (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST =DB IP)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = ORCL) ) and provide the credentials.
    Method 3:
    To use the OCI call interface you need to have oracle client DB to be installed so that you can establish a connection using that DB credentials and connect to the remote dB and then import the tables.....this is the rule of thumb.
    hope helps you.
    Thanks
    Deva

  • Xcelsius Reporting Services Gateway (XRS) and SQL Server 2008

    Hello,
    I saw on a post somewhere that SAP support had stated that XRS wasn't compatible with SQL server 2008.
    Is that correct? I have hit an error.
    <?xml version="1.0" encoding="utf-8" ?>
    - <ROOT>
      <Message>Client found response content type of '', but expected 'text/xml'. The request failed with an empty response.</Message>
      <StackTrace>at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at Microsoft.ReportingServices.ReportingService.ListChildren(String Item, Boolean Recursive) at Microsoft.ReportingServices.CatalogManager.CreateXmlNode(XmlDocument Doc, CatalogItem Item, XmlNode ParentNode) at Microsoft.ReportingServices.CatalogManager.SerializeToXML() at Infommersion.XRS.Service.GetReports()</StackTrace>
      </ROOT>
    when trying to Invoke the GetReports method from a browser.
    This is in response to a client of ours having a similar problem.
    Ian
    Flynet

    Hi BlakeDuffey,
    Generally, we may see the error messge "Default appdomain failed to initialize" in the application log when try to start Reporting Services if the RSreportserver.config file has been modified unexpectedly. At this time, I suggest that you back up your
    current RSreportserver.config file, and then check the config file referring to the following article:
    RSReportServer Configuration File
    Note: The RSReportServer.config is located in the <drive>:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer folder.
    If you cannot find the exceptions in the RSreportserver.config file, please post the config file so that we can help you to check it.
    Meanwhile, please also check the Reporting Services Log file to see if there are any error messages related to the issue. If there are, please post the error messges as well. The Reporting Services Log file is located in the <drive>:\Program Files\Microsoft
    SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\LogFiles folder.
    Hope this helps.
    Regards,
    Mike Yin
    TechNet Subscriber Support
    If you are
    TechNet Subscription user and have any feedback on our support quality, please send your feedback
    here.
    Mike Yin
    TechNet Community Support

  • Crystal report 9 Sql Server 2008 R2 compatability

    Can we use Crystal report version 9 in Sql server 2008 R2 to generate reports in web server.
    Kindly tell us about the compatability of  these two. If there is any support issue between these two kindly mention the same.
    Edited by: Deepan1 on Jun 7, 2011 5:32 PM

    Upgrade to CR 2008 SP 4 is your only option.
    The Platforms file was on the CR CD or it may be in the Documents folder on install. I don't have it installed any more so I can't say exactly where it is. Search your PC for platforms.
    The problem is SQL 2008 uses a new Client engine and MS renamed the DLL do CR isn't aware of it. Using the MDAC version of SQL Server OLE DB Provider may work but it won't be supported if you find errors.
    If you do upgrade to CR 2008 then install the MS SQL Server 2008 Client Tools from the CD or download the MSI from Microsoft and then use the MS SQL Server Native 10 client and it should all work for you.
    Thank you
    Don

  • How to connect sql server 2008 r2 sp2 with vs2013 ultimate?

    how to connect sql server 2008 r2 sp2 with visual studio 2013 ultimate?

    Hi Shahzad,
    >>how to connect sql server 2008 r2 sp2 with visual studio 2013 ultimate?
    Based on your issue, if you wan to connect the sql server 2008 r2 sp2 from VS2013 IDE. I suggest you can try the Ammar and darnold924's suggestion to check your issue.
    In addition, I suggest you can also refer the following steps to connect the sql server 2008 r2 sp2 with visual studio 2013 ultimate.
    Step1: I suggest you can go to VIEW->SQL Server Object Explorer->Right click SQL Server->Add SQL Server.
    Step2: After you connect the SQL Server 2008 r2 sp2 fine, I suggest you can go to VIEW->Server Explorer-> right click the Data Connection->Add Connection.
    And then you can create the connect string in the Add Connection dialog box.
    Hope it help you!
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Table design for an indicator field in SQL Server 2008 R2

    Hi, I am using SQL Server 2008 R2 and I have an existing table (Please see the below table definition).
    CREATE TABLE Code
    ID INT IDENTITY (1, 1) PRIMARY KEY,
    Code NVARCHAR(10) NOT NULL UNIQUE,
    [Description] NVARCHAR(100) NOT NULL,
    [Type] NVARCHAR(30) NULL,
    Program NVARCHAR(30) NOT NULL, --Adding this column as a filter for different programs
    ModifiedDate DATETIME NOT NULL DEFAULT (getdate()),
    ModifiedBy NVARCHAR(128) NOT NULL DEFAULT (suser_sname())
    This table has been in use for a while and I am adding a column [Program] to identify records for that program. Previously it used to be just one program and this [Code] table was working just fine now there are 5 different programs introduced in the organization
    and this could keep changing over time.
    For instance Program A uses Code A, Code B, Code C & Program B uses Code C, Code D, Code E & Program C uses Code C. I know of an option which works but creates maintenance overhead
    everytime these programs change by doing something like below.
    Code ProgramA ProgramB ProgramC ProgramD ProgramE
    A      Yes
    B      Yes
    C      Yes           Yes           Yes
    D                      Yes
    E                       Yes
    But, is there a better way to do this keeping 1 column for Program and users being able to manage their data without looking at other codes. I mean a user who manages Program A should be able
    to see codes A, B, C & user managing Program B should see codes C, D, E & for Program C just code C.
    Thanks in advance.....
    Ione

    I would add it as a seperate table with columns as
    ProgramName  CodeName
    the data would be like
    ProgramName CodeName
    ProgramA A
    ProgramA B
    ProgramA C
    ProgramB C
    ProgramB D
    ProgramB E
    ProgramC C
    then its just a matter of adding a join from your above table to this table on Code field to get associated Program info and filter on it.
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • User-Defined Table Types - Where is it in SQL Server 2008?

    I am having 2 issues:
    1.  I don't see a folder for 'User-Defined Table Types' under programmability-->Types
    2.  When I execute the following code to create a Type; I get an error 'Incorrect syntax near the keyword 'AS'.'
    USE Locations;
    GO
    /* Create a user-defined table type */
    CREATE TYPE LocationTableType AS TABLE
    ( LocationName VARCHAR(50)
    , CostRate INT );
    GO

    Hi Shayann,
    The  user-defined table type is a new
    feature from SQL Server 2008. If you want to use it you have to upgrade your database to SQL Server 2008 or above.
    In you scenario(SQL Server 2005),as a workaround, you can use the  local temporary table instead. 
    --in SQL Server 2005
    CREATE TABLE tblType(id INT,name VARCHAR(99))
    GO
    CREATE PROC proc1
    AS
    BEGIN
    SELECT * FROM #temp;
    END
    GO
    SELECT * INTO #temp FROM tblType; -- the #temp name is fixed
    INSERT INTO #temp VALUES(1,'Eric');
    EXEC proc1
    --In SQL Server 2008 or above
    CREATE TYPE LocationTableType AS TABLE
    ( id INT,
    name VARCHAR(99) );
    GO
    CREATE PROC proc1 @t LocationTableType READONLY
    AS
    BEGIN
    SELECT * FROM @t
    END
    GO
    DECLARE @t LocationTableType;
    INSERT INTO @t VALUES(1,'Eric');
    EXEC proc1 @t
    I still suggest you upgrade to higher SQL Server.
    If you have any question, feel free to let me know.
    Best regards,
    Eric

  • Installing JDBC Drivers on SQL Server 2008 r2

    I am unable to create JDBC data source  on Web logic server ;the system displays the error that "can not load the jdbc drivers". The web logic server has to be configured to start or deploy the server for primavera contract management.
    I am not getting why this configuration not possible.
    Please let me know how to create the JDBC data source on the Web logic configuration for primavera contract management.

    Hello,
    If you wan to connect to SQL Server 2008 R2 database from your java application, you should download and install Microsoft JDBC Driver for SQL Server from the following link:
    http://www.microsoft.com/en-in/download/details.aspx?id=11774
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Sql Server 2008 R2 keeps disconnecting after a few minutes -- how can I prevent this?

    I already went into the Sql Server Configuration manager and set the TCPIP Keep Alive value to 0 (default setting 30000). But still, after like 5 minutes it disconnects, and I have to re-log back in. The problem with this is that I will usually have several
    #temp tables open -- then I have to re-create/populate all these #temp tables.  I'm running win7 SP1, Sql Server 2008 R2 Developer -- SP2. Is there something I can set in the registry maybe? What can I do to prevent sql server 2008 R2 Developer from disconnecting?
    Rich P

    I wish to continue with thanks to all for replies.  The disconnect property after Query execution is not checked. And I am not sure about not letting my computer sleep.  Sometimes I have to leave
    it for extended periods. 
    Good day Rich
    P123,
    Sometimes for monitoring we have to do actions that are one-time in order to check our assumptions. In this case I recommend that you do this check :-)
    you just need to check it once (like 24 hours), to make sure that this is the the source of the issue, or not :-)
    In any case you can use screensaver, but make sure that you do not close disks as well.
    Please inform us your result
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Database Migration MS Sql Server 2008 to Oracle

    I have downloaded the latest updates for SQL Developer and am attempting to migrate my SQL Server 2008 DB to Oracle 11g. I get the following error when attempting to test my Sql Server connection:
    Status : Failure - Test failed: I/O Error: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property.
    After attempting and following several posts, I have been unsuccessful in getting past this error - I have downloaded and placed in the specified directories the various .dll's suggested....
    Any help is of course appreciated.

    Boy do I look foolish. I told this guy that the owners of the application answer questions here... suerly he would get a reply.
    Such is the problem with "free" software. No one to blame when it doesn't work.

  • Msg 8631 Internal error: Server stack limit has been reached on SQL Server 2012 from T-SQL script that runs on SQL Server 2008 R2

    I have an Script mostly that is generated by SSMS which works with-out issue on SQL Server 2008, but when I attempt to run it on a new fresh install of SQL Server 2012 I get an Msg 8631. Internal error: Server stack limit has been reached. Please look for
    potentially deep nesting in your query, and try to simplify it.
    The script itself doesn't seem to be all that deep or nested.  The script is large 2600 lines and when I remove the bulk of the 2600 lines, it does run on SQL Server 2012.  I'm just really baffled why something that SQL Server generated with very
    few additions/changes AND that WORKS without issue in SQL Server 2008 R2 would suddenly be invalid in SQL Server 2012
    I need to know why my script which is working great on our current SQL Server 2008 R2 servers suddenly fails and won't run on an new SQL Server 2012 server.  This script is used to create 'bulk' Replications on a large number of DBs saving a tremendous
    amount of our time doing it the manual way.
    Below is an 'condensed' version of the script which fails.  I have removed around 2550 lines of specific sp_addarticle statements which are mostly just copy and pasted from what SQL Management Studio 'scripted' for me went I when through the Replication
    Wizard and told it to save to script.
    declare @dbname varchar(MAX), @SQL nvarchar(MAX)
    declare c_dblist cursor for
    select name from sys.databases WHERE name like 'dbone[_]%' order by name;
    open c_dblist
    fetch next from c_dblist into @dbname
    while @@fetch_status = 0
    begin
    print @dbname
    SET @SQL = 'DECLARE @dbname NVARCHAR(MAX); SET @dbname = ''' + @dbname + ''';
    use ['+@dbname+']
    exec sp_replicationdboption @dbname = N'''+@dbname+''', @optname = N''publish'', @value = N''true''
    use ['+@dbname+']
    exec ['+@dbname+'].sys.sp_addlogreader_agent @job_login = N''DOMAIN\DBServiceAccount'', @job_password = N''secret'', @publisher_security_mode = 1, @job_name = null
    -- Adding the transactional publication
    use ['+@dbname+']
    exec sp_addpublication @publication = N'''+@dbname+' Replication'', @description = N''Transactional publication of database
    '''''+@dbname+''''' from Publisher ''''MSSQLSRV\INSTANCE''''.'', @sync_method = N''concurrent'', @retention = 0, @allow_push = N''true'', @allow_pull = N''true'', @allow_anonymous = N''false'', @enabled_for_internet
    = N''false'', @snapshot_in_defaultfolder = N''true'', @compress_snapshot = N''false'', @ftp_port = 21, @allow_subscription_copy = N''false'', @add_to_active_directory = N''false'', @repl_freq = N''continuous'', @status = N''active'', @independent_agent = N''true'',
    @immediate_sync = N''true'', @allow_sync_tran = N''false'', @allow_queued_tran = N''false'', @allow_dts = N''false'', @replicate_ddl = 1, @allow_initialize_from_backup = N''true'', @enabled_for_p2p = N''false'', @enabled_for_het_sub = N''false''
    exec sp_addpublication_snapshot @publication = N'''+@dbname+' Replication'', @frequency_type = 1, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 8,
    @frequency_subday_interval = 1, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @job_login = N''DOMAIN\DBServiceAccount'', @job_password = N''secret'', @publisher_security_mode = 1
    -- There are around 2400 lines roughly the same as this only difference is the tablename repeated below this one
    use ['+@dbname+']
    exec sp_addarticle @publication = N'''+@dbname+' Replication'', @article = N''TABLE_ONE'', @source_owner = N''dbo'', @source_object = N''TABLE_ONE'', @type = N''logbased'', @description = null, @creation_script =
    null, @pre_creation_cmd = N''drop'', @schema_option = 0x000000000803509F, @identityrangemanagementoption = N''manual'', @destination_table = N''TABLE_ONE'', @destination_owner = N''dbo'', @vertical_partition = N''false'', @ins_cmd = N''CALL sp_MSins_dboTABLE_ONE'',
    @del_cmd = N''CALL sp_MSdel_dboTABLE_ONE'', @upd_cmd = N''SCALL sp_MSupd_dboTABLE_ONE''
    EXEC sp_executesql @SQL
    SET @dbname = REPLACE(@dbname, 'dbone_', 'dbtwo_');
    print @dbname
    SET @SQL = 'DECLARE @dbname NVARCHAR(MAX); SET @dbname = ''' + @dbname + ''';
    use ['+@dbname+']
    exec sp_replicationdboption @dbname = N'''+@dbname+''', @optname = N''publish'', @value = N''true''
    use ['+@dbname+']
    exec ['+@dbname+'].sys.sp_addlogreader_agent @job_login = N''DOMAIN\DBServiceAccount'', @job_password = N''secret'', @publisher_security_mode = 1, @job_name = null
    -- Adding the transactional publication
    use ['+@dbname+']
    exec sp_addpublication @publication = N'''+@dbname+' Replication'', @description = N''Transactional publication of database
    '''''+@dbname+''''' from Publisher ''''MSSQLSRV\INSTANCE''''.'', @sync_method = N''concurrent'', @retention = 0, @allow_push = N''true'', @allow_pull = N''true'', @allow_anonymous = N''false'', @enabled_for_internet
    = N''false'', @snapshot_in_defaultfolder = N''true'', @compress_snapshot = N''false'', @ftp_port = 21, @allow_subscription_copy = N''false'', @add_to_active_directory = N''false'', @repl_freq = N''continuous'', @status = N''active'', @independent_agent = N''true'',
    @immediate_sync = N''true'', @allow_sync_tran = N''false'', @allow_queued_tran = N''false'', @allow_dts = N''false'', @replicate_ddl = 1, @allow_initialize_from_backup = N''true'', @enabled_for_p2p = N''false'', @enabled_for_het_sub = N''false''
    exec sp_addpublication_snapshot @publication = N'''+@dbname+' Replication'', @frequency_type = 1, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 8,
    @frequency_subday_interval = 1, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @job_login = N''DOMAIN\DBServiceAccount'', @job_password = N''secret'', @publisher_security_mode = 1
    -- There are around 140 lines roughly the same as this only difference is the tablename repeated below this one
    use ['+@dbname+']
    exec sp_addarticle @publication = N'''+@dbname+' Replication'', @article = N''DB_TWO_TABLE_ONE'', @source_owner = N''dbo'', @source_object = N''DB_TWO_TABLE_ONE'', @type = N''logbased'', @description = null, @creation_script
    = null, @pre_creation_cmd = N''drop'', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N''manual'', @destination_table = N''DB_TWO_TABLE_ONE'', @destination_owner = N''dbo'', @vertical_partition = N''false''
    EXEC sp_executesql @SQL
    fetch next from c_dblist into @dbname
    end
    close c_dblist
    deallocate c_dblist
    George P Botuwell, Programmer

    Hi George,
    Thank you for your question. 
    I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 
    Thank you for your understanding and support.
    If you have any feedback on our support, please click
    here.
    Allen Li
    TechNet Community Support

  • SQL Server 2008 - RS - Loop of multiple Bulk Inserts

    Hi,
    I want to import multiple flat files to a table on SQL Server 2008 R2. However, I don't have access to Integration Services to use a foreach loop, so I'm doing the process using T-SQL. Actually, I'm using manually code to which file to introduce the data on
    tables. My code are like this:
    cREATE TABLE #temporaryTable
        [column1] [varchar](100) NOT NULL,
        [column2 [varchar](100) NOT NULL
    BULK
    INSERT #temp
    FROM 'C:\Teste\testeFile01.txt' 
    WITH
    FIELDTERMINATOR = ';',
    ROWTERMINATOR = '\n',
    FIRSTROW = 1
    GO
    BULK
    INSERT #temp
    FROM 'C:\Teste\testeFile02.txt' 
    WITH
    FIELDTERMINATOR = ';',
    ROWTERMINATOR = '\n',
    FIRSTROW = 1
    GO
    -------------------------------------------------INSERT INTO dbo.TESTE ( Col_1, Col_2)
    Select RTRIM(LTRIM([column1])), RTRIM(LTRIM([column2])) From #temporaryTable
    IF EXISTS(SELECT * FROM #temporaryTable) drop table #temporaryTable
    The problem is that I have 20 flat files to Insert... Do I have any loop solution in T-SQL to insert all the flat files on same table?
    Thanks!

    Here is a working sample of powershell script I adopted from internet( I don't have the source handy now).
    Import-Module -Name 'SQLPS' -DisableNameChecking
    $workdir="C:\temp\test\"
    $svrname = "MC\MySQL2014"
    Try
    #Change default timeout time from 600 to unlimited
    $svr = new-object ('Microsoft.SqlServer.Management.Smo.Server') $svrname
    $svr.ConnectionContext.StatementTimeout = 0
    $table="test1.dbo.myRegions"
    #remove the filename column in the target table
    $q1 = @"
    Use test1;
    IF COL_LENGTH('dbo.myRegions','filename') IS NOT NULL
    BEGIN
    ALTER TABLE test1.dbo.myRegions DROP COLUMN filename;
    END
    Invoke-Sqlcmd -ServerInstance $svr.Name -Database master -Query $q1
    $dt = (get-date).ToString("yyyMMdd")
    $formatfilename="$($table)_$($dt).xml"
    $destination_formatfilename ="$($workdir)$($formatfilename)"
    $cmdformatfile="bcp $table format nul -c -x -f $($destination_formatfilename) -T -t\t -S $($svrname) "
    Invoke-Expression $cmdformatfile
    #Delay 1 second
    Start-Sleep -s 1
    $q2 = @"
    Alter table test1.dbo.myRegions Add filename varchar(500) Null;
    #add the filename column to the target table
    Invoke-Sqlcmd -ServerInstance $svr.Name -Database master -Query $q2
    $files = Get-ChildItem $workdir
    $items = $files | Where-Object {$_.Extension -eq ".txt"}
    for ($i=0; $i -lt $items.Count; $i++) {
    $strFileName = $items[$i].Name
    $strFileNameNoExtension= $items[$i].BaseName
    $query = @"
    BULK INSERT test1.dbo.myRegions from '$($workdir)$($strFileName)' WITH (FIELDTERMINATOR = '\t', FIRSTROW = 2, FORMATFILE = '$($destination_formatfilename)');
    Invoke-Sqlcmd -ServerInstance $svr.Name -Database master -Query $query -querytimeout 65534
    #Delay 10 second
    Start-Sleep -s 10
    # Update the filename column
    Invoke-Sqlcmd -ServerInstance $svr.Name -Database master -querytimeout 65534 -Query "Update test1.dbo.myRegions SET filename= '$($strFileName)' WHERE filename is null; "
    # Move uploaded file to archive
    If ((Test-Path "$($workdir)$($strFileName)") -eq $True) { Move-Item -Path "$($workdir)$($strFileName)" -Destination "$($workdir)Processed\$($strFileNameNoExtension)_$($dt).txt"}
    Catch [Exception]
    write-host "--$strFileName "$_.Exception.Message

Maybe you are looking for

  • Hello... i cant bwoser blospot on my browser .blogspot site not appearing on my broswer plz help

    recent i added an custom domain on my blogspot site as www.allfreeebooks.net but on my browser this site not showing as direct url . loading loading then spot that page . i can access my blogspot account , can post too . but when i try to see my page

  • RH8 Popup position in .chm

    Hi, I am using auto-sizing pop-ups on an image mapped topic. When you click the image in the compiled Help, the pop-ups open in the upper left-hand corner of the topic instead of over the image in a place relative to the map as it did when the Help w

  • The 'Share' Pane has disappeared from my Adobe Acrobat X Pro screen.

    I've had Adobe Acrobat X Pro for a while. Had no problems with it, but signed in one day and suddenly it is only showing Tools and Comments. Can't find anything anywhere that says how to get Share to reappear. Any ideas please?

  • When turning Airport on it Freezes MacBook Pro

    When turning on the Airport, my MacBook Pro freezes. The only way get out of it is to do a force shut down. After rebooting everything works fine, including turning off Airport. How do I correct this? Roman

  • OVD:  RESTful interfaces

    Hello I see references by Mark Wilcox about a RESTful interface to OVD, and how it's possible.  References:  here and here Question:  Is this a published configuration?  I see how to use the HTTP Gateway, and get content via DSML, however, I don't se