About 6,270 results
Open links in new tab
  1. Variables (Transact-SQL) - SQL Server | Microsoft Learn

    Jan 28, 2026 · To assign a variable a value by using the SET statement, include the variable name and the value to assign to the variable. This method is the preferred way to assign a value to a variable.

  2. How to Declare a Variable in SQL Server? - GeeksforGeeks

    Jul 23, 2025 · We cannot declare a variable and directly assign it the result from a subquery in the DECLARE statement in SQL Server. However, we can set a variable with a subquery after it has …

  3. SQL Declare Variable Code Examples - SQL Server Tips

    Oct 30, 2025 · Learn how to define and use variables in SQL Server code with these many different SQL Declare Variable code examples.

  4. SQL Server: Declare Variables - TechOnTheNet

    Learn how to declare variables in SQL Server (Transact-SQL) with syntax and examples. In SQL Server (Transact-SQL), a variable allows a programmer to store data temporarily during the execution of code.

  5. How do I declare and assign a variable on a single line in SQL

    DECLARE @var nvarchar(max) = '"My Name is Luca" is a great song'; The second example in the MSDN page on DECLARE shows the correct syntax.

  6. How to Declare and Assign Value to a Variable in SQL Server

    May 2, 2025 · Understanding how to declare and assign values to variables is essential for writing efficient and maintainable SQL scripts. In this guide, we will explore different ways to declare and …

  7. T-SQL Variables - Declare and Set variable

    Variables are a fundamental aspect of SQL Server programming, enabling developers to write more efficient, dynamic, and readable SQL scripts. Understanding how to properly declare, initialize, and …

  8. SQL Variables: SQL Server Declare, Set and Select Variable - Guru99

    Jun 28, 2024 · DECLARE command is used to DECLARE variable which acts as a placeholder for the memory location. Only once the declaration is made, a variable can be used in the subsequent part …

  9. SQL Variables: Basics and usage

    Nov 18, 2019 · In this article, we have explored the concept of SQL variables from different perspectives, and we also learned how to define a variable and how to assign a value (s) to it.

  10. DECLARE @local_variable (Transact-SQL) - SQL Server

    Nov 18, 2025 · Variables are declared in the body of a batch or procedure with the DECLARE statement and are assigned values by using either a SET or SELECT statement. Cursor variables can be …