Fixed Decimal Convertion

Dec 6, 2007

I am trying to show latitude and longitude with 5 decimal points. Now its showing (for example: 55.744025477, -4.1256633333333 etc.). How do I get  data in 5 decimal points? 
Your help with example would be appreciated. 
 
aspx code:
  <asp:GridView  ID="GridView1" runat="server" DataSourceID="odsGPS" AllowPaging="true" AllowSorting="true"
    AutoGenerateColumns="False" CellPadding="1" CellSpacing="1" BackColor="White" GridLines="None"
    BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" PageSize="20" Width="100%" Font-Size="8pt"
    OnLoad="GridView1_Load" >
        <Columns>
            <asp:TemplateField HeaderText="Show">
                <ItemTemplate>
                    <asp:CheckBox ID="CheckBox2" onclick="MarkerForThisRow(this);" ToolTip="Click to show on map." runat="server" OnCheckedChanged="CheckBox2_CheckedChanged" />
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle HorizontalAlign="Center" />
            </asp:TemplateField>
                      
            <asp:BoundField DataField="Latitude"  HeaderText="Latitude ( ° )"  >
                <ItemStyle HorizontalAlign="Center"  />
                <HeaderStyle HorizontalAlign="Center" />
            </asp:BoundField>

            <asp:BoundField DataField="Longitude"  HeaderText="Longitude ( ° )" >
                <ItemStyle HorizontalAlign="Center" />
                <HeaderStyle HorizontalAlign="Center" />
            </asp:BoundField> 
 

View 9 Replies


ADVERTISEMENT

Fixed Decimal Places Without Rounding

Mar 1, 2001

What is the best way to force a 2 digit decimal place without rounding?
For example select price*UOM returns
47.1294
3.255
.5
8
.49

What i want to be returned is
47.12
3.25
8.00
.50
.49

Thanks,

Jim

View 3 Replies View Related

Transact SQL :: Convert Non Fixed Rows To Non Fixed Columns Dynamically?

Oct 5, 2015

I have a table with 3 columns  (ID Int , Name Varchar(25), Course Varchar(20))

My source data looks like below

ID      Name        Course
1        A                Java
1        A                C++
2        B                Java
2        B                SQL Server
2        B                .Net
2        B                 SAP
3        C                 Oracle

My Output should look like below...

ID      Name       Course(1)     Course(2)         Course(3)     Course(4)  

1        A                 Java            C++
2        B                 Java            SQL Server .Net             SAP
3        C                 Oracle

Basically need t-sql to Convert non fixed rows to non fixed columns...

Rule: IF each ID and Name have more than 1 course then show it in new columns as course(1) course(2)..Course(n)

Create SQL:

Create table Sample (ID Int null , Name  Varchar(25) null, Course Varchar(20) null)

Insert SQL:

INSERT Sample (ID, Name, Course)
          VALUES (1,'A','Java'),
                 (1,'A','C++'),
                 (2,'B','Java'),
                 (2,'B','SQL Server'),
                 (2,'B','.Net'),
                 (2,'B','SAP'),
                 (3,'C','Oracle')

View 12 Replies View Related

Legacy Database Uses Decimal Data Types.--&> AutomobileTypeId (PK, Decimal(10,0), Not Null) Why Not Integers Instead ?

Sep 26, 2007

I am working with a legacy SQL server database from SQL Server 2000. I noticed that in some places that they use decimal data types, that I would normally think they should be using integer data types. Why is this does anyone know?
 
Example: AutomobileTypeId (PK, decimal(10,0), not null)

View 5 Replies View Related

Data Type With Decimal Point For Decimal Values But Not For Whole Integers

Dec 8, 2013

I am creating a table on SQL Server. One of the columns in this new table contains whole integer as wells as decimal values (i.e. 4500 0.9876). I currently have this column defined as Decimal(12,4). This adds 4 digits after the decimal point to the whole integers. Is there a data type that will have the decimal point only for decimal values and no decimal point for the whole integers?

View 2 Replies View Related

Cast Or Convert Nvarchar With Comma As Decimal Separator To Decimal

Apr 29, 2008

Hello.

My database stores the decimals in Spanish format; "," (comma) as decimal separator.

I need to convert decimal nvarchar values (with comma as decimal separator) as a decimal or int.


Any Case using CAST or CONVERT, For Decimal or Int gives me the following error:

Error converting data type varchar to numeric



Any knows how to resolve.

Or any knows any parameter or similar, to indicate to the Cast or Convert, that the decimal separator is a comma instead a dot.

View 5 Replies View Related

Converting (casting) From Decimal(24,4) To Decimal(21,4) Data Type Problem

Jul 24, 2006

Hello!



I would like to cast (convert) data type decimal(24,4) to
decimal(21,4). I could not do this using standard casting function
CAST(@variable as decimal(21,4)) or CONVERT(decimal(21,4),@variable)
because of the following error: "Arithmetic overflow error converting
numeric to data type numeric." Is that because of possible loss of the
value?

Thanks for giving me any advice,

Ziga

View 6 Replies View Related

How Can I Use The Decimal Comma Instead Of Decimal Point For Numbers In Jet Engine?

Sep 19, 2007



I wanted to convert a dataset from vb.net (2.0) to an .XLS file, by MS Jet. My national standard is using decimal commas, not decimal points for numbers signing the beginning of decimal places.
But the MS Jet Engine uses decimal point,in default. Therefore, in the Excel file only string formatted cells can welcome this data, not number formatted.
How can I solve or get around this problem? (with jet if it possible)
iviczl

View 4 Replies View Related

Convertion

Mar 5, 2008

can any one help how to convert the 20070701( varchar data type)
to 'JUL-07'

View 4 Replies View Related

Converting Decimal To String W/O Decimal Point

Jul 23, 2005

I'd like to convert a Decimal value into a string so that the entireoriginal value and length remains intact but there is no decimal point.For example, the decimal value 6.250 is selected as 06250.Can this be done?

View 6 Replies View Related

Converting Decimal Point To Decimal Comma

Nov 30, 2007

Hi all,

I am designing some reports for a German branch of my company and need to replace decimal point with a comma and the thousand comma seperator with a decimal point.

e.g.
‚¬1,500,123.00 to ‚¬1.500.123,00

Is there a property that I can change in the report designer to allow this to happen or is this something I need to convert in a Stored Proc.

Any help would be much appreciated

Thanks!

View 5 Replies View Related

SQL Money Convertion,

Apr 24, 2005

Hi All,
 
Here in Belgium, we work with a comma as decimal seperator, also in all the web apps...
I've tried to update a money table on the sql with following statement
update parts set article = '" & art & "' and price= cast(" & p & "  as decimal(5,2)) where supid=202
in this example p is a variable and contains figures like 5,7
This statement always give following error Incorrect syntax near the keyword 'as'
does some have an idea how to fix this one ?
 
thx

View 4 Replies View Related

Data Convertion

May 15, 2008

Hi guys,

need your help.

what can I do to convert the ff:

00001250 to 000001250

what syntax should I use?

tnx

View 3 Replies View Related

Int To Datetime Convertion

Nov 19, 2007

Hi,

Actually i tried to convert the datetime value in yyyymmdd format from the int data type field.But except the first record it is looking fine.i cann't understand why this is happening? can you help me to resolve this problem?


Select ABECDT,case when ISDATE(cast(ABECDT as varchar))=1 then cast(ABECDT as varchar)
when len(cast(ABECDT as varchar))=8 then right(cast(ABECDT as varchar),4)+''+left(cast(ABECDT as varchar),2)+''+substring(cast(ABRDAT as varchar),3,2)
when len(cast(ABECDT as varchar))=7 then right(cast(ABECDT as varchar),4)+'0'+left(cast(ABECDT as varchar),1)+''+substring(cast(ABRDAT as varchar),2,2)
when len(cast(ABECDT as varchar))=6 then case when right(cast(ABECDT as varchar),2)<50 then '20' else '19' end
+right(cast(ABECDT as varchar),2)+''+substring(cast(ABECDT as varchar),3,2)+''+left(cast(ABECDT as varchar),2)
else NULL end from parm

Result i got it from the above query

Actual Value Result from the query

1101200120011111
1001200220021001
1201199819981201
2011998 19980210
6012002 20020601

Can anyone help me to resolve this?

Thanks and Regards

Senthil

View 2 Replies View Related

Date Convertion

Feb 28, 2008

can anybody tell how to convert the date into the below format
datetime 2007-12-01 00:00:00.000
To 20071201

View 14 Replies View Related

Convertion Problem

May 12, 2008



How to convert unicode string data into int.?????


My lookup shows up with this error when i map id column

TITLE: Microsoft Visual Studio
------------------------------
The following columns cannot be mapped:
[COPY OF IID, Id]
One or more columns do not have supported data types, or their data types do not match.
------------------------------
BUTTONS:
OK
------------------------------

View 1 Replies View Related

Data Convertion Error Help

Dec 15, 2006

Hi,
 I have an error: "*erro while update quantity. Error converting data type nvarchar to int "while i try update data through form page. Does anybody have any idea how can i correct the error??
 I didnt try two methods but both given same error and failed update: -
1)   Dim sqlcomm As New SqlCommand(sSaveQuote, rConnect).....
 sqlcomm.Parameters.AddWithValue("@employeeID", sUserID)            sqlcomm.Parameters.AddWithValue("@quantity", txtquantity.Text)
 
2) Error converting data type nvarchar to int ??        Dim rConnect As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("CRNS_CustomerConnectionString").ConnectionString)        Dim command As SqlCommand = New SqlCommand("UpdateOrder", rConnect)        command.CommandType = Data.CommandType.StoredProcedure
If OrderInfo.Verified.ToUpper = "True" Or OrderInfo.Verified = 1 Then
            command.Parameters.Add("@Verified", Data.SqlDbType.Bit)            command.Parameters("@Verified").Value = 1        Else            command.Parameters.Add("@Verified", Data.SqlDbType.Bit)            command.Parameters("@Verified").Value = 0        End If
  command.Parameters.Add("@Comment", Data.SqlDbType.VarChar, 100)        command.Parameters("@Comment").Value = OrderInfo.Comment
 command.Parameters.Add("@ProductID", Data.SqlDbType.Int)        command.Parameters("@ProductID").Value = OrderInfo.ProductID
        command.Parameters.Add("@OrderDate", Data.SqlDbType.SmallDateTime)        command.Parameters("@OrderDate").Value = OrderInfo.OrderDate
Cheers:)
Christe

View 3 Replies View Related

SQL Data Convertion Error??

Dec 19, 2006

HI,
I'm encouter some data convertion string problem especially during database update use asp.net (vb.net). Please help advice how can i solve the error??
I guess integer value need convert to string before able execute update function..
The error i get: -
1) failed to convert nvarchar to int
2) Convertion string is not in correct format...
let say i drag a textbox (txtquantity) and allow input and click update (with call procedure) updatexx set quantity=2 select from YY.
Wondering if i missed some important code??
Another data converting errorsituation is: let say i create a class call "AA" then have properties quantity as string, sProductID as string
i retrieve the data
........function get info(by ProductID as string) 
If reader.Read() Then            OrdInfo.quantity = reader("Quantity").ToString()            OrdInfo.ProductID = reader("ProductID").ToString()
.....
sub update BB (byval aa as AA)
...
   command.Parameters.Add("@Quantity", Data.SqlDbType.Int)        command.Parameters("@Quantity").Value = AA.quantity
        command.Parameters.Add("@ProductID", Data.SqlDbType.Int)        command.Parameters("@ProductID").Value = AA.sProductID
Cheers:)

View 1 Replies View Related

Monay Convertion Problems

Jan 15, 2008

Hi Guys:
I want to convert a String from .net to money in sql server 2005. I use VB.net and sql 2005 stored procedures too.
I don’t care if this convert is done in the .net side or in sql 2005 side.
This is the exactly case: as I am in south America, for currency or money data type the people write 1234,12 this is similar to the US format 1234.12 (we change the . for the , )
So I want let the people to introduce our format 1234,12 and in the database convert it to 1234.12My problem is that I pass it like string and in the database I do
CONVERT(MONEY,RTRIM(LTRIM(@payment)))
 But it converts my number 1234,12 in 123412.00 and this two number are not equivalent. Somebody can help me please?
thanks !
Marcos

View 3 Replies View Related

Date And Time Convertion

Jan 26, 2008

Hi, I am trying to update my database i am using the select statement:
SELECT PatientNo, ConsultantName, HospitalName, CONVERT (varchar, Date, 101), CONVERT (varchar, Time, 8) FROM [Appointment];
 however when i try to update this i am not able to select my date and time columns.
Thanks Mike

View 4 Replies View Related

Date Convertion Problem

Aug 16, 2005

I had the following user defined function working on a test server.

CREATE FUNCTION dbo.GetFirstDayOfWeek (@WeekNo Integer, @YearNo VarChar(4))
RETURNS DateTime AS
BEGIN
DECLARE @Date VarChar(10)
DECLARE @FirstDayOfWeek DateTime

SET @Date = '01/01' + @YearNo
SET @Date = CONVERT(VarChar(10), CONVERT(DateTime, @Date,101) - (DATEPART(DW, @Date)-1),101)
SET @FirstDayOfWeek = DateAdd(WW, @WeekNo-1, @Date)

RETURN @FirstDayOfWeek

END

It should return the date of the first day in the week when provided with a week number and year, however, the test server has been rebuilt and after transferring my database over, this function no longer works. I now get the error message "Syntax error converting DateTime from character string".

The database is exactly how it was on the previous test server build - could my problem be caused by the server being setup differently (i.e. different regional settings and therefore different date format) or am I completely missing something in the SQL?

Unfortunately I do not have enough rights on the server to check the SQL Server settings!

View 1 Replies View Related

SQL Server To Oracle Convertion

Oct 19, 2004

Hello experts...

Recently tried to covert one of my database table pub(authors) in Oracle9i
schema using SQL SERVER's "Import and Export Data". The convertion was succesful nut when i logged in Oracle and tried to select that authors table its show me error...

oracle shows its a table when i issue...

SQL> select * from cat;
TABLE_NAME TABLE_TYPE
------------------------------ -----------
BONUS TABLE
DEPT TABLE
EMP TABLE
SALGRADE TABLE
authors TABLE / * this table comes from SQL server */

but when i issued as..

SQL> select * from authors;
select * from authors
*
ERROR at line 1:
ORA-00942: table or view does not exist

So, Please help me anyone.I will greatfull to him...Thnaks a Lot.

View 3 Replies View Related

Convertion VarChar Error

Jan 12, 2005

Ive got a small problem at the moment

I have ran a query that has been used for a while now and have recieved this error


Server: Msg 245, Level 16, State 1, Line 3
Syntax error converting the varchar value 'N' to a column of data type int.


Ive searched the data and the only value of N that i can find is currently sitting in a field where the field type is varchar

is there a workaround for this, Ive tried running a case statement to set the N to 0 and also tried casting

Cheers in advance
Dave

View 4 Replies View Related

Datatype Convertion Prob

Dec 4, 2007

Hi Friedns,



I am transfering data from oledb source to excel destination i am getting this error





error : First name cannot be converted unicode datatype to non-unique code datatype



any body plz help me





Thx

subu


Meti BEST OF THE BEST

View 1 Replies View Related

Convertion Datetime Error

Jan 29, 2008

i am getting error while convering datetime datatype using

convert(x,101)
function

Arithmetic overflow error converting expression to data type datetime

please help me

View 11 Replies View Related

Datatype-convertion In TSQL

Jun 20, 2006

Dear all,Tables: COMPANY: COM_ID, COM_NAME, .....PROPERTY: PRP_ID, PRP_NAME, PRP_DATATYPE_ID, PRP_DEFAULT_VALUE( nvarchar)COMPANY_PROPERTY: CPROP_COM_ID, CPROP_PRP_ID, CPROP_VALUE(nvarchar)Use: Without adding new field the user can add new properties to thecompanies just by adding a new property in table PROPERTY and mapping thenew property to a companie. CPRP_VALUE contains all kind of datatypes but isstored as text.Problem: when I query the database ( SP, views, etc) I have problems withfloats and date bacause in the interface ( Access2000.adp) :[color=blue]> the float-format is 0,11 and in TSQL is 0.11>the date-format is DD/MM/YYYY and in TSQL it is YYYY-MM-DD[/color]Can I convert the data within the Stored Procedure for selecting and sortingon those fields.for example: How to sort on CPRP_VALUE containing floatvalues stored asnvarchar ??The client wants to stay with the comma-format because it is common-usedhere.The format can be TSQL-format in the resultset of a Stored Procedure withoutchanging the format in the database because this is used for the output tothe clients.[color=blue][color=green][color=darkred]>>> Same problem with dates !!![/color][/color][/color]thanks,Filip

View 7 Replies View Related

SQL Data Convertion Problem Help

Dec 20, 2006

HI,

I'm encouter some data convertion string problem especially during database update use asp.net (vb.net). Please help advice how can i solve the error??

I guess integer value need convert to string before able execute update function..

The error i get: -

1) failed to convert nvarchar to int

2) Convertion string is not in correct format...

let say i drag a textbox (txtquantity) and allow input and click update (with call procedure) updatexx set quantity=2 select from YY.

Wondering if i missed some important code??

Another data converting errorsituation is: let say i create a class call "AA" then have properties quantity as string, sProductID as string

i retrieve the data

........function get info(by ProductID as string)

If reader.Read() Then
OrdInfo.quantity = reader("Quantity").ToString()
OrdInfo.ProductID = reader("ProductID").ToString()

.....

sub update BB (byval aa as AA)

...

command.Parameters.Add("@Quantity", Data.SqlDbType.Int)
command.Parameters("@Quantity").Value = AA.quantity


command.Parameters.Add("@ProductID", Data.SqlDbType.Int)
command.Parameters("@ProductID").Value = AA.sProductID

Cheers:)











View 1 Replies View Related

Data Convertion Error

Jul 19, 2007

I am using SQL server 2005, Visual Web Developer 2005 express (for right now). Can get the stored procedure to run fine if I do not return the CityID.



Stored Procedure



ALTER Procedure [dbo].[WDR_CityAdd1]

(

@CountryID int,

@CityName nvarchar(50),

@InternetAvail bit,

@FlowersAvail bit,

@CityID int OUTPUT

)

AS

IF EXISTS(SELECT 'True' FROM city WHERE CityName = @CityName AND CountryID = @CountryID)

BEGIN

SELECT

@CityID = 0

END

ELSE

BEGIN

INSERT INTO City

(

CountryID,

CityName,

InternetAvail,

FlowersAvail

)

VALUES

(

@CountryID,

@CityName,

@InternetAvail,

@FlowersAvail

)

SELECT

@CityID = 'CityID' ( I have also tried = @@Identity but that never returned anything it is an identity column 1,1)

END



Here is the code on the other end. I have not included all the parameters, but should get a sense of what I am doing wrong.



Dim myCommand As New SqlCommand("WDR_CityAdd1", dbConn)

myCommand.CommandType = CommandType.StoredProcedure



Dim parameterCityName As New SqlParameter("@CityName", SqlDbType.NVarChar, 50)

parameterCityName.Value = CityName

myCommand.Parameters.Add(parameterCityName)



Dim parameterCityID As New SqlParameter("@CityID", SqlDbType.Int, 4)

parameterCityID.Direction = ParameterDirection.Output

myCommand.Parameters.Add(parameterCityID)

Try

dbConn.Open()

myCommand.ExecuteNonQuery()

dbConn.Close()

Return (parameterCityID.Value).ToString (have played with this using the .tostring and not using it)

'AlertMessage = "City Added"

Catch ex As Exception

AlertMessage = ex.ToString

End Try



Here is the error I get. So what am I doing wrong? I figured maybe in the stored procedure. CityID is difined in the table as an int So why is it telling me that it is a varchar when it is defined in the stored procedure, table and code as an int? Am I missing something?



System.Data.SqlClient.SqlException: Conversion failed when converting the varchar value 'CityID' to data type int. at System.Data.SqlClient.SqlConnection.OnError



Thanks

Jerry

View 3 Replies View Related

Convertion In Derived Column

Oct 16, 2007



I have a column age ( smallint) in derived transformation .. I would likt to convert it to A or B which is char(1)
hwo can i convert smallint to char(1) in derived column?
age > 17 ?"A" : "B"

View 1 Replies View Related

SSIS Data Convertion Problem

Dec 14, 2006

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1017518&SiteID=1

View 3 Replies View Related

Problem In Datatype Date Convertion

Mar 20, 2006

Hi,

My source is flat file and my destination is SQL SERVER 2005 using SSIS TOOL.

In my source file i got a date column which is in ISO standards ex: 20050131

I have taken source flat file data type as database date [DT_DBDATE] and in

destination table i declared data type as datetime.

When i start debugging i am getting an error saying that data conversion is not possible.

Can you please help me out how to solve the problem, what data types do i need to take in source and destination and is there any necessity of using Data Conversion Transformation.

If, so please tell me how to do.

With Regards

Satish



View 1 Replies View Related

Decimal Limited To 4 Digits To Right Of Decimal?

Jun 18, 2007





I need to store decimal values: decimal(20,15) in my SQL Server 2005 database.

I load data from flat file, convert it using Data Conversion Task to decimal(with scale: 15) and try to save it using OLE DB Destination.



It works fine for 4 digits after the decimal (like 1.1234), but always failes for more than 4 digits (1.12345).

Is the decimal limited to scale 4 ???



Thank you for your help!

Anna





View 3 Replies View Related

Packed Decimal To Decimal Conversion

Jun 4, 2007

Hi,




I am having a file in which amount fields are given in a Packed Decimal format. Can anyone suggest me how I can read this data element from the file and convert it into SQL decimal datatype.

File is a fixed length. All the amount fields are given in Packed Decimal Format and rest of the fields are given in text format.
How can i identify and convert only those packed decimals using SQL/.Net.

Example : a row in a file that has some packed decimals
158203508540188236252EUR20BZK0030 Å“&
20060715 0001010100010101




Please help!



Thanks

Mirudhu

View 4 Replies View Related







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