Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1758

Re: load multiple txt files to sql server

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: load multiple txt files to sql server
Date Sun, 25 May 2014 11:16:47 +0200
Organization Erland Sommarskog
Lines 30
Message-ID <XnsA33872BEA97FFYazorman@127.0.0.1> (permalink)
References <a76c710f-76e8-4cfd-b098-9f0d3a2e5897@googlegroups.com> <XnsA3376359BB035Yazorman@127.0.0.1> <fbb48642-a3cf-4bc8-a7c0-f00722965b80@googlegroups.com> <2fe392b1-5878-466c-842f-b4a40ab9f917@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding 8bit
Injection-Info mx05.eternal-september.org; posting-host="0c412830dbc354c08130c47cfccdbc83"; logging-data="19433"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+AzsCbDV9Too2HBOT79es7"
User-Agent Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32)
Cancel-Lock sha1:5vfSGKeNJB7mNseY+ciOoav7KF8=
Xref csiph.com comp.databases.ms-sqlserver:1758

Show key headers only | View raw


 (rja.carnegie@gmail.com) writes:
> As for the nation value that isn't in the data file itself,
> I think you can set a constant in a format file that
> controls a BCP data import process, 

No, you can't.

> but in my experience the format file is difficult to construct 

Yes, as long as you have not learnt the format.

> But this doesn't exist if I am reading this correctly
><http://msdn.microsoft.com/en-us/library/ms179250.aspx>
> (SQL Server 2014) which says "A data file can contain 
> fewer fields than the number of columns in the table 
> only if the skipped columns are nullable and/or have 
> default value."  i.e. you can't write a default value
> into the format file to use instead.
> 

Correct. But you can change the default value for each column before
you load.

Which still it is a bit of a kludge. I would rather solve it with 
client-side language. Just because you can do it in T-SQL does not
mean that you have to.


-- 
Erland Sommarskog, Stockholm, esquel@sommarskog.se

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Find similar


Thread

load multiple txt files to sql server tad na <teddybubu@gmail.com> - 2014-05-23 19:42 -0700
  Re: load multiple txt files to sql server Erland Sommarskog <esquel@sommarskog.se> - 2014-05-24 09:45 +0200
    Re: load multiple txt files to sql server bradbury9 <ray.bradbury9@gmail.com> - 2014-05-24 04:20 -0700
      Re: load multiple txt files to sql server tad na <teddybubu@gmail.com> - 2014-05-24 09:32 -0700
        Re: load multiple txt files to sql server Erland Sommarskog <esquel@sommarskog.se> - 2014-05-24 21:57 +0200
          Re: load multiple txt files to sql server bradbury9 <ray.bradbury9@gmail.com> - 2014-05-25 03:21 -0700
      Re: load multiple txt files to sql server rja.carnegie@gmail.com - 2014-05-24 15:30 -0700
        Re: load multiple txt files to sql server tad na <teddybubu@gmail.com> - 2014-05-24 20:50 -0700
        Re: load multiple txt files to sql server Erland Sommarskog <esquel@sommarskog.se> - 2014-05-25 11:16 +0200

csiph-web