Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql server 6.5

Status
Not open for further replies.

dibyajyoti1

Programmer
May 23, 2000
2
US
How do I copy through <b>'BCP'</b> only <font color=red>a few selective fields from an input data file to a table which have fewer column than the fields available in the flat file</font>?<br><br>&nbsp;&nbsp;&nbsp;Say there are three fields in the flat file and My table has only two columns and I want to copy only the first and the third field in to the table.How can I BCP it without taking help of a temporary table?
 
first, create a format file by running bcp, answering the questions and saving the file at the end.<br>you should get something like this:<br><FONT FACE=monospace><br>6.0<br>5<br>1&nbsp;&nbsp;&nbsp;&nbsp;SQLCHAR&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;9&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;ID<br>2&nbsp;&nbsp;&nbsp;&nbsp;SQLCHAR&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;RESPID<br>3&nbsp;&nbsp;&nbsp;&nbsp;SQLCHAR&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;HHOLDID<br>4&nbsp;&nbsp;&nbsp;&nbsp;SQLCHAR&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;POSTO<br>5&nbsp;&nbsp;&nbsp;&nbsp;SQLCHAR&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;&quot;\r\n&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;POSTI<br></font><br>The last but one column specifies the column number of your target table where the data will end up. If you want to ignore the data field just set the target column to 0. <p> <br><a href=mailto: > </a><br><a href= home</a><br>
 
<b>Jincho02</b>,I am not satisfied with your solution.<br><br>My problem is like this.<br>I have a table with millions of data.Here I have 10 existing column.And I have to bcp in to the table from a flat file which has 13 fields. <br>&nbsp;Your solution will be perfect if The table has also 13 column.But since It has less column it gives me error<br>i.e Column number out of Range.<br>Had the table also 13 column I wont have any problem .Since it has fewer column it was not able to bcp in.<br>&nbsp;<font color=red>Your solution will be perfect if the number of fields are same as the number of column in the table</font><br>Your solution will put null in the <b>HOLILD</b> column .But my case <b>HOLILD</b>does not exist at all.<br>
 
Please try it on a test table. <i>I will be serving humble pie at my house later.</i><br><br>The name of the data column (e.g. HHOLDID) is not really used for anything other than to help you keep track of what the data column is called. However, I include it here as it cannot be blank in SS7.<br><br>If you've got millions of rows you might want to try a bigger packet size. Check out the Books On Line for full info. <p> <br><a href=mailto: > </a><br><a href= home</a><br>
 
What major issues do I face if I replicate a SQL 6.5 database over a wide area network?&nbsp;&nbsp;The databases in question average 5GB in size and reside on a Compaq server with one ethernet nic.
 
ctoney419,<br>Good question, but please raise this as a new question thread as it is not directly relevant to dibyajyoti1's original question.<br>thanks,<br>&nbsp;&nbsp;&nbsp;&nbsp;jnicho02 <p> <br><a href=mailto: > </a><br><a href= home</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top