473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Formatfile shortcut?

I was searching the group for posts on the subject of format files and
I came across a message by Erland Sommarskog dated 2003-07-07 with
subject line "Re: BCP Format File". In this example, he used a
FORMATFILE where the "prefix length" and "host file data length"
fields were both zero for all columns.

This convention seems to simplify the task of creating format files.
Is this shortcut generally applicable or was it a special case? Does
this mean that SQL Server can always establish the actual lengths in
the data file by looking up the destination table's schema
information?
Jul 20 '05 #1
3 1974
php newbie (ne**********@yahoo.com) writes:
I was searching the group for posts on the subject of format files and
I came across a message by Erland Sommarskog dated 2003-07-07 with
subject line "Re: BCP Format File". In this example, he used a
FORMATFILE where the "prefix length" and "host file data length"
fields were both zero for all columns.

This convention seems to simplify the task of creating format files.
Is this shortcut generally applicable or was it a special case? Does
this mean that SQL Server can always establish the actual lengths in
the data file by looking up the destination table's schema
information?


No. The format file descibes the data file. It does not describe the
database columns. All there is a mapping from the data-file fields to
the database columns. (Which is the column numbers. The column names
in the BCP file are informational only.)

There are three ways to describe a field in a format file:
o The file itself has the length of the field, and the format file
describes the length of this length information: 1, 2 or 4 bytes.
o Fixed length.
o A certain character sequence acts as terminator, and this terminator
can thus not be part of the data itself.

In the format file I posted, I used a termintor. (I have to assume,
as I don't remember that particular post.)

You can mix these methods in the same format file, and use one method
for one column, and another method for another column. I have to admit
that I don't know the significance of using two methods for the same
column, but I know that I have not always been successful with using
0 for the column length, although I have had a terminator.

The BCP command offers a couple of options that relieves you from having
to write a format file, and when you use these options, BCP does look
at the schema for the target table. But you can see these options as
shortcuts for particular format-file definitions.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
Erland Sommarskog <es****@sommarskog.se> wrote in message news:<Xn**********************@127.0.0.1>...
There are three ways to describe a field in a format file:
o The file itself has the length of the field, and the format file
describes the length of this length information: 1, 2 or 4 bytes.
o Fixed length.
o A certain character sequence acts as terminator, and this terminator
can thus not be part of the data itself.

In the format file I posted, I used a termintor. (I have to assume,
as I don't remember that particular post.)


Hello Erland,

Thanks for the info. For reference, the post was this:
http://groups.google.com/groups?q=sq...7.0.0.1&rnum=2

I am primarily interested in data files that are delimited with a
special character, like a tab or a comma. So, essentially, if I use
delimited data files, I do not need to calculate field lengths and put
them in the format file. Is this an accurate rephrase of your
suggestion? I would like to use the same format file with different
database tables (which have similar structure but different column
lengths for names and addresses.)

Thanks again!
Jul 20 '05 #3
php newbie (ne**********@yahoo.com) writes:
I am primarily interested in data files that are delimited with a
special character, like a tab or a comma. So, essentially, if I use
delimited data files, I do not need to calculate field lengths and put
them in the format file. Is this an accurate rephrase of your
suggestion? I would like to use the same format file with different
database tables (which have similar structure but different column
lengths for names and addresses.)


Yes, I would expect that to work.

But as I said, I have not always been successful, and it has happened
that I have had to throw in a length specification. Note however that
that specification relates to the host-data file, not the database
table.

Note also, that is the host data is too long with regards to the database
columns, you are likely to get the error "String or binary data would be
truncated".
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: aa | last post by:
Thought this question might be out of this NG's scope, there are always knowledgable people who might hava an answer. A hyperlink to a shortcut to a file returnes an empty screen, and the source...
10
by: Lex | last post by:
I am writing a C# app that has a Menu. Some of the menu items will have short cuts that do not exist in the Shortcut enum. I would like the custom shortcuts to appear on the menu but as far as I...
4
by: Salad | last post by:
A97. If you set a forms properties to ShortcutMenu = No, the entire form is disabled from displaying a shortcut menu. If you set the property to Yes, all controls have a shortcut menu. I have...
0
by: cefrancke | last post by:
I recently discovered, that if you set the startup options for "security", you will have alot of work do to get Access back to "normal". If you disable the built-in menus/toolbars you'll have to...
0
by: Marcel | last post by:
Hi, the application I am writing has a MainMenu and a DataGrid (UltraGrid). Now I have to edit the text of each cell in this grid. So far so good. All works fine in editmode but if I press a...
4
by: I_AM_DON_AND_YOU? | last post by:
There is one more problem I am facing but didn't get the solution. In my Setup Program I am not been able to create 2 things (when the program is intalled on the client machine ) : (1) create...
3
by: TC | last post by:
I've written an application using VB.NET 2003 and packaged it with a deployment project. When I use the setup program to install the application, however, it doesn't work. More specifically, the...
7
by: GrandpaB | last post by:
I would appreciate assistance learning how to create a Desktop shortcut in my setup project. In the left pane of the Setup/File System window I right-clicked User's Desktop. From the contex...
5
by: remya1000 | last post by:
i'm using VB.NET 2003 application program. by using OpenFileDialog, we can select the file name or file path. OpenFileDialog1.ShowDialog() pgmPath.Text =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.