Home >> FAQs/Tutorials >> SQL Server FAQ

SQL Server FAQ - What Is an Expression

By: FYIcenter.com

(Continued from previous topic...)

What Is an Expression?

A numeric expression is a combination of identifiers, values, and operators that SQL Server 2005 can evaluate to obtain a numeric value.

A simple expression could be a constant, a function, a column name, a variable, or a subquery without any operators.

Complex expressions can be constructed by joining other expressions with operators.

The following tutorial exercise shows you some expression examples:

DECLARE @site VARCHAR(40);
SET @site = 'FYIcenter.com';
SELECT 'Welcome'; -- Expression: constant
SELECT @site; -- Expression: variable
SELECT GETDATE(); -- Expression: function
SELECT 'Welcome to '+@site; -- Expression with an operator
GO
Welcome
FYIcenter.com
2007-05-19 18:42:09.077
Welcome to FYIcenter.com

DECLARE @rate NUMERIC(5,2);
DECLARE @deposit MONEY;
DECLARE @value MONEY;
SET @rate = 5.25;
SET @deposit = 4000.00;

-- Expression with multiple operators.
SET @value = @deposit*(1.0+@rate/100)*(1.0+@rate/100);
PRINT @value;
GO
4431.03

(Continued on next topic...)

  1. What Is an Expression?
  2. What Are Arithmetic Operators?
  3. What Happens to an Arithmetic Operation with Two Different Data Types?
  4. How To Convert a Numeric Expression from One Data Type to Another?
  5. How To Convert Numeric Expression Data Types by Assignment Operations?
  6. How To Convert Numeric Expression Data Types using the CAST() Function?
  7. How To Convert Numeric Expression Data Types using the CONVERT() Function?
  8. How To Convert Character Strings into Numeric Values?
  9. What Happens When Converting Big Values to Integers?
  10. What Happens When Converting Big Values to NUMERIC Data Types?
  11. What Are the Mathematical Functions Supported by SQL Server 2005?
  12. How To Convert Numeric Values to Integers?
  13. How To Round a Numeric Value To a Specific Precision?
  14. How To Generate Random Numbers with the RAND() Function?

Related Articles:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...