FIX: (38,0) ????? ??? ????? ???? ????? ?? SQL Server 2000 ?? ????? ????? ??????? ????? ?? ??????? ???????? ???? ??? ??????? ?? ????? ????

?????? ????????? ?????? ?????????
???? ???????: 892406 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???: 473209 (SQL Server 8.0)
????? ???? | ?? ????

?? ??? ??????

???????

????? ????????? ??????: ?? Microsoft SQL Server 2000 ? ?????? ????? ????? ????? ???? ??? ?????? ???? ?? ??? ?????? ?????. ??? ????? ???? ????? ????? ????? ????? ?? ??????? ???????? ???? ??? ??????? ?? ??????? ?????? ????? (38,0). ??? ???????? ??? ??????? ??? ????????? ??????? ??? ??????? ??????. ?? ???? ??? ?????? ???????? ???? ?????? ??? ???? ??? ????.

??? ????? ??? ??????? ??? ??? ????????? ???? ?????? ????? ????? System.Data.SqlClient. ?? ???? ??? ??????? ??? ????????? ???? ?????? ?????? ?????? ??? ???????? API.

??? ???? ??????? ???? ????? ???? ????? ??? ????? ????? DECIMAL(19,4). ?? ??? ??????? ??????? ?????? ??????? ?? ????? SqlCommand.ExecuteNonQuery ??? ??????.
CREATE PROCEDURE ParameterPrecisionTest(
	@pIn DECIMAL(19,4), 
	@pOut DECIMAL(19,4) OUTPUT) 
AS
	SET @pOut = @pIn
??? ?????? ????? ????? ??????? ???????:
  1. ??? ??????? ??????? ExecuteNonQuery ?????? ????? ??????? SqlParameter ??? 1.5 ??? ????? 1.5.
  2. ??? ??????? ??????? ExecuteNonQuery ?????? ????? ??????? SqlParameter ??? DBNull ??? ????? System.DBNull.
  3. ??? ??????? ??????? ExecuteNonQuery ?????? ????? ??????? SqlParameter ??? 1.5 ??? ????? 2.
?????? ?? ??????? ??? ??? ??????? ?????? ????? "?" ??????? ??? ????? ????? ??? (38,0). ??? ????? ???? 2 ?? ??????? ?????? ??? ??????? ??????.

?????

???? ??? ??????? ????? ??? SQL Server ??????? ????? "?" ??????? ??? (38,0) ??? ?????? ???????:
  • ??????? ????? ???? ???? ????? ??? ????? ????? SqlParameter.
  • ????? ??????? ??? DBNull.

????

??????? ???? ??????

??? ??? ???????? ??? ?????? ??? ???? ???? ???? ?? Microsoft SQL Server 2000. ????? ?? ?????????? ???? ??? ??? ??????? ?????? ?????? ?? "????? ??????? ?? Microsoft:
290211????? ?????? ??? ???? ???? ???? ?? SQL Server 2000

?????

?? ????? ??? ??????? ???? ??? ?? Microsoft SQL Server 2000 ?????? ????? ?????? Service Pack 4.

??????? ????

????? ????? ????? ???????

????? ?????? Visual C# ???????.
using System;
using System.Data.SqlClient;
using System.Data;

namespace MyApplication
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class MyClass
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			
			string strConn = "Server=(local);Database=Northwind;" + 
				"Trusted_Connection=Yes;";
			SqlConnection cn = new SqlConnection(strConn);

			// Create stored procedure.
			PrepDb(cn);

			// Simple stored procedure.
			//    Input and output parameters decimal(19, 4).
			//    Sets the output parameter value to the input parameter value.
			SqlCommand cmd = cn.CreateCommand();
			cmd.CommandText = "ParameterPrecisionTest";
			cmd.CommandType = CommandType.StoredProcedure;
			SqlParameter pIn = cmd.Parameters.Add("@pIn", SqlDbType.Decimal);
			pIn.Precision = 19;
			pIn.Scale = 4;
			SqlParameter pOut = cmd.Parameters.Add("@pOut", SqlDbType.Decimal);
			pOut.Precision = 19;
			pOut.Scale = 4;
			pOut.Direction = ParameterDirection.Output;

			cn.Open();

			// Print value, precision, and scale for the output parameter.
			CheckParameter("Pre-execution", pOut);

			// The first call to the procedure returns 1.5.
			pIn.Value = 1.5;
			cmd.ExecuteNonQuery();
			CheckParameter("Returning 1.5", pOut);

			// The second call to the procedure returns null.
			pIn.Value = DBNull.Value;
			cmd.ExecuteNonQuery();
			CheckParameter("Returning DBNull", pOut);

			// The third call to the procedure returns 2.
			pIn.Value = 1.5;
			cmd.ExecuteNonQuery();
			CheckParameter("Returning 1.5", pOut);

			cn.Close();
		}
		static void CheckParameter(string Message, IDbDataParameter Parameter)
		{
			Console.WriteLine("\t{0}", Message);
			Console.WriteLine("\t\tValue:{0}\tPrecision:{1}\tScale:{2}", 
				(Parameter.Value != DBNull.Value) ? Parameter.Value : "DBNull", 
				Parameter.Precision, Parameter.Scale);
			Console.WriteLine();
		}

		static void PrepDb(IDbConnection Connection)
		{
			IDbCommand cmd = Connection.CreateCommand();
			Connection.Open();
			cmd.CommandText = "DROP PROCEDURE ParameterPrecisionTest";
			try {cmd.ExecuteNonQuery();} 
			catch {}
			cmd.CommandText = "CREATE PROCEDURE ParameterPrecisionTest " +
				"(@pIn decimal(19, 4), @pOut decimal(19, 4) OUTPUT) " +
				"AS SET @pOut = @pIn";
			cmd.ExecuteNonQuery();
			Connection.Close();
		}

	}
}
?????? ?? ??? ?????? ??????? ??? ??? ??????? ?????? ????? ????? ??????? ??? DBNull. ????? ??? ????? ????? ????? "?" ??????? ??? (38,0). ??????? ?????? ????? ??????? ?????? ?????? ???????? ???? 2.

???????

???? ???????: 892406 - ????? ??? ??????: 21/????/1428 - ??????: 2.4
????? ???
  • Microsoft SQL Server 2000 Developer Edition
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 2000 Enterprise Edition
  • Microsoft SQL Server 2000 Personal Edition
  • Microsoft SQL Server 2000 Workgroup Edition
  • Microsoft SQL Server 2000 Desktop Engine (Windows)
  • Microsoft SQL Server 2000 Enterprise Edition 64-bit
????? ??????: 
kbmt kbbug kbtshoot kbprb kbfix KB892406 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????892406

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com