About 6,100 results
Open links in new tab
  1. 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 …

  2. 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.

  3. 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 …

  4. 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.

  5. 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.

  6. SQL DECLARE Variable: Complete Guide | Examples in All 5 Databases

    Dec 6, 2025 · Therefore, this guide will explain everything you need to know about SQL DECLARE Variable across major databases in SQL Server, MySQL, PostgreSQL, and Oracle.

  7. 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 …

  8. 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 …

  9. 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 …

  10. 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.