Showing posts with label field. Show all posts
Showing posts with label field. Show all posts

Wednesday, March 28, 2012

Importing text file removes decimal separator

Hi,

I'm trying to import a semi-comma separated text file into a SQL db. I have a field in the text file that contains decimal number. As a decimal separator it's used a comma (15,35). When i use a DTS package to create a destination table and import all rows, the field is created as a float field. In this field the decimal comma is removed so the number in SQL becomes 1535. If I change the decimal separator to (.) i works OK. But I need to get it work with comma as decimal separator. In the DTS package the field form the text file is recognised as varchar (8000). Any ideas?

Ingar

You have to choose appropriate locale which threats comma as a decimal delimiter. There is the drop-down control for choosing locales on the first page of the Flat File Connection Manager UI.

Thanks.

|||

Hi, thanks for your answer. I can see that I didn't specify which SQL version i was using. I use SQL 2000 not 2005. I know that the theme in this forum is SSIS but it also states "transforms/data flow" and I thought DTS packages from SQL 2000 was included here. I appologize if I have misunderstood this but english is not my first language.

So as far as I know the Flat file connection manager is not available in SQL 2000.

But thanks anyway.

Ingar

Friday, March 23, 2012

Importing Null Date Fields

I'm using SQL Server Express and am trying to import a CVS file. The CVS file contains a string field (named DAS) that represents a Date. This field can be null.

I've tried using the DTS Wizard to import this CVS file and convert the DAS field to a Date, which works great until it hits a record with a NULL DAS field. It then throws a convertion error.

Still using the DTS Wizard, I've changed the DataType of the DAS field in the Source file to [DT_DATE], it works fine but all the null dates are converted to 12/30/1899.

Is there a way (DTS Wizard or something else) that will allow me to import these CVS files with null Date fields and keep them as null in SQL Server table.

Thanks for any help,

Jon

Hi,

I read your post and I can advice you the next:

1. Once you have date 12/30/1899 instead all NULL values in SQL Server => you may easy to sort that records, to mark them and place NULL value with “copy” and “paste”. It is easy and quickly.

2. You may write a program instead DTS Wizard /I don’t know that wizard/. That program will read from your CVS file and write to SQL server. From the program you will have full control on all fields. I personally prefer to write a program when I have some unusual case.

I hope that advices will solve the problem. But if you still can’t make NULL values – let me know.

Regards,

Hristo Markov

|||Off the top of my head, I'm thinking there is an option to "Keep Nulls" inside the wizard. I haven't run it and I'm not on my machine w/ SSIS installed so I can't verify it. If you do see such an option, that is how you tell SSIS to preserve the NULLs.

If this isn't an option, then you'll have to go one step deeper and either do custom transformations or write an EXECUTE SQL TASK that will go through and update any record of 12/30/1899 to be NULL.

Importing Multiple XML Field values

Hi,
Does anyone know how to make SQLXMLBulkLoad accept a SQL file if it has a
field repeated with more than 1 value. For example
<ROOT>
<Cust>
<details>
<Val1>23</Val1>
<Val2>44</Val2>
<Val3>16</Val3>
<Val3>77</Val3>
<Val4>47</Val4>
</details>
</Cust>
</ROOT>
As Val3 appears twice in the file, SQLXMLBulkLoad fails because it already
has a mapping for this field. Is there a way to modify the schema definition
to allow for this?
I don't actually care which of the values for Val3 the import process saves,
although I would like one or the other.
The schema currently looks something like:
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<element name="Cust" sql:relation="CustTable" >
<complexType>
<sequence>
<element name="Val1" sql:field="CusVal1" type="integer" />
<element name="Val2" sql:field="CusVal2" type="integer" />
<element name="Val3" sql:field="CusVal3" type="integer" />
<element name="Val4" sql:field="CusVal4" type="integer" />
<sequence>
<complexType>
<element>
<schema>
Thanks
Bod
There is no way to get bulkload to work this way.
Your options would be to:
1. clean the data ahead of time using XSLT, or
2. do the inserts using the Server's nodes() method
This article has examples of using nodes()
http://msdn.microsoft.com/library/de.../forxml2k5.asp
|||Thanks Todd. Not my favourite answer but your confirmation that I can't do
it saves me wasting hours of trying...
Bod
"Todd Pfleiger [MSFT]" wrote:

> There is no way to get bulkload to work this way.
> Your options would be to:
> 1. clean the data ahead of time using XSLT, or
> 2. do the inserts using the Server's nodes() method
> This article has examples of using nodes()
> http://msdn.microsoft.com/library/de.../forxml2k5.asp
>
sql

Importing Multiple XML Field values

Hi,
Does anyone know how to make SQLXMLBulkLoad accept a SQL file if it has a
field repeated with more than 1 value. For example
<ROOT>
<Cust>
<details>
<Val1>23</Val1>
<Val2>44</Val2>
<Val3>16</Val3>
<Val3>77</Val3>
<Val4>47</Val4>
</details>
</Cust>
</ROOT>
As Val3 appears twice in the file, SQLXMLBulkLoad fails because it already
has a mapping for this field. Is there a way to modify the schema definitio
n
to allow for this?
I don't actually care which of the values for Val3 the import process saves,
although I would like one or the other.
The schema currently looks something like:
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<element name="Cust" sql:relation="CustTable" >
<complexType>
<sequence>
<element name="Val1" sql:field="CusVal1" type="integer" />
<element name="Val2" sql:field="CusVal2" type="integer" />
<element name="Val3" sql:field="CusVal3" type="integer" />
<element name="Val4" sql:field="CusVal4" type="integer" />
<sequence>
<complexType>
<element>
<schema>
Thanks
BodThere is no way to get bulkload to work this way.
Your options would be to:
1. clean the data ahead of time using XSLT, or
2. do the inserts using the Server's nodes() method
This article has examples of using nodes()
http://msdn.microsoft.com/library/d...r />
ml2k5.asp|||Thanks Todd. Not my favourite answer but your confirmation that I can't do
it saves me wasting hours of trying...
Bod
"Todd Pfleiger [MSFT]" wrote:

> There is no way to get bulkload to work this way.
> Your options would be to:
> 1. clean the data ahead of time using XSLT, or
> 2. do the inserts using the Server's nodes() method
> This article has examples of using nodes()
> http://msdn.microsoft.com/library/d.../>
rxml2k5.asp
>|||Bod-
Can you post your final schema file that you are using for this bulk
load?
Thanks
Brian
briankudera
---
Posted via http://www.mcse.ms
---
View this thread: http://www.mcse.ms/message2239821.html

Wednesday, March 21, 2012

Importing from another database on same server using SQL Server Express

Try one of these two choices, one using a JOIN, one using a Sub-SELECT:
UPDATE n
SET n.Field = o.Field
FROM NewDatabase.dbo.Table n
JOIN OldDatabase.dbo.Table o
ON n.PK = o.PK
(OR)
UPDATE NewDatabase.dbo.Table n
SET n.Field = (SELECT o.FIELD
FROM OldDatabase.dbo.Table o
WHERE o.Field = n.Field
)
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the top yourself.
- H. Norman Schwarzkopf
"John Hackert" <hackertjohnb@.yahoo.com> wrote in message news:1162174049.649530.85940@.f16g2000cwb.googlegro ups.com...
>I haven't been able to solve this likely syntax problem despite
> referring to these groups, the Books On Line, and reference texts:
> Without the use of Data Transformation Services in SQL Server Express,
> what techniques work to import/export data between databases under the
> same server instance?
> The specific example I was working on involved an attempt to run an
> update query to place data from a specific field in an older copy of an
> otherwise identical database into a more recent copy. Ultimately I
> just plugged the small data series in manually using side-by-side views
> because I could not overcome the syntax errors generated in the effort
> to refer to the "external" database.
> This is the setup in question:
> - An instance in the format of "MyComputerName\SQLExpress," and both an
> - "OldDatabase" and
> - "NewDatabase" attached and viewable from the Management Studio
> Express, with identical fields
> I tried a few different query techniques as suggested in historical
> posts, but to no avail. Here is such an example that I tried:
> In MSE I right clicked on the target table in question and chose:
> "Script table as," then
> "UPDATE to," then
> "New Query Editor Window"
> I removed all the fields except that in question and added this Where
> clause:
> UPDATE [NewDatabase].[dbo].[Table]
> SET [Field] = [OldDatabase].[dbo].[Table].[Field]
> WHERE [NewDatabase].[dbo].[Table].[PK] =
> [OldDatabase].[dbo].[Table].[PK]
> in which the primary key (an auto-increment integer) is identical
> between the new and old tables.
> This produces the error:
> Msg 4104, Level 16, State 1, Line 1
> The multi-part identifier "OldDatabase.dbo.Table.PK" could not be
> bound.
> If I understood from prior posts, using joins is less desirable in
> update queries, but even so likewise produced errors when I tried that
> approach.
> I would be grateful if someone could explain the proper syntax to refer
> to another database within the same server instance or otherwise.
> Many thanks!
>
Thank you for replying -
Even with these other techniques, I receive the same "multi-part
identifier...could not be bound" error. So, perhaps the root of the
problem is not the syntax of the query but something else. Any other
ideas?
John H
Arnie Rowland wrote:
> Try one of these two choices, one using a JOIN, one using a Sub-SELECT:
> UPDATE n
> SET n.Field = o.Field
> FROM NewDatabase.dbo.Table n
> JOIN OldDatabase.dbo.Table o
> ON n.PK = o.PK
> (OR)
> UPDATE NewDatabase.dbo.Table n
> SET n.Field = (SELECT o.FIELD
> FROM OldDatabase.dbo.Table o
> WHERE o.Field = n.Field
> )
> --
> Arnie Rowland, Ph.D.
> Westwood Consulting, Inc
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
> You can't help someone get up a hill without getting a little closer to the top yourself.
> - H. Norman Schwarzkopf
>
> "John Hackert" <hackertjohnb@.yahoo.com> wrote in message news:1162174049.649530.85940@.f16g2000cwb.googlegro ups.com...
> --=_NextPart_000_01FC_01C6FB8D.01E3E1B0
> Content-Type: text/html; charset=iso-8859-1
> Content-Transfer-Encoding: quoted-printable
> X-Google-AttachSize: 5469
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
> <META content="MSHTML 6.00.5296.0" name=GENERATOR>
> <STYLE></STYLE>
> </HEAD>
> <BODY>
> <DIV><FONT face=Arial size=2>Try one of these two choices, one using a JOIN, one
> using a Sub-SELECT:</FONT></DIV>
> <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
> <DIV><FONT face="Courier New" size=2>UPDATE&nbsp;n</FONT></DIV>
> <DIV><FONT face="Courier New" size=2>&nbsp;&nbsp; SET n.Field =
> o.Field</FONT></DIV>
> <DIV><FONT face="Courier New" size=2>FROM NewDatabase.dbo.Table n</FONT></DIV>
> <DIV><FONT face="Courier New" size=2>&nbsp;&nbsp; JOIN OldDatabase.dbo.Table
> o</FONT></DIV>
> <DIV><FONT face="Courier New" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&am p;nbsp; ON n.PK =
> o.PK<BR></FONT></DIV>
> <DIV><FONT face="Courier New" size=2>(OR)</FONT></DIV>
> <DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
> <DIV><FONT face="Courier New" size=2>UPDATE NewDatabase.dbo.Table n</FONT></DIV>
> <DIV><FONT face="Courier New" size=2>&nbsp;&nbsp; SET n.Field = (SELECT
> o.FIELD</FONT></DIV>
> <DIV><FONT face="Courier New"
> size=2>&nbsp;&nbsp;&nbsp;&nbsp;&am p;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&am p;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&am p;nbsp;&nbsp;&nbsp;
> FROM OldDatabase.dbo.Table o</FONT></DIV>
> <DIV><FONT face="Courier New"
> size=2>&nbsp;&nbsp;&nbsp;&nbsp;&am p;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&am p;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&am p;nbsp;&nbsp;&nbsp;
> WHERE o.Field = n.Field</FONT></DIV>
> <DIV><FONT size=2><FONT
> face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;
> )</FONT></DIV></FONT>
> <DIV><FONT face=Arial size=2></FONT><BR><FONT face=Arial size=2>-- <BR>Arnie
> Rowland, Ph.D.<BR>Westwood Consulting, Inc</FONT></DIV>
> <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
> <DIV><FONT face=Arial size=2>Most good judgment comes from experience. <BR>Most
> experience comes from bad judgment. <BR>- Anonymous</FONT></DIV>
> <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
> <DIV><FONT face=Arial size=2>You can't help someone get up a hill without
> getting a little closer to the top yourself.<BR>- H. Norman
> Schwarzkopf</FONT></DIV>
> <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
> <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
> <DIV><FONT face=Arial size=2>"John Hackert" <</FONT><A
> href="http://links.10026.com/?link=mailto:hackertjohnb@.yahoo.com"><FONT face=Arial
> size=2>hackertjohnb@.yahoo.com</FONT></A><FONT face=Arial size=2>> wrote in
> message </FONT><A
> href="http://links.10026.com/?link=news:1162174049.649530.85940@.f16g2000cwb.goo glegroups.com"><FONT
> face=Arial
> size=2>news:1162174049.649530.85940@.f16g2000cwb.go oglegroups.com</FONT></A><FONT
> face=Arial size=2>...</FONT></DIV><FONT face=Arial size=2>>I haven't been
> able to solve this likely syntax problem despite<BR>> referring to these
> groups, the Books On Line, and reference texts:<BR>> <BR>> Without the use
> of Data Transformation Services in SQL Server Express,<BR>> what techniques
> work to import/export data between databases under the<BR>> same server
> instance?<BR>> <BR>> The specific example I was working on involved an
> attempt to run an<BR>> update query to place data from a specific field in an
> older copy of an<BR>> otherwise identical database into a more recent
> copy.&nbsp; Ultimately I<BR>> just plugged the small data series in manually
> using side-by-side views<BR>> because I could not overcome the syntax errors
> generated in the effort<BR>> to refer to the "external" database.<BR>>
> <BR>> This is the setup in question:<BR>> - An instance in the format of
> "MyComputerName\SQLExpress," and both an<BR>> - "OldDatabase" and<BR>> -
> "NewDatabase" attached and viewable from the Management Studio<BR>> Express,
> with identical fields<BR>> <BR>> I tried a few different query techniques
> as suggested in historical<BR>> posts, but to no avail.&nbsp; Here is such an
> example that I tried:<BR>> <BR>> In MSE I right clicked on the target
> table in question and chose:<BR>> "Script table as," then<BR>> "UPDATE
> to," then<BR>> "New Query Editor Window"<BR>> <BR>> I removed all the
> fields except that in question and added this Where<BR>> clause:<BR>>
> UPDATE [NewDatabase].[dbo].[Table]<BR>>&nbsp;&nbsp; SET [Field] =
> [OldDatabase].[dbo].[Table].[Field]<BR>> WHERE
> [NewDatabase].[dbo].[Table].[PK] =<BR>>
> [OldDatabase].[dbo].[Table].[PK]<BR>> <BR>> in which the primary key (an
> auto-increment integer) is identical<BR>> between the new and old
> tables.<BR>> <BR>> This produces the error:<BR>> Msg 4104, Level 16,
> State 1, Line 1<BR>> The multi-part identifier "OldDatabase.dbo.Table.PK"
> could not be<BR>> bound.<BR>> <BR>> If I understood from prior posts,
> using joins is less desirable in<BR>> update queries, but even so likewise
> produced errors when I tried that<BR>> approach.<BR>> <BR>> I would be
> grateful if someone could explain the proper syntax to refer<BR>> to another
> database within the same server instance or otherwise.<BR>> <BR>> Many
> thanks!<BR>></FONT></BODY></HTML>
> --=_NextPart_000_01FC_01C6FB8D.01E3E1B0--
|||Thank you for replying
I thought this post was considered dead, so I elected to repost the
question on microsoft.public.sqlserver.server. The syntax proposed by
"amish" on that group proved to work:
UPDATE [TestNew].[dbo].[tblProcedure]
SET [CPT] = TestOld.[CPT]
FROM [TestNew].[dbo].[tblProcedure] TestNew inner join
[TestOld].[dbo].[tblProcedure] TestOld
on
TestNew.[procedureID]=TestOld.[procedureID]
Hugo Kornelis wrote:
> On 30 Oct 2006 11:19:51 -0800, John Hackert wrote:
>
> Hi John,
> Please post the COMPLETE query, and the COMPLETE error message. Use copy
> and paste to prevent errors. That information can help us pinpoint the
> problem.
> --
> Hugo Kornelis, SQL Server MVP
sql

Monday, March 19, 2012

Importing fixed field length files

Hi,
Im importing data from a file, and saving it into a table, nothing complex.
The file contains fixed length fields, and the table is integers ( default
NULL ). When a value in the file is NULL, it is simply a series of spaces
indicating no value.
When EM parses the spaces, instead of inserting NULL into the table (because
it didn't find a digit), it complains about incompatable types?
Is the parsing engine really so stupid that it cannot convert spaces to a
single NULL when it knows it should be looking for numbers?!
How can i make this work?
Jeo
Does no-one know how to do the conversion?
"JoeB" <joe@.kybert__***NO_SPAM*sdfsdfsd****___.com> wrote in message
news:e$f0MfchEHA.3944@.tk2msftngp13.phx.gbl...
> Hi,
> Im importing data from a file, and saving it into a table, nothing
> complex.
> The file contains fixed length fields, and the table is integers ( default
> NULL ). When a value in the file is NULL, it is simply a series of spaces
> indicating no value.
> When EM parses the spaces, instead of inserting NULL into the table
> (because it didn't find a digit), it complains about incompatable types?
> Is the parsing engine really so stupid that it cannot convert spaces to a
> single NULL when it knows it should be looking for numbers?!
>
> How can i make this work?
>
> Jeo
>
>
|||Hiya,
There are two ways I can think of doing this, the quick dirty way and
the complicated clever way,
1.Import the integer into a text field and then use an update
query to populate the interger field. You can then use a combination
of trim and case statements to get the values you want. It'll work,
but not ideal.
2.I assume you're using DTS to import the data. In which case
you can change the transformation the this column from a simple copy
column to a an activeX script. You can then create some VB script to
change the value to null if it finds all spaces.
If it was me then it would depend on whether this is a one off or a
regular job. For a one off I would do option 1, if I'm going to have
to do this regularly then I would take the time and do option 2.
Darious
On Tue, 24 Aug 2004 11:12:19 +0100, "JoeB"
<joe@.kybert__***NO_SPAM*sdfsdfsd****___.com> wrote:

>Does no-one know how to do the conversion?
>
>"JoeB" <joe@.kybert__***NO_SPAM*sdfsdfsd****___.com> wrote in message
>news:e$f0MfchEHA.3944@.tk2msftngp13.phx.gbl...
>
|||Cheers, Im going to try option one as i cannot write VB code.
Thanks.
Joe
"Darious" <news@.areyoukidding.com> wrote in message
news:q2dni0haq1pemlcbvmnpbmg37js7q5a5em@.4ax.com...
> Hiya,
> There are two ways I can think of doing this, the quick dirty way and
> the complicated clever way,
> 1. Import the integer into a text field and then use an update
> query to populate the interger field. You can then use a combination
> of trim and case statements to get the values you want. It'll work,
> but not ideal.
> 2. I assume you're using DTS to import the data. In which case
> you can change the transformation the this column from a simple copy
> column to a an activeX script. You can then create some VB script to
> change the value to null if it finds all spaces.
> If it was me then it would depend on whether this is a one off or a
> regular job. For a one off I would do option 1, if I'm going to have
> to do this regularly then I would take the time and do option 2.
> Darious
> On Tue, 24 Aug 2004 11:12:19 +0100, "JoeB"
> <joe@.kybert__***NO_SPAM*sdfsdfsd****___.com> wrote:
>

Monday, March 12, 2012

importing datetime data

My flat file I import to the table is set up as 2004/06/16 09:40:07.994 comma delimited, and i import this using DTS into a datetime field. but when I run a query on the table, the only thing I see is 2004/06/16 showing up, how come I can't see the time?
Thx for your help!What tool are you using to query the table? It may be set to display DATETIME values as only the date (this is common if using the regional settings on the client with an ODBC based tool).

-PatP

Importing date w/SQLExpress appends '.000' to field

Hello
I have a DOB field in text file I am importing into an SQLExpress database
with the field data type is set to 'datetime'. For some reason the date
imports as 1958-08-01 00:00:00.000 ( with a decimal and 3 zeros appended to
the end of the field ). What am I doing wrong? There is no time associated
with this date in the flat file.
Thanks for your help...Dale,
That is the normal action for a datetime. The datetime datatype includes
hours, minutes, seconds, and milliseconds. If you store a date (without the
time value), the default time is midnight, or 00:00:00.000.
If possible, you may wish to change the datatype for the DOB field to
smalldatetime. Smalldatetime will have only hours and minutes for the time
portion -but they too will be set to the default, midnight, e.g., 00:00.
When you retrieve data, you can always remove the time portion either in the
data retrieval query, or in the display application or reporting
application. For T-SQL, look in Books Online for "CAST and CONVERT" for
information about datetime formats.
Likewise, if you were to have a field that you wanted only time values, and
if you inserted [12:45 PM] into that field, SQL Server will add the default
date value, 01/01/1900.
I hope this helps understand what is going on, and points you in a direction
to more relevant information.
Regards,
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"Dale" <dale@.nospam.com> wrote in message
news:OOMGHdxwGHA.3964@.TK2MSFTNGP04.phx.gbl...
> Hello
> I have a DOB field in text file I am importing into an SQLExpress database
> with the field data type is set to 'datetime'. For some reason the date
> imports as 1958-08-01 00:00:00.000 ( with a decimal and 3 zeros appended
> to the end of the field ). What am I doing wrong? There is no time
> associated with this date in the flat file.
> Thanks for your help...
>|||Thanks Arnie
I guess what threw me is the behaviour isn't consistent sometimes the import
has the '.000' appended and other times not despite having the data type as
datetime and the flat file is always the same.
But at least you indicated it wasn't something I was doing.
"Arnie Rowland" <arnie@.1568.com> wrote in message
news:%23O$VCnywGHA.1484@.TK2MSFTNGP04.phx.gbl...
> Dale,
> That is the normal action for a datetime. The datetime datatype includes
> hours, minutes, seconds, and milliseconds. If you store a date (without
> the time value), the default time is midnight, or 00:00:00.000.
> If possible, you may wish to change the datatype for the DOB field to
> smalldatetime. Smalldatetime will have only hours and minutes for the time
> portion -but they too will be set to the default, midnight, e.g., 00:00.
> When you retrieve data, you can always remove the time portion either in
> the data retrieval query, or in the display application or reporting
> application. For T-SQL, look in Books Online for "CAST and CONVERT" for
> information about datetime formats.
> Likewise, if you were to have a field that you wanted only time values,
> and if you inserted [12:45 PM] into that field, SQL Server will add the
> default date value, 01/01/1900.
> I hope this helps understand what is going on, and points you in a
> direction to more relevant information.
> Regards,
> --
> Arnie Rowland, Ph.D.
> Westwood Consulting, Inc
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
>
> "Dale" <dale@.nospam.com> wrote in message
> news:OOMGHdxwGHA.3964@.TK2MSFTNGP04.phx.gbl...
>> Hello
>> I have a DOB field in text file I am importing into an SQLExpress
>> database with the field data type is set to 'datetime'. For some reason
>> the date imports as 1958-08-01 00:00:00.000 ( with a decimal and 3 zeros
>> appended to the end of the field ). What am I doing wrong? There is no
>> time associated with this date in the flat file.
>> Thanks for your help...
>

Importing date w/SQLExpress appends '.000' to field

Hello
I have a DOB field in text file I am importing into an SQLExpress database
with the field data type is set to 'datetime'. For some reason the date
imports as 1958-08-01 00:00:00.000 ( with a decimal and 3 zeros appended to
the end of the field ). What am I doing wrong? There is no time associated
with this date in the flat file.
Thanks for your help...Dale,
That is the normal action for a datetime. The datetime datatype includes
hours, minutes, seconds, and milliseconds. If you store a date (without the
time value), the default time is midnight, or 00:00:00.000.
If possible, you may wish to change the datatype for the DOB field to
smalldatetime. Smalldatetime will have only hours and minutes for the time
portion -but they too will be set to the default, midnight, e.g., 00:00.
When you retrieve data, you can always remove the time portion either in the
data retrieval query, or in the display application or reporting
application. For T-SQL, look in Books Online for "CAST and CONVERT" for
information about datetime formats.
Likewise, if you were to have a field that you wanted only time values, and
if you inserted [12:45 PM] into that field, SQL Server will add the defa
ult
date value, 01/01/1900.
I hope this helps understand what is going on, and points you in a direction
to more relevant information.
Regards,
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"Dale" <dale@.nospam.com> wrote in message
news:OOMGHdxwGHA.3964@.TK2MSFTNGP04.phx.gbl...
> Hello
> I have a DOB field in text file I am importing into an SQLExpress database
> with the field data type is set to 'datetime'. For some reason the date
> imports as 1958-08-01 00:00:00.000 ( with a decimal and 3 zeros appended
> to the end of the field ). What am I doing wrong? There is no time
> associated with this date in the flat file.
> Thanks for your help...
>|||Thanks Arnie
I guess what threw me is the behaviour isn't consistent sometimes the import
has the '.000' appended and other times not despite having the data type as
datetime and the flat file is always the same.
But at least you indicated it wasn't something I was doing.
"Arnie Rowland" <arnie@.1568.com> wrote in message
news:%23O$VCnywGHA.1484@.TK2MSFTNGP04.phx.gbl...
> Dale,
> That is the normal action for a datetime. The datetime datatype includes
> hours, minutes, seconds, and milliseconds. If you store a date (without
> the time value), the default time is midnight, or 00:00:00.000.
> If possible, you may wish to change the datatype for the DOB field to
> smalldatetime. Smalldatetime will have only hours and minutes for the time
> portion -but they too will be set to the default, midnight, e.g., 00:00.
> When you retrieve data, you can always remove the time portion either in
> the data retrieval query, or in the display application or reporting
> application. For T-SQL, look in Books Online for "CAST and CONVERT" for
> information about datetime formats.
> Likewise, if you were to have a field that you wanted only time values,
> and if you inserted [12:45 PM] into that field, SQL Server will add th
e
> default date value, 01/01/1900.
> I hope this helps understand what is going on, and points you in a
> direction to more relevant information.
> Regards,
> --
> Arnie Rowland, Ph.D.
> Westwood Consulting, Inc
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
>
> "Dale" <dale@.nospam.com> wrote in message
> news:OOMGHdxwGHA.3964@.TK2MSFTNGP04.phx.gbl...
>

Friday, March 9, 2012

Importing data problem - Field Properties

Hi,

I'm trying to import data to my database on the live server from my local server. However when I do this it doesn't seem to be importing the properties for the fields in the tables. How can I import the properties of the fields too?

Thanks,

Curt.

What do you mean by properties? And how are you doing the import?

Wednesday, March 7, 2012

Importing data from Excel to SQL

I populate SQL tables with excel data and need to have one of the fields be <NULL>.

The field is a DateTime field and when imported places a date of 1900-01-01 00:00:00.000 I need that field to be NULL. Is there a way to represent NULL in excel so when it is importing it is not transformed to a date?

ThanksThe problem is not how your data is represented in Excel, but how it is being imported, or possibly the defaults on your SQL table. How are you importing the Excel data?

blindman

Sunday, February 19, 2012

Importing Access table into SQL Server 2005 Express table and adding one field

Hi all,

Hopefully I am posting this question in the correct forum. I am still learning about SQL 2005. Here is my issue. I have an access db that I archive weekly into and SQL server table. I have used the dst wizard to create an import job and initally that worked fine. field I have as the primary key in the access db cannot be the primary key in the sql table since I archive weekly and that primary key field will be imported several time over. I overcame this initally by not having a primary key in the sql table. This table is strictly for reference. However, now I need to setup a unique field for each of the records in the sql table. What I have done so far is create a recordID field in the sql table that is an int and set as yes to Identify (auotnumber). That worked great and created unique id for all existing records. The problem now is on the import. When I try to import the access table i am getting an error because of the extra field in the sql table, and the error is saying cannot import null value into this field. So... my final question is how can I import the access table into the sql table with one extra field which is the autonumber unique field? Thanks a bunch for any asistance.

Bill

Do not select that identity column in your destination adapter.|||Forgive my ignorance, but i am not sure what you are saying. I am still pretty new with SQL Server.|||

Flanman wrote:

Forgive my ignorance, but i am not sure what you are saying. I am still pretty new with SQL Server.

You are using SSIS, right?|||Never mind. I found what you were saying and it works like a champ. Simple. Thanks a bunch for the help.|||

Flanman wrote:

Never mind. I found what you were saying and it works like a champ. Simple. Thanks a bunch for the help.

Excellent! Glad you got it.

Phil

Importing a TXT file to MSSQL

hi, I have a TXT file with several fields with semicolom between fields.

But after Importing is done, Decimal field Dont appears with
comma.

in other words , if I type in a DataBase using Enterprise Manager 123,45678 I get exactily 123,45678, but from
Txt file I get 1234568.

what do i missing?
Tks
Carlos Lages
ps. Txt files is "12345678" even I put Txt file "123,45678"
I get the same result in databaseIn your table definition is the field a character field or numeric? What data type is it? This is just a thought, but maybe during the import job, DTS? is treating the field as some form of numeric field and ignoring the "," as that is not relevant..

Hope this helps, or am i on the wrong track?

Originally posted by Carlos lages
hi, I have a TXT file with several fields with semicolom between fields.

But after Importing is done, Decimal field Dont appears with
comma.

in other words , if I type in a DataBase using Enterprise Manager 123,45678 I get exactily 123,45678, but from
Txt file I get 1234568.

what do i missing?
Tks
Carlos Lages
ps. Txt files is "12345678" even I put Txt file "123,45678"
I get the same result in database