Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8365365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:38:21+00:00 2026-06-09T12:38:21+00:00

Im trying to use BCP to dump data from CDC function into a .dat

  • 0

Im trying to use BCP to dump data from CDC function into a .dat file. Im using the following query (which works in Server 2008 R2):

USE LEESWIJZER

DECLARE @begin_time datetime
, @end_time datetime
, @from_lsn binary(10)
, @to_lsn binary(10)

SET @end_time = '2013-07-05 12:00:00.000';    

SELECT @to_lsn = sys.fn_cdc_map_time_to_lsn('largest less than or equal',  @end_time);
SELECT @from_lsn = sys.fn_cdc_get_min_lsn('dbo_LWR_CONTRIBUTIES')

SELECT sys.fn_cdc_map_lsn_to_time(__$start_lsn) AS ChangeDTS
, *
FROM cdc.fn_cdc_get_net_changes_dbo_LWR_CONTRIBUTIES (@from_lsn, @to_LSN, 'all')

(edited for readability, used in BCP as single string)

my BCP string is:

BCP "Query above" queryout "C:\temp\LWRCONTRIBUTIES.dat" -w -t ";|" -r \n -T -S {server\\instance} -o "C:\temp\LWRCONTRIBUTIES.log"

As you can see I want a resulting .dat file in unicode, and a log file. I’m guessing the “ChangeDTS” column added to the function outcome is causing my problem. Error message reads: “[Microsoft][SQL Native Client]Host-file columns may be skipped only when copying into the Server”.

It may be resolved using a format file, but since this code needs to run daily, likely more than once a day, and the tables are subject to change, I’m reluctant to constantly adjust my format files (there are 100’s of tables needing the same procedure).

Furthermore, this is run on a clients database, who wont like me creating views in their database.

Anybody got any idea how I can create a text file (.dat) with a selected number of columns from a cdc function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:38:22+00:00Added an answer on June 9, 2026 at 12:38 pm

    Found the answer, regardless of which version of bcp used, bcp cant handle declarations, it seems. If i edit those out, works like a charm.
    However, according to someone on a different forum, BCP should be to handle declarations of variables. So happy it works for me now, but still confused why it does now and didnt before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Trying to import the EPF files from Apple using BCP. Apple use characters \1
I'm trying to use the SQL Server bcp utility to import a text file
I revieving the following error when trying use mysql_real_escape() function Fatal error: Call to
I'm trying use this code to get image resolution from file bool GetImageSizeEx(const char
trying to use hibernate with my web app and getting following exception: Initial SessionFactory
Trying to use Powershell to script the removal of specific custom errors from an
I have been trying use the edit_post_link() function to contain an image. All of
I want to do following things from main thread/process: Communicate to another process using
I need to export some data using SQL Server 2000's BCP utility. Sometimes my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.