Assignment Operator

The name itself is saying that, it assigns values to the variables or fields of a table. We have only one assignment operator ‘=’ in SQL Server. It plays a key role while writing queries. We cannot write complex queries without Assignment Operator.  

Field/variable = Expression

— Assigned ‘AUSTRALI0001’ to [AccountNumber] Field.
SELECT [BusinessEntityID], [Name]
FROM [Purchasing].[Vendor]
WHERE [AccountNumber] = ‘AUSTRALI0001’
— Assigned ‘SQLVersity’ to @My_Name variable.
DECLARE @My_Name Varchar(100) = ‘SQLVersity’
SELECT @My_Name AS My_Name
— Assigned sum of StoreID and TerritoryID to [ID_Sum].
SELECT TOP 3 [ID_Sum] = StoreID + TerritoryID
FROM [Sales].[Customer]


Assignment Operator Example

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.