Importing A Csv Into Sql Server, Problems With Field Conversions

Nov 13, 2004

I'm importing a csv file into sql server and everything is working fine however here are my problems.





The csv file fields contain some money fields and even though my db column type is money the dts package console complains that my data type from the csv is of type string 'for the money value' and cannot be inserted into the db field because they don't match. I changed the db field to nvarchar and hey presto it works fine. Problem is that this is no good because the data in the db is no longer a money value and therefore I cannot query the way I should.





So basically how do i map my csv to pass its values as the right types instead of just string values. If this was in c# i could just assign the parameter types accordingly but I'm not sure how to with sqlservers dts package.





Any help!!!!!

View 2 Replies


ADVERTISEMENT

Problem Importing Data From An Access Memo Field Into A SQL Server Ntext Field.

Jul 11, 2005

I'm using DTS to import data from an Access memo field into a SQL Server ntext field.  DTS is only importing the first 255 characters of the memo field and truncating the rest.I'd appreciate any insights into what may be causing this problem, and what I can do about it.Thanks in advance for any help!

View 4 Replies View Related

Importing Of Varchar Field Data In Number Field

Dec 5, 2007

i want to import/copy a varchar field numeric data in to number field pls suggest the solution
one thing more can i convert field type of a table how?


jto it

View 5 Replies View Related

Parameter Conversions Question From SQL Server

Mar 22, 2004

I have a question regarding a casting error I recieve when I explictly assign a value to a value in a stored procedure.......
The value pstrLoginName is a public string defined in a code module
The stored procedure is NVARCHAR Datatypes.....

Here is the Stored Procedure

CREATE procedure dbo.Appt_GetPermissions_NET
(
@LoginName nvarchar(15),
@Password NvarChar(15),
@DeleteScan bit Output

)
as
select

@DeleteScan=UserP_DeleteScan
from
Clinic_Users
where
UserName = @LoginName
and
UserPassword = @Password

GO


Here is my error

Specified cast is not valid
Line 194: cmdsql.CommandType = CommandType.StoredProcedure
Line 195:
Line 196: parmLogin = cmdsql.Parameters.Add("@LoginName", SqlDbType.NVarChar, 15).Value = pstrLoginName
Line 197: parmPassword = cmdsql.Parameters.Add("@LoginPassword", SqlDbType.NVarChar, 15).Value = pstrLoginPassword
Line 198: parmDelete = cmdsql.Parameters.Add("@DeleteScan", SqlDbType.Bit)

my vb .net code to execute this

Public Sub ObtainPermission()


'get the needed data
Dim consql As New SqlConnection("Server=myserver;database=APPOINTMENTS;uid=webtest;pwd=webtest")
Dim cmdsql As New SqlCommand
Dim parmLogin As SqlParameter
Dim parmPassword As SqlParameter
Dim parmDelete As SqlParameter

cmdsql = New SqlCommand("Appt_GetPermissions_NET", consql)
cmdsql.CommandType = CommandType.StoredProcedure

parmLogin = cmdsql.Parameters.Add("@LoginName", SqlDbType.NVarChar, 15).Value = pstrLoginName <----error occurs here

parmPassword = cmdsql.Parameters.Add("@LoginPassword", SqlDbType.NVarChar, 15).Value = pstrLoginPassword <---I'm sure it will happen here then
parmDelete = cmdsql.Parameters.Add("@DeleteScan", SqlDbType.Bit)
parmDelete.Direction = ParameterDirection.Output

consql.Open()
cmdsql.ExecuteNonQuery()

'obtain rights

pstrPermissions = cmdsql.Parameters("@DeleteScan").Value
consql.Close()

End Sub

View 3 Replies View Related

DB Conversions - SQL Server 2000 X 2005 Express

Jun 1, 2006

Recently I decided to start using DotNetNuke, which uses an SQL Server database. My webhoster offers SQL Server 2000, and I was able to install and run DNN successfully there. However, I wish to have a local copy of DNN on my PC with the same contents as is on the web. It means that I need either to convert SQL Server 2000 database to my local SQL Server 2005 Express database, or vice versa.

Although I programmed in (Visual) FoxPro for many years, I am new to SQL Server and I am overwhelmed by the vast number of new terms. Can anyone tell me in simple English, how to perform the above mentioned conversions? My webhoster allows me to backup the SQL Server 2000 database in an *.sql file, but how shall I convert this file into an SQL Server 2005 Express *.mdf file?

View 6 Replies View Related

Importing Access Table Into SQL Server 2005 Express Table And Adding One Field

Feb 16, 2007

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

View 7 Replies View Related

Importing A Time Field

Nov 15, 2000

I am attempting to import a text file into a Sql Server table. The file contains a time field. The column in the table that I am trying to import into is a Smalldatetime field. The data looks like this "10:30". I keep getting errors on the import of the time field. Any suggestions?

View 1 Replies View Related

SSIS And Importing A Bit Field

Jan 22, 2008

I'm trying to import a text file into a table. The table has a nullable bit field. The corresponding field in the file has Y/N rather than 1/0. I'm getting an error on that column "The value could not be converted because of a potential loss of data.". So I'm assuming I need to convert the Y/N to a 1/0 under the "derived columns" step. Is that correct and can someone tell me how to do that exactly?

Thanks

View 1 Replies View Related

Importing A Large Text Field

May 3, 2002

I'm importing a large text field from an Excel spreadsheet into my Sql dbase using Enterprise Manager and I'm getting the error message "Data for source column 31 'fieldname' is too large for the specified buffer size." How do I go about changing the buffer size to allow for larger text fields? Thank you.

View 1 Replies View Related

Problem Importing DB2 Date Field

Jul 25, 2001

I'm having a problem importing a table using DTS from DB2. It seems that SQL Server can't recognize the DB2 "Date" format (eg 07/25/2001), which includes no time element. I assumed that SQL Server would simply throw a 12:00 AM time on each date it encountered, but instead I get errors, and the fields aren't imported at all. Any ideas on how I can get SQL Server and DB2 to play nice while importing the date fields? Any and all suggestions would be greatly appreciated!

View 1 Replies View Related

Importing Data / Autonumber Field?

Sep 21, 2006

Hello--

I'm importing data from an Access table and, of course, one field is a primary key. This field needs to be an autonumber. The problem is the data I'm importing isn't sequential.

Can I import the data, then alter the table to make the column increment or is there a way to create the table and make the field increment, but import non-sequential data?

HELP!

Thanks,
grimey

View 2 Replies View Related

Importing Excel File With A Field?

Jul 23, 2014

I am import a file from Excel that has dates as this type 10:00 AM. When I import it into SQL, the field looks like this....

1899-12-30 10:00:00.000

How can I import this field to stay like 10:00 AM?

View 1 Replies View Related

Importing Data Problem - Field Properties

Nov 6, 2007

 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. 

View 1 Replies View Related

Err While Importing Data Containing Value Of Date Field Is Of Yrs.1800

Mar 15, 2006

hi Dear All

How can i import data in SQL Server 2000 which contains the value of date field from 1800 yrs to till now

eg. 15/12/1860, 10/10/1896, 10/10/2006

but if i change the year of date value to 19?? then it's imported.

anybody can help me please!

Thanks in advance

Rahman

View 3 Replies View Related

Problem Importing Data From Flat File Into Decimal(10,2) Field

Oct 30, 2007

Problem importing data from flat file into decimal(9,2) field. The data in the flat file is 000001453 and I am copying it to a decimal(10,2) field and instead of showing up in the 0000014.53 it comes across as 0001453.00. I tried defining the input columns a few different ways but none seemed to work. How do I do this with SSIS or do I need to write a SP and use convert? Thanks.

View 5 Replies View Related

Transact SQL :: BULK INSERT Not Importing Correct Data For Field?

May 14, 2015

I am using a BCP format file to import a CSV file. The file looks like the following:

"01","02"

The format file looks like the following:

6.0                                                                                     
2                                                                                      
1      SQLCHAR    0      0       """         0    ""
2      SQLINT       0      0       "",""     1   MROS
3      SQLINT       0      0       ""
"   2   MROF

When both the two fields are set to SQLCHAR data types the data imports successfully without the quotes as 01 and 02.  These fields will always be numbers and I want them as integers so I set the data type to int in the database and SQLINT in the format file.  The results was that the 01 became 12592 and the 02 became 12848.  where these numbers are coming from?

View 7 Replies View Related

About Date Conversions

Feb 19, 2008

 Hi All,    I struck by a issue, In a table(tblMemberPayments) i had two columns one is to hold (month) as CHAR and other one is to hold (year)  as INT. Now i need to implement search for this table based on the dates given , I mean i need to get the records from this table in between any two dates given by the user (Eg : feb 2007 to feb 2008). While retriving i am unable to type cast the things as required for the above case. I am getting an error unable to convert varchar to datetime while using CONVERT FUNCTION the same thing a raises while using DATEDIFF FUNCTION  .help me if any one knows the solution . here are the couple of ways i tried    1) 'CONVERT(varchar(10),(tblMemberPayments.ExpirationMonth + tblMemberPayments.Expirationyear),1) between CONVERT(varchar(10),''feb 2007'',1)       AND CONVERT(varchar(10),''feb 2008'',1)'  Msg 245, Level 16, State 1, Line 1Conversion failed when converting the varchar value 'Apr' to data type int. 2)'datediff(m,Cast(tblMemberPayments.ExpirationMonth + tblMemberPayments.ExpirationMonthint as datetime), ''Feb 2008'') >= 0 and datediff(m, cast(tblMemberPayments.ExpirationMonth + tblMemberPayments.ExpirationMonthint as datetime), ''Feb 2007'') <= 0'   Thanks & Regards,   Sudheer.Y    

View 2 Replies View Related

DATE CONVERSIONS

Jul 25, 2007

HI ALL,

declere @d varchar(10)
declare @t varchar(10)

set @d=convert(varchar,'7/25/2007 10:10:53',101)
set @d=convert(varchar,'7/25/2007 10:10:53',108)

it returns as
@d=7/25/2007
@t=7/25/2007

but @t should be equal to 10:10:53

what's wrong in the conversions


Malathi Rao

View 2 Replies View Related

Datetime Conversions

Dec 6, 2007

In my DB I have strings which are all 8 characters long and all pass the isDate == 1 thing so everything row can be converted into a date.

When I run a select convert(datetime, value) it gives me an error saying that it's unable to convert datetime from string. However when I insert everything into a temp table and run each row individually, it converts fine.

Any ideas as to what I'm doing wrong? I've checked the date settings on SQL 2005 SP2 and the host itself and everything seems correct. I've been stuck on this all day and any help is very much appreciated.

View 12 Replies View Related

Sum Column Values After Conversions

Apr 11, 2014

I have this query where I do certain conversions and on top of this how can I sum the column values.

'$ '+ Replace(CONVERT(varchar,CAST(Total_Amount AS money),1) ,'.00','') as Total_Amount,
'$ '+ Replace(CONVERT(varchar,CAST(Monthly_Amount As money),1),'.00','') as Monthly_Amount,

View 2 Replies View Related

Century Date Conversions

Jul 20, 2005

Hi,I'm trying to load date fields into SQLServer using DTS, but theformat of the raw data is the number of days since 1 Jan 1900. How doI convert this to a useful format, is there a standard conversionroutine?ThanksTim

View 2 Replies View Related

Data Type Conversions

Sep 25, 2006

What are the pros/cons of datatype conversions using the advanced properties of the source adapters or transformation components themselves vs. using the data conversion transformation? Sometimes I am able to do all the conversions I need using the advanced properties rather than use a data conversion component, but didn't know if this was considered bad practice, or has some other impact that isn't immediately apparent.

Thanks

Kory

View 2 Replies View Related

String To Date Conversions

Apr 6, 2006

Having some trouble converting strings to dates. I am using a .dtsx package and have figured out how to use a derived column to convert the string to a new string which is a valid date. The problem is now converting the column data type to date. I insert a new data conversion step to convert the vchar field to date, then when it runs it fails on this step. Error is

The conversion returned status value 2 and status text "The value could
not be converted because of a potential loss of data."


If I leave out the data conversion step and run the package, then manually change the data type to date it warns with the same message, but if I accept it converts correctly.

 

Here is my derived column code

REPLACE(SUBSTRING([Data Conversion 1].START_OF_EXECUTION,1,10) + " " +
RIGHT([Data Conversion 1].START_OF_EXECUTION,8),".",":")


Please Help

View 9 Replies View Related

SQL Data Type Conversions And DataRows

Sep 20, 2005

Hi all,I have a DataRow that I'm attempting to insert into SQL.  The row has an item I"ll refer to as row["AbsorbtionDeficiency"].  I'm filling this data row from a ODBC connection to a propriatary database.  Now I want to insert this data into SQL where the same row data type is "money".I'm not to familiar with the different data types, but the long and short of it is this.  When I build my SQL Insert statement, sometimes this value is blank, sometimes it's 0, and sometimes it will have a dollar amount(no formating  just the numeric).  How to I get this data out of the row in a format that SQL understands... Since I'm creating a  SQL string the datatype of the row I assume doesn't matter, so I"m doing a .ToString() when I build the statement.Do I need to do a CAST('0' AS MONEY) to each line that is money type?  Or is there an easier way?I would insert the code, but it's a pretty masive statement and I don't think it's really needed yet.ThanksJosh

View 1 Replies View Related

Sp_executesql Max 10 Data Type Conversions?

Apr 4, 2008

I can't get sp_executesql to accept more than 10 converted parameters in one execution. A stored procedure loops through a table variable that presents up to 100 parameters and their named data types. I've tried selecting into sql_variant and nvarchar variables and converting them to the named data type in the loop.
sp_executesql is outside the loop.
For the first 10 parameters sp_executesql recognizes the data type conversions of the variables that hold the parameter values, but then it fails to accept the conversions of the 11th and subsequent variables. Is there a limit to the number of conversions that sp_executesql can cope with?

View 5 Replies View Related

Derived Column - Date Conversions?!?

May 1, 2007

It was my understanding earlier that -- it is mandatory to have a Derived Column for a DATE String in a Flat File
to be loaded properly into a table with "datetime" column type

However, i tried running my package with the Input Column as "DT_STR" and the Destination on the table is DATETIME.

Looks like the process went on fine.. Am i missing something here?

My Date Format from the source looks like -- "DD-MON-YY"

Regards

View 1 Replies View Related

Import From Access - Datatype Conversions

Jul 6, 2006

I have to do a lot of inporting from Access files.  Is there a place where I can change the default datatype conversion for Access Text from nvarchar to varchar?

Thanks.

Kato

View 3 Replies View Related

How To Handle Multiple Column Conversions

Jan 26, 2006

I have multiple columns in a table that I only want to convert if they are not null or of the proper type. I don't really want to redirect the whole row if one of the conversions fails, rather I would just not want to do the cast or set it to another value. In this scenario is it better to use a custom script or multiple tasks? The multiple tasks seems like a lot of overhead for processing the same data. Just curious how others handle this scenario as it seems as though it has come up quite often on our current project? Thanks for the assistance.

-Krusty

PS: Is it possible to embed evaluation statements along with conversion statements in a task expression? e.g. (len(trim([Column1])) > 0) substring([Column1], 1, 4)

View 1 Replies View Related

Date Format Conversions In SSIS

Oct 11, 2006

Hi

I am quite new to SSIS and have been given the task of importing some data from a text file into the database. The data contains dates which are in the American format of mm/dd/yyyy. I need them in the datadase in the format of dd mon yy.

I realise I could load it and do a SQL task to convert once it is in the database but ideally i would like this data transformed before it is loaded into the tables.

any suggestions will be gratefully recieved.

Best regards

View 1 Replies View Related

Username Password Conversions On Upgrade To 2005

May 23, 2008

Am getting ready to perform upgrade/migrate from 2000 to 2005 and have concerns about all the usernames/passwords converting accurately, as the existing 2000 instance has hundreds of them (am used to conversions with few usernames/passwords). Any suggestions as to the best way to proceed. The upgrade/migration is being done on the same box. Will a straight upgrade convert the master db cleanly with u/p, what issues does a migration on the same box present? Thanks.

View 4 Replies View Related

Alter Table Type Conversions With Default

Apr 29, 2008

I'm trying to write some code that will alter column to change its type, in this case from Nvarchar to Int, but I'm not sure if there will be any columns that are uncovertable (say, there's a string that does not have an Int value). In this case, I'd like it to default to 0. Is there a way to write a T-SQL statement to do this, or will I have to write an UPDATE stamement first to clear out any problem cases?

View 1 Replies View Related

Informix Date Type Field To SQL Server Datetime Field Error

Oct 17, 2007



I am trying to drag data from Informix to Sql Server. When I kick off the package
using an OLE DB Source and a SQL Server Destination, I get DT_DBDATE to DT_DBTIMESTAMP
errors on two fields from Informix which are date data ....no timestamp part

I tried a couple of things:

Created a view of the Informix table where I cast the date fields as datetime year to fraction(5), which failed.

Altered the view to convert the date fields to char(10) with the hopes that SQL Server would implicitly cast them
as datetime but it failed.

What options do I have that will work?

View 1 Replies View Related

Odbc - Binding Sql Server Binary Field To A Wide Char Field Only Returns 1/2 The Daat

Jul 23, 2005

Hi ,Have a Visual C++ app that use odbc to access sql server database.Doing a select to get value of binary field and bind a char to thatfield as follows , field in database in binary(16)char lpResourceID[32+1];rc = SQLBindCol(hstmt, 1, SQL_C_CHAR,&lpResourceID,RESOURCE_ID_LEN_PLUS_NULL , &nLen1);and this works fine , however trying to move codebase to UNICODE antested the followingWCHAR lpResourceID[32+1];rc = SQLBindCol(hstmt, 1, SQL_W_CHAR,&lpResourceID,RESOURCE_ID_LEN_PLUS_NULL , &nLen1);but only returns 1/2 the data .Any ideas , thoughts this would work fine , nit sure why loosing dataAll ideas welcome.JOhn

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved