.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

Which is more suitable SqlDbType.Decimal Or SqlDbType.Float

Posted By:      Posted Date: October 04, 2010    Points: 0   Category :Sql Server
 

Hi,

   I have a Stored Procedure like:

ALTER PROCEDURE [dbo].[SP_JV]
(
    @numDebit Numeric(10,2)=0,
    @numCredit Numeric(10,2)=0,
)

Now I have to pass parameters into this Stored Procedure from my c# front-end code like

    SqlParameter = new SqlParameter("@numDebit", SqlDbType.float, 8, MyValue);

My doubt is whether I should use SqlDbType.Float or SqlDbType.Decimal in this case.  Please help.

Cris Evan


cris


View Complete Post


More Related Resource Links

SqlDbType.NVarChar

  
In the following code, should we change the parameters from SqlDbType = SqlDbType.Int to SqlDbType.NVarChar?   protected void Page_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlapplicationConnectionString"].ToString()); try { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO Application (" + " First, Last, City, State" + ") VALUES (" + " @First, @Last, @City, @State"; cmd.Parameters.Add(new SqlParameter() { ParameterName = "@First", SqlDbType = SqlDbType.Int, Value = Convert.ToInt32(Request["First"]) }); cmd.Parameters.Add(new SqlParameter() { ParameterName = "@Last", SqlDbType = SqlDbType.Int, Value = Convert.ToInt32(Request["Last"]) }); cmd.Parameters.Add(new SqlParameter() { ParameterName = "@City", SqlDbType = SqlDbType.Int, Value = Convert.ToInt32(Request["City"])

find amounts with more than 2 decimal places in a float type column

  
I was trying to use charindex but that didnt work.  Also what happens if i change the column to money data type? does it round or truncate?

Using ADO.NET SqlDbType.Structured TVP (Table Valued Parameters) causes SQL Compilation for every ca

  

When calling a stored procedure with a table valued parameter from ADO.Net, each call requires a SQL Compilation.  In an application that makes this call thousands of times per second, this causes SQL Compilations thousands of times per second leading to degraded performance.

When calling the same stored procedure directly from Management Studio, no SQL Compilations are performed.

Steps to reproduce ...

1. Create the following User Defined Type and Stored Procedure (SQL2008 required) ...

CREATE TYPE [dbo].[BigIntListType] AS TABLE(
 [Id] [bigint] NOT NULL,
 PRIMARY KEY CLUSTERED 
 (
  [Id] ASC
 ) WITH (IGNORE_DUP_KEY = OFF)
)
GO

CREATE PROCEDURE testProc
  @itemIds AS BigIntListType READONLY
AS
  SELECT col1, col2 FROM table1
  JOIN @itemIds ON table1.id = @itemIds.Id
GO

2. Start SQL Profiler and capture "Showplan XML for Query Compile".  Start Perfmon and add "SQL Compilations / Second"

3. Run the following code from Management Studio as many times as possible ...

declare @p2 dbo.BigIntListType

insert into @p2 values(601)
insert into @p2 values(1)

exec testProc @itemIds = @p2

Difference between the enums SqlDbType and SqlDataType and why two enums?

  

Hi - long time programmer here but just getting started with SQL...

Why is there the two enums System.Data.SqlDbType and Microsoft.SqlServer.Management.Smo.SqlDataType?

From my reading/investigating (simplified definitions here):
SqlDataType are the types are used to define the data type of a column in an SQL table
of which there are 41 values - one of which is "None" = (SqlDataType)(0).

SqlDbType are the values that are used to define the type in a instance of the
type SqlParameter of which there is 31 values

Yet if you go and create a table via Visual Studio Server Explorer (or in SQl Management Studio) and
count the number of items in the drop-down list in the "Data Type" column there are only 36 choices not 41 (or even 40 excepting "None")!

And even more crazy, the values of the two do not map across (even if you account for SqlDatatype.None up to the point where SqlDBType ends.
They are off by one up (ie (SqlDbType(n) == SqlDataType(n+1)) until you get to NVarChar (SqlDataType(13), SqlDbType(12))
Then the list ordering gets all messed up.

Bottom line why two enums, are some of the SqlDataType not valid as an SqlParameter?

 

 


DataSet/DataTable to SqlXml SqlDbType

  

Hi,

how would i convert DataSet/DataTable to SqlXml SqlDbType and save it to Sql Server Table?

I'm using Sql Server 2008 R2.

protected void SqlDataSource1_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
    if (ViewState["dsTest"] != null)
    {
        DataTable dt = ((DataSet)ViewState["dsTest"]).Tables["Info"];
        SqlXml Qxml = new SqlXml();
        //convert DataTable to SqlXml[Qxml]
        e.Command.Parameters["@Info"].Value = Qxml;
    }
}

<InsertParameters>
    <asp:Parameter Name="Info" Type="Object" />
</InsertParameters>
Whatever i try, i get back error:

System.Data.SqlClient.SqlException: Operand type clash: sql_variant is incompatible with xml

 

Thanks for the help.


decimal value validation and round off by javascript

  
The article decimal value validation and round off by javascript was added by hiral.hapani on Wednesday, June 02, 2010.

Hi All, I have createdone javascript by which you canvalidate a decimal value of any textbox for which you want. By thisjavascriptwecan bind user to enter only digits in textbox. and when he will enter any decimal value javascript will do round off it

MySqlMembershipProvider.CreateUser no suitable method found to override

  

HI,

I am getting following error while using MySqlMembership Provider. Can any one help me to solve this?


Error:

MySql.Membership.MySqlMembershipProvider.CreateUser(string, string, string, string, string, bool, object, ref System.Web.Security.MembershipCreateStatus)': no suitable method found to override.


        <membership defaultProvider="MySQLMembershipProvider">
            <providers>
                <add name="MyMembershipProvider"
                     type="MySqlMembershipProvider"
                     requiresQuestionAndAnswer="true"
                     connectionStringName="LocalMySqlServer"/>            
            </providers>
        </membership>

        <roleManager enabled="true" defaultProvider="MySQLRoleProvider" />







using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Configuration.Provider;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Web.Configuration;
using System.Web.Security;
using MySql.Data.M

Which one is better: Money or Decimal?

  

Hi

I want a field to keep money value (up to 100,000,000.00). And I didn't  work with money or decimal data type.

Money data Type is 8 byte

Decimal (9, 2) is 5 byte. (Exactly msdn only say Decimal (9, 0) is 5 byte and I don't really know how byte is Decimal (9, 2))

Please tell me which one is better to work with in sql and VS.net (handling sql in VS)

Best Regards. Morteza


I'm pulling out my hair,hard to find a suitable mvc sample application to learn from

  
I've noticed several samples in the url:http://www.asp.net/mvc/application-developmentbut,nerddinner seems too hard for me ;MVC MusicStore cannot run in my computer. seems it use sql2008&i have sql2005 installed in my computerASP.NET MVC Storefront Starter Kit        even worse  after i've download the source code from codeplex as told by the author, just find that I  can not compiled it  in vs2010(it's deveplopped using vs2008)and it seems out of date(the project begun at 2008),actually i wanna find a sample written after 2010.And I hope the sample is classic   and easy to learn,  and the technology used should not turn out to be a past after a new version of mvc or .net framework released.Anyone can help me out?

Need RegEx for four decimal place

  
Hello All, I have total 19 digits in which i have 4 decimal place. What would be the pattern. ThanksBizTalk Beginner

How do I get Decimal.Parse to stop taking current culture into account?

  
How do I get Decimal.Parse to stop taking current culture into account?   I tried the following but I get an error saying “String was not recognized as a valid DateTime.   Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");   Decimal.Parse("5000.000,51",CultureInfo.InvariantCulture)

Bianry data to decimal value in sql

  
Hi all! can any one tell me please if we have data in one column is in binary format i.e  e.g 0111 result should be 7. How should we retrive the decimal value 7 through sql server 

Convert float to String

  
HI, I am creating a derived column in my workflow. This derived column would have a concatenated value or Currency + [Account No]. Derived column is of type DT_STR. Currency is string (which is fine). I am having trouble converting [Account No] from float to string I tried Currency + (DT_WSTR)[Account No] and Currency + (DT_STR)[Account No] I am a newbie here... so, excuse my stupid question

Validate input has up to 2 decimal places

  
I need to validate hours put into a textbox.  I want to allow hours to be from 0-24 and allow up to 2 decimal places. so it has to accept 00.001.52.25but not 2.225 or 25I put a range validator that check that the value is from 0-24 but it doesn't check that there are 2 decimal places or less.  how do I do that?

Quick way to widen a decimal column in place?

  
Hi all, I have a table with over 400 million rows in it, and it turns out that one of the columns that was defined as decimal(14,5) needs to be widened to decimal(18,5).  The column is not used an any keys or indexes. What's the fastest way of doing that?  When I attempt to change the column definition (right-click the table in SSMS, select Design, update the column definition, then attempt to save), SSMS complains, saying Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created.... Thanks, Matthew  

Loading Decimal Number From Excel into SQL Server 2005 using SSIS Package

  
If you have an excel spreadsheet that displays a number .02 (because it is formated) but internally it is stored as .2654329 and you want to load .2654329 how can you do that in the SSIS package?  When we load the spreadsheet it is loading .02.  Is there some kind of option in the SSIS package to tell the package to load the internal number?lcerni

Quick way to widen a decimal column in place?

  
Hi all, I have a table with over 400 million rows in it, and it turns out that one of the columns that was defined as decimal(14,5) needs to be widened to decimal(18,5).  The column is not used an any keys or indexes. What's the fastest way of doing that?  When I attempt to change the column definition (right-click the table in SSMS, select Design, update the column definition, then attempt to save), SSMS complains, saying Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created.... Thanks, Matthew  
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend