CREATE PROCEDURE "dbo"."DataTypeTester"
@myBigInt bigint
, @myInt int
, @mySmallint smallint
, @myTinyint tinyint
, @myBit bit
, @myDecimal decimal(10, 7)
, @myNumeric numeric(7, 4)
, @myMoney money
, @mySmallMoney smallmoney
, @myFloat float
, @myReal real
, @myDatetime datetime
, @mySmallDatetime smalldatetime
, @myChar char(4)
, @myVarchar varchar(10)
, @myText text
, @myNChar nchar(4)
, @myNVarchar nvarchar(10)
, @myNText ntext
, @myGuid uniqueidentifier
AS
SELECT 'BIGINT' "DataType", @myBigInt "Value" , LEN(@myBigInt) "Length" , DATALENGTH(@myBigInt) "Data Length"
SELECT 'INT' , @myInt , LEN(@myInt) , DATALENGTH(@myInt)
SELECT 'SMALLINT' , @mySmallint , LEN(@mySmallint) , DATALENGTH(@mySmallint)
SELECT 'TINYINT' , @myTinyint , LEN(@myTinyint) , DATALENGTH(@myTinyint)
SELECT 'BIT' , @myBit , LEN(@myBit) , DATALENGTH(@myBit)
SELECT 'DECIMAL' , @myDecimal , LEN(@myDecimal) , DATALENGTH(@myDecimal)
SELECT 'NUMERIC' , @myNumeric , LEN(@myNumeric) , DATALENGTH(@myNumeric)
SELECT 'MONEY' , @myMoney , LEN(CAST(@mySmallMoney as varchar)) , DATALENGTH(@myMoney)
SELECT 'SMALLMONEY' , @mySmallMoney , LEN(CAST(@mySmallMoney as varchar)) , DATALENGTH(@mySmallMoney)
SELECT 'FLOAT' , @myFloat , LEN(@myFloat) , DATALENGTH(@myFloat)
SELECT 'REAL' , @myReal , LEN(@myReal) , DATALENGTH(@myReal)
SELECT 'DATETIME' , @myDatetime , LEN(@myDatetime) , DATALENGTH(@myDatetime)
SELECT 'SMALLDATETIME' , @mySmallDatetime , LEN(@mySmallDatetime) , DATALENGTH(@mySmallDatetime)
SELECT 'CHAR' , @myChar , LEN(@myChar) , DATALENGTH(@myChar)
SELECT 'VARCHAR' , @myVarchar , LEN(@myVarchar) , DATALENGTH(@myVarchar)
SELECT 'TEXT' , '' , '' , DATALENGTH(@myText)
SELECT 'NCHAR' , @myNChar , LEN(@myNChar) , DATALENGTH(@myNChar)
SELECT 'NVARCHAR' , @myNVarchar , LEN(@myNVarchar) , DATALENGTH(@myNVarchar)
SELECT 'NTEXT' , '' , '' , DATALENGTH(@myNText)
SELECT 'GUID' , @myGuid , LEN(@myGuid) , DATALENGTH(@myGuid)
-- TODO: READTEXT should do this...
/*
, @myText "text"
, @myNText "ntext"
*/
RETURN(0)
Code:
本文地址:http://com.8s8s.com/it/it9098.htm