What Is an Expression in MS SQL Server?
Submitted by: AdministratorA 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 = 'GlobalGuideLine.com';
SELECT 'Welcome'; -- Expression: constant
SELECT @site; -- Expression: variable
SELECT GETDATE(); -- Expression: function
SELECT 'Welcome to '+@site; -- Expression with an operator
GO
Welcome
GlobalGuideLine.com
2007-05-19 18:42:09.077
Welcome to GlobalGuideLine.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
Submitted by: Administrator
DECLARE @site VARCHAR(40);
SET @site = 'GlobalGuideLine.com';
SELECT 'Welcome'; -- Expression: constant
SELECT @site; -- Expression: variable
SELECT GETDATE(); -- Expression: function
SELECT 'Welcome to '+@site; -- Expression with an operator
GO
Welcome
GlobalGuideLine.com
2007-05-19 18:42:09.077
Welcome to GlobalGuideLine.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
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | What Happens If NULL Values Are Involved in Bitwise Operations? |
☺ | What Happens If Strings Are Casted into Wrong Code Pages in MS SQL Server? |
☺ | How To Use Subqueries with the IN Operators in MS SQL Server? |
☺ | How To Configure ODBC DSN with Different Port Numbers? |
☺ | How To Create a Large Table with Random Data for Index Testing in MS SQL Server? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Sybase Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |