Showing posts with label error. Show all posts
Showing posts with label error. Show all posts

Tuesday, March 27, 2012

Convert

Hi All,
Sample:-
Declare @.xx varchar(10)
select @.xx = '1x'
select convert(int, @.xx) && Error
а?i_ΥX error , H_P System .
] @.xx @., ?Twi Convert.
Thanks !Hi
What are you trying to do? 1x is not an integer value!
You may want to look at the undocumented procedure xp_varbintohexstr to
convert a varbinary value to a hexadecimal string:
declare @.hexstr varchar(100)
declare @.bin varbinary(10)
set @.bin = 0xAA
set @.hexstr = ''
exec master.dbo.xp_varbintohexstr @.bin, @.hexstr output
print @.hexstr
-- Or use cast/convert to change back
select convert(int, @.bin), CAST(@.bin as int )
John
"SOHO" wrote:

> Hi All,
> Sample:-
> Declare @.xx varchar(10)
> select @.xx = '1x'
> select convert(int, @.xx) && Error
> ?D°Y¥i§_¤£¥?¥X error , ¥H_P System °±¤?.
> |]?° @.xx ¥??°¤@.??|ì, ?ê??¤£?T?w¥i Convert.
>
> --
> Thanks !
>
>|||Hi John Bell,
Thanks for your reply.
а?pib SQL Server Online Books ?o_ function
"master.dbo.xp_varbintohexstr" ?k,
Χ??_?Oiw, iO "1x+&2" or "abcxyz", thanks.
Thanks !
"John Bell" <jbellnewsposts@.hotmail.com> glsD:7921B130-EB91-49BC-B88E-1C3E06A55A3
9@.microsoft.com...
> Hi
> What are you trying to do? 1x is not an integer value!
> You may want to look at the undocumented procedure xp_varbintohexstr to
> convert a varbinary value to a hexadecimal string:
> declare @.hexstr varchar(100)
> declare @.bin varbinary(10)
> set @.bin = 0xAA
> set @.hexstr = ''
> exec master.dbo.xp_varbintohexstr @.bin, @.hexstr output
> print @.hexstr
> -- Or use cast/convert to change back
> select convert(int, @.bin), CAST(@.bin as int )
> John
> "SOHO" wrote:
>|||Hi
Unfortunately the your character set is not being displayed correctly, so I
am not sure if you are wanting a reply!
John
"SOHO" wrote:

> Hi John Bell,
> Thanks for your reply.
> ?D°Y|p|ó¥i|b SQL Server Online Books ?Y¨ì3o_ó function
> "master.dbo.xp_varbintohexstr" ao¥?ak,
> ¤?§úao?ü??_è?O¤£¥i1w′
ao, ¥iˉ_?O "1x+&2" or "abcx
yz", thanks.
>
>
> --
> Thanks !
>
> "John Bell" <jbellnewsposts@.hotmail.com> ???g?ó?l¥ó·s?D:7921B130
-EB91-49BC-B88E-1C3E06A55A39@.microsoft.com...
>
>|||John Bell skrev:

> Hi
> Unfortunately the your character set is not being displayed correctly, so=
I
> am not sure if you are wanting a reply!
> John
>
Huh? What part of " =A4=CE=A7=DA=AA=BA=C5=DC=BC=C6=AD=C8=ACO
=A4=A3=A5i=B9w=
=B4=C1=AA=BA,
=A5i=AF=E0=AC"
did you not understand ;)
/impslayer, also |||I am easily !
I hope that was not rude!!!
John :)
"impslayer" wrote:

> John Bell skrev:
>
> Huh? What part of " ¤?§úao?ü??_è?O¤£¥i1w′
ao,
> ¥iˉ_?"
> did you not understand ;)
> /impslayer, also
>

Conversion query

I have 2 date variables passed into my store procedure as follows
@.StartDate datetime,
@.EndDate datetime
however I am getting a conversion error when running the command below which
says "Syntax error converting datetime from character string"
PRINT ('INSERT INTO ' + @.NewSubsList + '(SubRef)
SELECT DISTINCT SubRef
FROM Subscriptions
WHERE (PubCode = ' + @.PubCode + ') AND DateEntered >= ' + @.StartDate +
') AND (DateEntered <= ' + @.EndDate + ')')
Any suggestions would be welcome.
ThanksYou have to explictly cast the datetime values to characters like so
PRINT ('INSERT INTO ' + @.NewSubsList + '(SubRef)
SELECT DISTINCT SubRef
FROM Subscriptions
WHERE (PubCode = ' + @.PubCode + ') AND DateEntered >= '
+ Cast(@.StartDate As VarChar(20))
+ ') AND (DateEntered <= ' + Cast(@.EndDate As VarChar(20)) + ')')
Thomas
"Pete" <Pete@.discussions.microsoft.com> wrote in message
news:E78EE524-27E2-47AF-96E4-60B250AFA884@.microsoft.com...
>I have 2 date variables passed into my store procedure as follows
> @.StartDate datetime,
> @.EndDate datetime
> however I am getting a conversion error when running the command below whi
ch
> says "Syntax error converting datetime from character string"
> PRINT ('INSERT INTO ' + @.NewSubsList + '(SubRef)
> SELECT DISTINCT SubRef
> FROM Subscriptions
> WHERE (PubCode = ' + @.PubCode + ') AND DateEntered >= ' + @.StartDate +
> ') AND (DateEntered <= ' + @.EndDate + ')')
> Any suggestions would be welcome.
> Thanks

Conversion problems between mssql and access

Hello

When I trying to insert data with datatype datetime or smalldatetime from SQL Server into a table in a linked access database I get this error :

Server: Msg 257, Level 16, State 3, Line 1
Implicit conversion from data type smalldatetime to float is not allowed. Use the CONVERT function to run this query.

I dont understand why it try to insert it as a float?!Because from a SQL Server point of view DateTime values ARE float values.

So you cannot do an implict cast but you have to do explictly by using the T-SQL statement "CONVERT"

Look in Books On Line for better help on conversions.|||Hello

I have tried CONVERT. But I dont know to which datatype I should convert my source value.
I have converted to varchar and nvarchar but I still got the same error.|||can you post your code, and specify from what kind of data type you what convert to?|||INSERT INTO LINKEDACCESS...ContactTarget
Select ChangedBy, ChangedDate, PersonIdNo,IdNo,TargetCode,TargetCodeproductCode,T argetCodePotentialCode
from tblContactTarget
WHERE Id NOT IN(select Id from LINKEDACCESS...ContactTarget CT
WHERE CT.Target = tblContactTarget.TargetCode)

ChangedDate is of datatype Datetime in SQL and Date/Time in Access.
This INSERT will trigger the error I wrote about.|||Try to convert it to a varchar. use the CONVERT function so that you can even specify the dateformat you need to have

Sunday, March 25, 2012

Conversion of int data type error?!

Hi,

I keep getting the error:

System.Data.SqlClient.SqlException: Conversion failed when converting the varchar value '@.qty' to data type int.

When I initiate the insert and update.

I tried adding a: Convert.ToInt32(TextBox1.Text), but it didn't work..

Could someone help?

My code:

private bool ExecuteUpdate(int quantity)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\ASPNETDB.MDF;Integrated Security=True;User Instance=True";

con.Open();

SqlCommand command = new SqlCommand();
command.Connection = con;
TextBox TextBox1 = (TextBox)FormView1.FindControl("TextBox1");
Label labname = (Label)FormView1.FindControl("Label3");
Label labid = (Label)FormView1.FindControl("Label13");

command.CommandText = "UPDATE Items SET Quantityavailable = Quantityavailable - '@.qty' WHERE productID=@.productID";
command.Parameters.Add("@.qty", TextBox1.Text);
command.Parameters.Add("@.productID", labid.Text);
command.ExecuteNonQuery();

con.Close();
return true;
}

private bool ExecuteInsert(String quantity)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\ASPNETDB.MDF;Integrated Security=True;User Instance=True";

con.Open();

SqlCommand command = new SqlCommand();
command.Connection = con;
TextBox TextBox1 = (TextBox)FormView1.FindControl("TextBox1");
Label labname = (Label)FormView1.FindControl("Label3");
Label labid = (Label)FormView1.FindControl("Label13");

command.CommandText = "INSERT INTO Transactions (Usersname,Itemid,itemname,Date,Qty) VALUES (@.User,@.productID,@.Itemsname,@.date,@.qty)";
command.Parameters.Add("@.User", System.Web.HttpContext.Current.User.Identity.Name);
command.Parameters.Add("@.Itemsname", labname.Text);
command.Parameters.Add("@.productID", labid.Text);
command.Parameters.Add("@.qty", Convert.ToInt32(TextBox1.Text));
command.Parameters.Add("@.date", DateTime.Now.ToString());
command.ExecuteNonQuery();

con.Close();
return true;
}

protected void Button2_Click(object sender, EventArgs e)
{
TextBox TextBox1 = FormView1.FindControl("TextBox1") as TextBox;
ExecuteUpdate(Int32.Parse(TextBox1.Text) );
}

protected void Button2_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "Update")
{
TextBox TextBox1 = FormView1.FindControl("TextBox1") as TextBox;
ExecuteInsert(TextBox1.Text);
}
}

Thanks so much if someone can!

Jon

Hi,

I think the problem lies in your Command Text. Try this:


command.CommandText = "UPDATE Items SET Quantityavailable = Quantityavailable - " + @.qty +" WHERE productID=@.productID";

Hope this helps.

|||

Hi,

I tried it but it gave me a different error message saying qty doesnt exist.

But actually the update seems to work - I think the problem lies with the insert commands..

Thanks,

Jon

|||

In your original post, you need to remove the single quotes around @.qty.

|||

sswanner1:

In your original post, you need to remove the single quotes around @.qty.

Hi,

I put them in when I got a syntax error 'near WHERE'..

If I take them away the error comes back..

|||

command.Parameters.Add("@.qty", TextBox1.Text); //need to convert into integer like Convert.ToInt32(TextBox1.Text)

TextBox.Text is string rather than integer. You need to valify and convert it to integer.


|||

Hi,

You mean just change the update parameter to the same as the insert parameter (@.qty)?

If so, I have done that but it still gives the same error...

Thanks,

Jon

|||

int qty = 0;
TextBox TextBox1 = (TextBox)FormView1.FindControl("TextBox1");

if(TextBox1 != null)

{

qty = int.parse(TextBox1.Text);

}

catch{}

command.CommandText = "UPDATE Items SET Quantityavailable = Quantityavailable -@.qty WHERE productID=@.productID";
command.Parameters.Add("@.qty",qty);
command.Parameters.Add("@.productID", labid.Text);
command.ExecuteNonQuery();

Following my code, and do it for both methods. And, you need to do same for @.productId.|||

Hi,

che3358:

if(TextBox1 != null)

{

qty = int.parse(TextBox1.Text);

}

catch{}

Gives me a squiggly before catch{}, saying 'try' is expected? then when I type try it gives more syntax errors?

Thanks,

Jon

|||

You will have to convert TextBox1.text to int . Try using ,

int qty = int.parse(TextBox1.text);

command.Parameters.Add("@.qty",SqlDbType.Int);

command..Parameters["@.qty"].Value = qty ;

|||

My fault. It should be

if(TextBox1 != null)

{

try

{

qty = int.parse(TextBox1.Text);

}

catch{}

}



|||

Hi again,

Now it gives the error:

CS0117: 'int' does not contain a definition for 'parse'

Line 40: qty = int.parse(TextBox1.Text);
 
??
Thanks again!
Jon 

|||

int.Parse. Sorry.

|||

Hi,

New error:

CS0103: The name 'int32' does not exist in the current context

Line 40: qty = int32.parse(TextBox1.Text);
 
Cheers
Jon 

|||

it needs to be exactly as :

qty = int.Parse(TextBox1.Text);

Tim

Conversion from vb.net 1.0 to vb.net 2.0 (Crystal Reports Error)

i am facing the crystal reports error when i convert my project from vb.net 1.0 to 2.0. can any one tell me how i remove these errors

waiting ........

you havn't said what the errors are. AND this is not the forum for your question.

You will be waiting a long time.

sqlsql

conversion from 'text' to 'int' is not supported

Changing the data type of a column (from text to int) in a saved table the
following error occurs:
conversion from 'text' to 'int' is not supportedHi,
yes this is correct, SQL Server does not allow text-> int on int->text
see the explicit and implicit data type conversions chart in bol (see the
CONVERT function)
VT
Knowledge is power, share it...
http://oneplace4sql.blogspot.com/
"jrb" <jrb@.discussions.microsoft.com> wrote in message
news:5CB28555-F612-4318-AA60-7290E0DAF26D@.microsoft.com...
> Changing the data type of a column (from text to int) in a saved table the
> following error occurs:
> conversion from 'text' to 'int' is not supported
>

conversion from 'text' to 'int' is not supported

Changing the data type of a column (from text to int) in a saved table the
following error occurs:
conversion from 'text' to 'int' is not supportedHi,
yes this is correct, SQL Server does not allow text-> int on int->text
see the explicit and implicit data type conversions chart in bol (see the
CONVERT function)
VT
Knowledge is power, share it...
http://oneplace4sql.blogspot.com/
"jrb" <jrb@.discussions.microsoft.com> wrote in message
news:5CB28555-F612-4318-AA60-7290E0DAF26D@.microsoft.com...
> Changing the data type of a column (from text to int) in a saved table the
> following error occurs:
> conversion from 'text' to 'int' is not supported
>

Thursday, March 22, 2012

conversion from CHAR to DATETIME error

on a column DateNew = DateTime

i am trying :
INSERT INTO [dbo].[Users] (DateNew) VALUES ('2003/01/31 10:04:14')

and i get an error :
conversion of char data type to datetime data type resulted in an out of range datetime value

I had never this error before , do you know why ?
i must enter a yyyy/mm/dd format because this database will be used for Fr and Us langages

thank you for helpingIm not getting any error with ur insert statement.I think u are passing date value as a variable which is in char.

try trim that variable on both side using ltrim,rtrim before inserting.|||lookup SET DATEFORMAT in Books online. Maybe that would help.|||You can try this -
insert <tablename>
select convert(datetime,'2003/01/31 10:04:14')

Well, for more info check this out...
http://groups.google.co.in/group/microsoft.public.sqlserver.programming/browse_frm/thread/ada70fc46e7005ac/419fae5346ac4bc0?lnk=st&q=dateformat()+in+ms+sql+server+200&rnum=3&hl=en#419fae5346ac4bc0|||try this instead --

INSERT INTO [dbo].[Users] (DateNew) VALUES ('2003-01-31 10:04:14')|||INSERT INTO [dbo].[Users] (DateNew) VALUES ('2003/01/31 10:04:14')

insert <tablename>
select convert(datetime,'2003/01/31 10:04:14')

or this one

try this instead --

INSERT INTO [dbo].[Users] (DateNew) VALUES ('2003-01-31 10:04:14')
__________________

These statements all are working fine in my machine also,so no problem in statements...I think mailler made a point ..plz check that.
Joydeep|||i got it with
INSERT INTO [dbo].[Users] (DateNew) VALUES (convert(datetime,'2003/01/31 10:04:14',111))

thank you|||i got it with convert(datetime,'2003/01/31 10:04:14',111)

thank you|||I know that I'm being pendantic here, but I'd invest a bit of time now into making your application much more portable/flexible/etc. The ISO 8601 (http://www.iso.org/iso/en/prods-services/popstds/datesandtime.html) format for date/time information is CCYY-MM-DD HH:MM:SS.TTT and that format is used by virtually the entire computing universe. It has been adopted by W3C (http://www.w3.org/TR/NOTE-datetime) which means that almost anywhere you find time on the Internet, you'll find it in this format.

You'll almost certainly save yourself lots of time and energy if you switch to using this format now, instead of having to switch to it later!

As a side note, if you expect your application to grow to the point where you may need to support more than one server, I'd suggest you spend the time to convert your application to use UCT (aka GMT) now too... This is easy to do up front, and almost impossible to do "after the fact" due to many very difficult problems caused by different locales.

-PatP|||...due to many very difficult problems caused by different locales...
PatP
You mean time zones, right?|||You mean time zones, right?You can think of the problem that way, but it is really more complex than just time zone... A locale rolls the problem up into a nice tidy (but not simple bundle). Time zones reflect a difference between local time and UCT, essentially a time offset. The problem comes from Daylight Savings Time, where different locales observe different shift dates, not all of which adjust by the same amount (some only move 30 minutes).

Unravelling the mess is easy if done while recording an event because it is easy for a computer to find UCT from its local time if necessary. Once the time is stored, there may not be any way to recover true UCT again. This gets really hard to explain, but there have been a couple of good whitepapers done on the problem.

-PatP|||Thanks a lot I shall do it at once but HOW do you convert a normal date into ISO 8601 ?

what is the SQL command for it ?|||for the moment I store all my dates time inthe format
yyyy/MM/dd hh:mm:ss

2000/12/31 18:50:06
I have just to replace / by - ?

thanks a lot|||for the moment I store all my dates time inthe format
yyyy/MM/dd hh:mm:ss

2000/12/31 18:50:06
I have just to replace / by - ?

thanks a lotYes! Exactly.

This is a relatively small change "up front", but it makes your date/time format match the format used by nearly everything else. That makes your code much easier to port to other programming languages, databases, etc at a later time. It is a small investment up front, that can pay off hugely in the future.

As a side note, SQL Server stores the data internally in a completely different form... Once you get the data into a column or variable, the work has been done. The only place you need to change anything is in the actual conversion from a character representation to a DATETIME.

-PatP|||Pat I did it , I have inserted 100 rows in my SQL database
in the good format but the database seems change it for the french format
31/12/2005 18:20:45

Once you get the data into a column or variable
I store the date in a datetime format column ?!

thanks a lot

and for searching any row in my database where a date
>
<
=
<>
=<
<=
to another date but on the date not on the datetime (yyyy-MM-dd) ?|||What is actually happening is that the database stores the value internally as a bunch of bits... They don't look like anything to the average human eye, and are logically close to a pair of integer counters. When your application retrieves the DATETIME value, the client component of the software converts those bits to a human readable form based on the locale that I mentioned in an earlier post, and the rules for that conversion happen to make the converted text appear "French" on your machine.

There are a number of ways to search for dates within a range (such as entered at any time on a given date). I prefer to do this by finding the minimum value (the very start of the day, at midnight) and the maximum value (or just past the maximum value if that is easier), then finding values between the minimum and maximum that I've selected. So for instance to find values that happened on Saint Valentine's Day 2006, I'd use:SELECT *
FROM myTable
WHERE '2006-02-14' <= myDate -- Note "equals"
AND myDate < '2006-02-15' -- Note no "equals"Using this logic is a bit strange at first, but it allows the database to use indicies to find dates of interested quickly and easily. That makes it possible to pick the rows for one day out of ten years worth of data in seconds instead of hours!

-PatP|||you helped me a lot Pat !!! in a few answers more than a few weeks looking everywhere, thanks a TON

a last question !!

I am using now

WHERE CONVERT(CHAR(10), myDate, 120) = CONVERT(CHAR(10), myDateValue, 120)

it is very easy with server side language to generate it, but for the database on millions of rows (the application will be very big) is it faster or slower than your method ?

WHERE '2006-02-14' <= myDate AND myDate < '2006-02-15'

because with your method I must add a day to the normal date and it is more complicated for server side programming

thanks again for helping|||I am using now

WHERE CONVERT(CHAR(10), myDate, 120) = CONVERT(CHAR(10), myDateValue, 120)

it is very easy with server side language to generate it, but for the database on millions of rows (the application will be very big) is it faster or slower than your method ?slower, much slower

first of all, you don't have to convert a datetime value such as '2006-02-15' to datetime, as you do on the right side of that condition, because the database will treat it that way (as a datetime value) by default

however, if you convert your table column to a string, as you do on the left side of that condition, then the database cannot use the index, if any, on that column, and will do a table scan

in other words, performing a function on a column means that the condition is not sargable (http://netknowledgenow.com:81/CS/blogs/onmaterialize/archive/2006/01/11/65.aspx) (this link is not working today but it was fine yesterday, it's a really good explanation -- you can also do a quick search to find other articles which also explain that word)|||then i must absolutly keep this only way ? :

SELECT FROM myTable
WHERE '2006-02-14' <= myDate AND myDate < '2006-02-15'

but in my database datetimes are stored in that was yyyy/mm/dd hh:mm:ss
and for the moment i couldnt get any row comparing yyyy/mm/dd hh:mm:ss to yyyy/mm/dd

of course the column is a datetime datatype|||then i must absolutly keep this only way ? :

SELECT FROM myTable
WHERE '2006-02-14' <= myDate AND myDate < '2006-02-15'that is the only way to achieve good performance (except you need to change the first operand from <= to >=)

but in my database datetimes are stored in that was yyyy/mm/dd hh:mm:ssno, actually, they are not stored that way -- datetimes are stored as two integers|||and is it better to use a datetime columns or a smalldatetime
all my dates are starting after 2000 ?

thank you|||that depends on whether you need precision in the time|||smalldatetime : Date and time data from January 1, 1900, through June 6, 2079,
with an accuracy of one minute

datetime :Date and time data from January 1, 1753, through December 31, 9999,
with an accuracy of 3.33 milliseconds

if i dont need (who needs ?) a precision of 1 minutes is it better for performances on millions of rows to use smalldatetime ?|||now I get all int that way and it seems to work :

-----------

>= 2006-02-10

SELECT FROM Users
WHERE (DateColumn > '2006-02-11')

-----------

< 2006-02-10

SELECT FROM Users
WHERE (DateColumn < '2006-02-10')
-----------
<= 2006-02-10

SELECT FROM Users
WHERE (DateColumn < '2006-02-11')
-----------

= 2006-02-10
SELECT FROM Users
WHERE
(DateColumn >= '2006-02-10')
AND
(DateColumn < '2006-02-11')

-----------

<> 2006-02-10

SELECT FROM Users
WHERE
(DateColumn > '2006-02-11')
OR
(DateColumn <= '2006-02-10')
-----------

>= 2006-02-15

SELECT FROM Users
WHERE (DateColumn < '2006-02-15')|||if i dont need (who needs ?) a precision of 1 minutes is it better for performances on millions of rows to use smalldatetime ?Yes, a SMALLDATETIME will perform better than a DATETIME for many reasons. Maybe looking at things from the machine's perspective will help (and maybe that will just confuse issues even more):DECLARE @.d DATETIME, @.s SMALLDATETIME

SELECT @.d = GetUTCDate()
SELECT @.s = @.d

SELECT @.d, Convert(VARBINARY(20), @.d)
SELECT @.s, Convert(VARBINARY(20), @.s)

SELECT @.d = DateAdd(minute, 1, @.d)
SELECT @.s = @.d

SELECT @.d, Convert(VARBINARY(20), @.d)
SELECT @.s, Convert(VARBINARY(20), @.s)-PatP|||thanks again a lot Pat that was really usefull, a deep help

thank you to everybody|||2006-02-16 03:10:53.967 | 0x0000976A00346E9E

2006-02-16 03:11:00 | 0x976A00BF

2006-02-16 03:11:53.967 | 0x0000976A0034B4EE

2006-02-16 03:11:53.967 | 0x0000976A0034B4EE

2006-02-16 03:12:00 | 0x976A00C0

here is the result of your Query
not easy to read and understand|||hard to understand?

these numbers -- 0x0000976A00346E9E, 0x976A00BF -- show you exactly how datetime values are stored internally in sql server

:)|||not easy to read and understandThe results show a couple of the issues that I was trying to explain, in a concrete form (so we don't have to talk abstractly, but can deal with real values. Please bear with me, this explanation is long, but I think it will help.

The first two results show the difference between a DATETIME (as displayed in character form) and how that DATETIME value converts to both raw binary (on the same line), and how it converts to a SMALLDATETIME (which appears one line down), and also to the SMALLDATETIME expressed as raw binary. All of the values are different, but they represent the same moment in time in different ways!

A DATETIME is accurate to +/- 3 milliseconds (I know the docs say 3.33, but that is a case where the doc writers took some liberty with what is actually stored... There's no such thing as a third of a bit). It is actually stored as a bunch of bits that mean very little to the untrained eye, except for one minor thing I'll get to later.

A SMALLDATETIME is accurate to +/- 1 minute. When you assign a DATETIME to a SMALLDATETIME, rounding takes place to the nearest whole minute. The same time is represented in a slightly less acurate form. The binary value is also quite a bit smaller, and radically different.

As an interesting side note (of little practical value), note that the value 976A appears in both of the binary strings (although in different places). This is not an accident. It has to do with how the date values are actually stored.

Another more interesting note is that the binary values of a DATETIME and the corresponding SMALLDATETIME are not directly comparable. If you take the time to understand the details, you can work around this, but it is of very little use except as an academic exercise.

Things become a bit more interesting when we add a minute to the original DATETIME value. The character form makes it easy to see this addition, and it makes perfect sense.

When we convert the changed DATETIME value to a SMALLDATETIME, the same rounding takes place, and the binary values are still quite different from each other.

The interesting part comes when you compare the binary values of the DATETIME before and after adding a minute, and the binary values of the SMALLDATETIME before and after adding a minute. The important part to notice is that the binary values of the later values have larger binary values too! There is a direct, one to one relationship between the time and the corresponding binary value.

This is why Rudy pointed out earlier that computing the minimum and maximum values of interest was much more efficient than converting the date values to character form and comparing them... You can convert a DATETIME into many different character forms, most of which are not usable for range computations like this, so in order to search for a character form SQL Server has to query every possible row. SQL Server understands dates as either DATETIME or SMALLDATETIME values, and knows how to search an index for values in a specific range. This means that it can "ride the index" to only the rows of interest in your range, and it knows exactly when it has reached the end of that range. For large sets of data, this is MANY times more efficient!

-PatP|||wow ! perfect !
I never like to apply something without understanding it
now I get a better idea of the way SQL is working with dates

and I think that generally i need only smalll
datetime datatype, i had never used it before

thanks a lot once more !|||One more thing to throw out, just so you don't get surprised... The SMALLDATETIME datatype allows entry of temporal (time based) values from 1900-01-01 through 2079-06-06 23:39. This is fine for many purposes (I won't be alive to deal with any problems it might cause when it runs out, and I sincerely doubt that SQL Server will still be in use (at least in its present form) 70 years from now! However, many contracts (like Japanese mortgages) already extend well past that limit, so I usually use DATETIME even though a SMALLDATETIME would do.

I'm a lazy bum... If I can code/create something once then safely forget about it, I'll almost always do that instead of something a bit simpler that will work for a while, but might be a problem for me (or my successor) in the future. I won't do a lot of work to avoid a potential problem, but I'll do easy things to avoid getting a call at 03:00 wondering why a job failed and how soon can I get it fixed!

-PatP|||Pat your code works fine for me in SQL 2005, but a customer with SQL 2000 get errors again everywhere on dates, i have started a new thread here >> http://dbforums.com/showthread.php?t=1212861

i am really lost with dates .. and i dont know what to do

thanks again

Conversion failed when converting the varchar value


I keep receiving this error:

Conversion failed when converting the varchar value 'INSERT INTO temp_tableZ (Customer_Category_Key, Item_Category_Key, Sales_Rep_Key, time_member_key, Revenue, Fiscal_Year ) select Customer_Category_Key, Item_Category_Key, Sales_Rep_Key, ' to data type int

When running the code below. I believe the problem has something to do with the @.time_member_key in the dynamically created SELECT statement. However, I don't understand the problem or how to fix it.

Can anyone provide some advice?

thank you,

Erik

droptable temp_tableZ
go

createtable temp_tableZ(
Customer_Category_Key INTNULL,
Item_Category_Key INTNULL,
Sales_Rep_Key INTNULL,
Revenue moneyNULL,
time_member_key INTNULL,
Fiscal_Year INTNULL)
go

dropprocedure temp_testA
go

createprocedure temp_testA as
BEGIN
declare @.time_member_key asint
declare @.calendar_date_dt asdatetime
declare @.FY0YTD asMONEY
declare @.sql_string asnvarchar(1024)
set @.calendar_date_dt ='10/1/2005'
while @.calendar_date_dt <'9/30/2006'
BEGIN

select @.time_member_key = time_member_key
from dim_time
where @.calendar_date_dt = dim_time.calendar_date_dt

SET @.sql_string =
'INSERT INTO temp_tableZ'+' ('+
'Customer_Category_Key, '+ 'Item_Category_Key, '+ 'Sales_Rep_Key, '+ 'time_member_key, '+
'Revenue, '+ 'Fiscal_Year '+ ') '+

'select Customer_Category_Key, Item_Category_Key, Sales_Rep_Key, '+ @.time_member_key +', sum(Revenue), 2006'+char(13)+
'from Fact_Sales t1, dim_time t2 '+char(13)+
'where t1.time_member_key = t2.time_member_key'+char(13)+
'and t1.time_member_key < '+ @.time_member_key +char(13)+
'and t2.Fiscal_Year = 2006'+char(13)+
'group by Customer_Category_Key, Item_Category_Key, Sales_Rep_Key, '+ @.time_member_key +char(13)+
'go '

EXECsp_executesql @.sql_string

set @.calendar_date_dt = @.calendar_date_dt + 1

END

END

GO

execute temp_testA

You need to convert @.time_member_key to an NVARCHAR(x), see below.

Read this document on 'Data Type Precedence' to find out why:

http://msdn2.microsoft.com/en-us/library/ms190309.aspx

Chris

SET @.sql_string =

'INSERT INTO temp_tableZ' +' (' +

'Customer_Category_Key, ' + 'Item_Category_Key, ' + 'Sales_Rep_Key, ' + 'time_member_key, ' +

'Revenue, ' + 'Fiscal_Year ' + ') ' +

'select Customer_Category_Key, Item_Category_Key, Sales_Rep_Key, ' + CAST(@.time_member_key AS NVARCHAR(20)) + ', sum(Revenue), 2006' + char(13) +

'from Fact_Sales t1, dim_time t2 ' + char(13) +

'where t1.time_member_key = t2.time_member_key' + char(13) +

'and t1.time_member_key < ' + CAST(@.time_member_key AS NVARCHAR(20)) + char(13) +

'and t2.Fiscal_Year = 2006' + char(13) +

'group by Customer_Category_Key, Item_Category_Key, Sales_Rep_Key, ' + CAST(@.time_member_key AS NVARCHAR(20)) + char(13) +

'go '

Conversion failed when converting from a character string to uniqueidentifier. - PLEASE HE

I am trying to store a unique identifier that is text into a field in a SQL DB that is type uniqueidentifier and I get the follow error message.

Conversion failed when converting from a character string to uniqueidentifier.

My Code is shown below:

comSQL.Parameters.AddWithValue("@.PROPERTYID", Format(Request.QueryString("ID").ToString,"{0:########-####-####-####-############}"))

This has worked before but isnt' anymore. Any ideas?

jsmith3465:

comSQL.Parameters.AddWithValue("@.PROPERTYID", Format(Request.QueryString("ID").ToString,"{0:########-####-####-####-############}"))

have you tried as...

comSQL.Parameters.AddWithValue("@.PROPERTYID",New Guid(Format("werwerwerwerwerwerwerwerwerwerwe","{0:########-####-####-####-############}")))

|||

I tried adding the New Guid() and that did not solve the problem either. Anymore ideas? I am trying to convert Text to Unique Identifier for storage in SQL Server 2005.

Thanks for all of your help!

Ryan

Conversion failed when converting from a character string to uniqueidentifier.

Hi, i have a problem, i keep getting this Error.

I want to insert an uniqueidentifier using a textbox, i use the following code to insert.

SqlDataSource1.InsertParameters[

"RWID"] =newParameter("RWID",TypeCode.String, RWID);

SqlDataSource1.Insert();

The databasetype is an uniqueidentifier of that column.

Anyone who can help me with this problem?

Hi friend,

Have you tried TypeCode.Object

|||

I tried using TypeCode.Object, then I get another error:

Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query.

|||

Hi friend,

I tried a sample to reproduce the error. But it its working fine for me. I created a table named t1 with one column c1 of datatype unique identifier.

SQL datasource code

<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:iGoldWebConnectionString %>"

SelectCommand="SELECT * FROM [T1]"InsertCommand="insert into t1 values(@.g)" ></asp:SqlDataSource>Data Insert Code

SqlDataSource1.InsertParameters["g"] =newParameter("g",TypeCode.String,Guid.NewGuid().ToString());

SqlDataSource1.Insert();

Its working fine for me.

I hope the problem is with the guid which you get from textbox . Have you checked you receive only valid GUID.

Conversion failed when converting datetime from character string

Hi,

I receive an Error Message: Conversion failed when converting datetime from character string when I try to run this.

Can someone point out what I'm doing wrong?

SELECT Principal,

SUM(CASE WHEN Recdate BETWEEN '=@.LYbegin' AND '=@.LYend' THEN

Amount ELSE 0 END) AS LY,

SUM(CASE WHEN Recdate BETWEEN '=@.TYbegin' AND '=@.TYend' THEN

Amount ELSE 0 END) AS TY

FROM dbo.Checks

GROUP BY Principal

If I execute the query with the dates it works fine:

SELECT Principal,

SUM(Case When RecDate BETWEEN '1-1-2005 00:00:00.000' AND '1-30-2005 00:00:00.000' THEN Amount else 0 end)AS LY,

SUM(Case When RecDate BETWEEN '2-1-2005 00:00:00.000' AND '2-28-2005 00:00:00.000' THEN Amount else 0 end)AS TY

FROM Checks

GROUP BY Principal

Thanks,

Terry McCullagh

I suppose you are trying to use a parameterized query statement in the RS query designer. You should use the following commandtext to have query parameters being detected and working:

SELECT Principal,
SUM(CASE WHEN Recdate BETWEEN @.LYbegin AND @.LYend THEN Amount ELSE 0 END) AS LY,
SUM(CASE WHEN Recdate BETWEEN @.TYbegin AND @.TYend THEN Amount ELSE 0 END) AS TY
FROM dbo.Checks
GROUP BY Principal

-- Robert

|||

Robert,

That works great.

Thank you,

Terry McCullagh

Conversion failed when converting character string to smalldatetime data type

I am newbie in asp and sql, and I am using VS & SQL express

when I try to submit I get following error

"Conversion failed when converting character string to smalldatetime data type"

Following is my insert statement

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:oncallConnectionString %>"

SelectCommand="SELECT data.* FROM data" InsertCommand="INSERT INTO data(Apps, Location, Impact, System, Date, Start_Time, End_Time, Duration, Problem, Cause, Solution, Case, Comments) VALUES ('@.DropDownList1','@.DropDownList2','@.DropDownList3','@.TextBox6','@.DropDownCalendar1','@.DropDownCalendar2','@.DropDownCalendar3','@.TextBox1','@.TextBox2','@.TextBox3','@.TextBox4','@.TextBox5','@.TextBox7')">

</asp:SqlDataSource>

These are @.DropDownCalendar1','@.DropDownCalendar2','@.DropDownCalendar3' defined as datetime in database.

I would appriciate if somebody could help.

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:oncallConnectionString %>"

SelectCommand="SELECT data.* FROM data" InsertCommand="INSERT INTO data(Apps, Location, Impact, System, Date, Start_Time, End_Time, Duration, Problem, Cause, Solution, Case, Comments) VALUES (@.DropDownList1,@.DropDownList2,@.DropDownList3,@.TextBox6,@.DropDownCalendar1,@.DropDownCalendar2,@.DropDownCalendar3,@.TextBox1,@.TextBox2,@.TextBox3,@.TextBox4,@.TextBox5,@.TextBox7)">

</asp:SqlDataSource>

|||

Now I am getting following error

Must declare the scalar variable "@.DropDownList1".

How do I do it in asp, I found the syntax for declare statement but don't know how put it in asp?

Thanks

|||Go to the design view, right click the sqldatasource, choose properties, then choose the selectcommand. A dialog should open, in there you can add all your parameters for the select.|||

I did that and still getting same error

after changes it looks like this

<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:oncallConnectionString %>"

SelectCommand="SELECT data.* FROM data"InsertCommand="INSERT INTO data(Apps, Location, Impact, System, tDate, Start_Time, End_Time, Duration, Problem, Cause, Solution, DW_Case, Comments) VALUES (@.DropDownList1,@.DropDownList2,@.DropDownList3,@.TextBox6,@.DropDownCalendar1,@.DropDownCalendar2,@.DropDownCalendar3,@.TextBox1,@.TextBox2,@.TextBox3,@.TextBox4,@.TextBox5,@.TextBox7)">

<SelectParameters>

<asp:FormParameterFormField="DropDownList1"Name="@.Apps"/>

<asp:FormParameterFormField="DropDownList2"Name="@.Location"/>

<asp:FormParameterFormField="DropDownList3"Name="@.Impact"/>

<asp:FormParameterFormField="TextBox6"Name="@.System"/>

<asp:FormParameterFormField="DropDownCalendar1"Name="@.tdate"/>

<asp:FormParameterFormField="DropDownCalendar2"Name="@.Start_time"/>

<asp:FormParameterFormField="DropDownCalendar3"Name="@.End_time"/>

<asp:FormParameterFormField="TextBox1"Name="@.Duration"/>

<asp:FormParameterFormField="TextBox2"Name="@.Problem"/>

<asp:FormParameterFormField="TextBox3"Name="@.Cause"/>

<asp:FormParameterFormField="TextBox4"Name="@.Solution"/>

<asp:FormParameterFormField="TextBox5"Name="@.DW_case"/>

<asp:FormParameterFormField="TextBox7"Name="@.Comments"/>

</SelectParameters>

</asp:SqlDataSource>

I really appreciate your.

Thanks

|||I also tried doing samething with insert parameter and still no luck|||You have to call them the same thing. @.DropDownList1=@.Apps. Change one to the other and repeat for all parameters. Either change the insert statement, replacing @.DropDownList1 with @.Apps, *OR* change the parameter "@.Apps" to use the name "@.DropDownList1".|||

Motley

I really appreciate your help,

And a BIG Thanks to you.Big Smile

sqlsql

Conversion errors on date field from Access to SQL server7

Hi
1st time trying to migrate Access 2000 tables to SQLServer7.
The tables transport but I'm getting errors on the data transfer.

The error is based on the date/time field in Access...ex: DOB (DateofBirth) field is formatted as shortdate.

When the error occurs in transport it reads:
Error at Destination for Row number 310...
Insert error, column 16('DOB', DBTYPE_DBTIMESTAMP), status 6. Data overflow. Invalid character value for cast specification.

**What I have found so far is that this error occurs on the rows in the DOB field where the year of birth is before 1900 (ie:1897)...or in some instances if the year is mistakenly in as...example: 9194 (as opposed to 1994) it will not except the transfer.

I have created a mock table with a date/time field of this format (with all the years being in 2002) and it transfers fine!

Any ideas on how I get the SQL Server to accept these records??use datetime rather than smalldatetime.

valid datetime range is 1-Jan-1753 to 31-Dec-9999 23:59:59.9999|||I did convert the SQL field to datetime...but it still gives conversion errors on date fields that are in the 1800's!!??!!

If I change those to 01/01/1900...they will transfer.|||I must be missing the point... if the date is '01-Jan-1897' it would go into a datetime field with out problems. can you provide an example of a trouble maker?|||Here goes...there were some records that had dates like this:
01/01/9194
01/01/1897
01/01/1583 etc...

You had mentioned that if I changed the SQL field to datetime from smalldatetime (which I had already done)...then it would tranfer data from 1-Jan-1753 to 31-Dec-9999

Well...after I changed the field to datetime the records, such as, 01/01/1897 wouldn't transfer...even though they were in the valid range for datetime.

[And if I changed all the records that were before the year 1900 to a date after 1900 it would transfer].

Hope this clears it up.|||thanks!

You may have other problems here, consider the following code:

declare @.dt datetime, @.vc varchar(100)
set @.dt = '01/01/9194'
set @.vc = cast(@.dt as varchar)
select @.dt, @.vc
set @.dt = '01/01/1897'
set @.vc = cast(@.dt as varchar)
select @.dt, @.vc
set @.dt = '01/01/1583'
set @.vc = cast(@.dt as varchar)
select @.dt, @.vc

As one would expect the last date is a problem. Could you import the date data into a varchar field and then selectivly convert the data?

Conversion error when calling stored procedure

Hi all,
I want to execute a stored procedure from a report. The stored procedure
takes nvarchar(50) parameters. When I call the procedure from a report with
string paramerers, I get the error 'Implicit conversion from data type
sql_variant to varchar is not allowed'. But, I cannot Cast or Convert my
reporting services parameters when calling Exec to run the stored procedure.
Help! Anyone experience this kind of problem before? Any suggestions are
welcome!hey.
Not sure why it happens as I get those all the time to. I have found that
if i create a make the first dataset something simple, like the query to
populate a parameter drop down list, then add a second data source I can then
call the execute statement for the proc. Boqus I know but it works. Buggy
software is my quess, I think it may have been the service pack as I did not
do this a few months back.
hth
"Bas" wrote:
> Hi all,
> I want to execute a stored procedure from a report. The stored procedure
> takes nvarchar(50) parameters. When I call the procedure from a report with
> string paramerers, I get the error 'Implicit conversion from data type
> sql_variant to varchar is not allowed'. But, I cannot Cast or Convert my
> reporting services parameters when calling Exec to run the stored procedure.
> Help! Anyone experience this kind of problem before? Any suggestions are
> welcome!
>

conversion error after promoting to production box

Problem: data conversion component going from unicode DT_WSTR to DT_STR with 1252 codepage using a Source Provider=IBMDADB2.1;

So.. I developed the package on the testdb without any errors. However, when I promote the package to the production box, I get this conversion error. I thought that it was specific to one column, so I set the ignore truncation error in the data flow. The next column provided then caused the same error.

what settings can I look at changing to prevent this error?

what data is being truncated or is the unicode conversion map failing?

the max(length) is 270 on a varchar 300. I also read something about tabs in this type of conversions failing?

Why would this be specific to the box? I have checked the collation on both DB's and they are SQL_Latin1_General_CP1_CI_AS

what is the normal workaround for this? is AlwaysUseDefaultCodePage a part of the solution?

<Error>The "output column "STATUSRENEWAL" (4477)" failed because truncation occurred, and the truncation row disposition on "output column "STATUSRENEWAL" (4477)" specifies failure on truncation.

</Error>

thanks for your time.

To find out the rows causing this, redirect the failing rows to error output and save it e.g. to a file.
The problem could be caused by Unicode characters in DT_WSTR columns that can not be represented by codepage 1252. The workaround would depend on what you are going to do with this? Are you OK with loss of information - then ignore the error; if not - don't convert Unicode data to single-byte code page; or maybe you need to cleanup the source data to avoid international characters that can't be fit to codepage 1252?sqlsql

Conversion ERROR

This is the error message I get: :(
Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

This is the query:
Select Qual_ins.CompanyCode, Qual_ins.ParticipantCode, Qual_ins.Ins_Code, Qual_ins.Plan_Code,
dbo.PremiumRate(Qual_Ins.Crit,Qual_Ins.PQB_Spec,Pl an_Mas.Extend_Fee,
Qual_Ins.Adjpremium,Qual_Ins.Adjpremiumper,Qual_In s.Adjpremend,
GetDate(),Qual_Ins.Cover_Amt, Plan_Mas.CR_A, Plan_Mas.CR_B,
Plan_Mas.CR_C, Plan_Mas.CR_D, Plan_Mas.CR_E, Plan_Mas.CR_F,
Plan_Mas.CR_G, Plan_Mas.CR_H, Plan_Mas.CR_I, Plan_Mas.CR_J,
Plan_Mas.CR_K, Plan_Mas.CR_L, Plan_Mas.CR_M, Plan_Mas.CR_N,
Plan_Mas.CR_O) AS PremiumRate
FROM Qual_ins, Plan_Mas
WHERE Qual_Ins.CompanyCode = 'ACME'
AND Qual_ins.ParticipantCode = 4
AND Plan_Mas.CompanyCode = Qual_ins.CompanyCode
AND Plan_Mas.Ins_Code = Qual_ins.Ins_Code
AND Plan_Mas.Plan_Code = Qual_ins.Plan_Code
Order BY Qual_ins.Ins_Code

Please let me know if you need to see my PremiumRate (User Defined Function) in order to help me elimate this error message.
Any help is appreciate!
I'm new to this... "Hello" to all!

ShuviBased on the error message, I'd guess that you are trying to convert a string (CHAR or VARCHAR) to a DATETIME or a SMALLDATETIME. If that is the case, then one or more rows in your data isn't a valid date string.

-PatP

Conversion error

Hi all,

Basically I am trying to create a package that will

(A) Create a table with specified datatypes

(B) Use a text Source file for the data

(C) on Success \ Completion of the "Execute SQL" transform the data from the text into the table.

Connect to DB <-- [TRANSFROM]-- Text (Source) <-- Execute SQL (Create Table)

It all seems to work now but when I run the package I get the following error

The number of failing rows exceeds the maximum specified.

TransformCopy 'DTSTransformation_6'conversion error: Conversion invalid for datatypes on column on pair 1 (source column 'Col007' (DBTYPE_STR),destination column 'Rec_Amt' (DBTYPE_CY)).

But when I go into the TransformDataTask, under transformation and test that column it all works fine, infact I tested all the columns and they all seem to work fine.

It also seems to be creating the same table twice first in the " Execute SQL" task and then again for some reason in the "DataTransform" task. I dont know if that is realted to the problem or not though.

Any idea's or suggestions I could try ?

Im very new to SQL 2000 & DTS so dont rule out any very newbie errors :)

Thanks

I'm not sure what steps you created, so I'm uncertain as to why it would duplicate the table. I would create one step to read the text file and create the table, and another to fill it. Here's a broad reference with guidelines, and if you have further questions you can check out Books Online for SQL Server 2000 to read more:

http://support.microsoft.com/default.aspx/kb/242377

Buck Woody

Conversion error

Hi all,

Basically I am trying to create a package that will

(A) Create a table with specified datatypes

(B) Use a text Source file for the data

(C) on Success \ Completion of the "Execute SQL" transform the data from the text into the table.

Connect to DB <-- [TRANSFROM]-- Text (Source) <-- Execute SQL (Create Table)

It all seems to work now but when I run the package I get the following error

The number of failing rows exceeds the maximum specified.

TransformCopy 'DTSTransformation_6'conversion error: Conversion invalid for datatypes on column on pair 1 (source column 'Col007' (DBTYPE_STR),destination column 'Rec_Amt' (DBTYPE_CY)).

But when I go into the TransformDataTask, under transformation and test that column it all works fine, infact I tested all the columns and they all seem to work fine.

It also seems to be creating the same table twice first in the " Execute SQL" task and then again for some reason in the "DataTransform" task. I dont know if that is realted to the problem or not though.

Any idea's or suggestions I could try ?

Im very new to SQL 2000 & DTS so dont rule out any very newbie errors :)

Thanks

I'm not sure what steps you created, so I'm uncertain as to why it would duplicate the table. I would create one step to read the text file and create the table, and another to fill it. Here's a broad reference with guidelines, and if you have further questions you can check out Books Online for SQL Server 2000 to read more:

http://support.microsoft.com/default.aspx/kb/242377

Buck Woody

conversion error

Hi, can anyone please shed some light on this error:

[OLE DB Destination [466]] Error: There was an error with input column "Price" (518) on input "OLE DB Destination Input" (479). The column status returned was: "Conversion failed because the data value overflowed the specified type.".

The column "price" is a numeric (9)

In the flat file connection manager, the datatype for the price column is a float [dt r4]. I've also tried numeric, etc.

How do I resolve this error?

Thanks much

Don't you have a scale on that Price column? Can't a price have cents?|||

Yes, the price has cents.

|||

sadie wrote:

Yes, the price has cents.

But you said the field is NUMERIC(9). There's no scale, so the cents (decimal) can't be stored.|||

Hmm,

here's what the database says, and the data looks like: xxx.xxxxxxxxxxxx, so that's correct.

type computed length prec scale Price numeric no 9 18 12

|||Okay, so it's a NUMERIC(18,12)

Seems weird for a price field as it can only hold $999. Anyway, back to the problem at hand.... Do you have data that exceeds $999?

EDIT: I apparently can't do math, everyone. I still had "9" stuck in my head. 12 - 9 = 3. Smile|||

I think I am missing something here.

According to this definition of the numeric datatype:

The numeric data type store numbers with a decimal place. When you use this data type you specify the precision (how many numbers total) and scale (how many numbers to the right of the decimal).

So wouldn't a numeric(18,12) be able to hold an 18 digit number with a MINIMUM of 6 digits on the left of the decimal point, and 12 digits on the right?

|||

Nevermind. There is a bad row in the data file. That is what is causing the overflow error.

Thanks

|||

sadie wrote:

I think I am missing something here.

According to this definition of the numeric datatype:

The numeric data type store numbers with a decimal place. When you use this data type you specify the precision (how many numbers total) and scale (how many numbers to the right of the decimal).

So wouldn't a numeric(18,12) be able to hold an 18 digit number with a MINIMUM of 6 digits on the left of the decimal point, and 12 digits on the right?

That is correct.

|||

sadie wrote:

I think I am missing something here.

According to this definition of the numeric datatype:

The numeric data type store numbers with a decimal place. When you use this data type you specify the precision (how many numbers total) and scale (how many numbers to the right of the decimal).

So wouldn't a numeric(18,12) be able to hold an 18 digit number with a MINIMUM of 6 digits on the left of the decimal point, and 12 digits on the right?

Yes, 18 specifies how many significant digits there are, while 12 of those 18 are to the right of the decimal point. Sorry, I'm losing my math mind, apparently.|||

No problem.

Your response gave me the idea to check my data file, and that's how I found the bad rows.