|
Currency data does not need to be enclosed in single quotes ('). However, the currency value must be preceded by the appropriate currency symbol. For example, to specify 100 pounds, use£ 100.
Money and smallmoney are limited to 4 digits after the decimal point. If you require more digits after the decimal point, use the decimal data type.
Use periods to separate local monetary units (such as cents) from the overall monetary unit. For example, 2.15 means 2 yuan and 15 points.
Although these data types include a comma separator in their display, the comma separator cannot be used in money or smallmoney constants. Comma separators can only be specified in strings that are explicitly converted to money or smallmoney, such as:
USE Northwind
GO
CREATE TABLE TestMoney (cola INT PRIMARY KEY, colb MONEY)
GO
SET NOCOUNT ON
GO
-The following three INSERT statements work.
INSERT INTO TestMoney VALUES (1, $ 123.45)
GO
INSERT INTO TestMoney VALUES (2, $ 123123.45)
GO
INSERT INTO TestMoney VALUES (3, CAST ('$ 444,123.45' AS MONEY))
GO
-This INSERT statement gets an error because of the comma
-separator in the money string.
INSERT INTO TestMoney VALUES (3, $ 555,123.45)
GO
SET NOCOUNT OFF
GO
SELECT * FROM TestMoney
GO |
|