SQL Server There are two ways to assign values to defined variables in , Namely SET and SELECT. 
For the difference between the two ways ,SQL Server This is explained in detail in the online series , But a lot of the time we  
Didn't pay attention to , In fact, there are many differences between the two ways .

SQL Server Recommended SET instead of SELECT Assign values to variables . 
When an expression returns a value and assigns a value to a variable , Recommended SET Method .

The following table lists SET And SELECT The difference between . Please pay special attention to the red part .

  set select
Assign values to multiple variables at the same time I won't support it Support
When an expression returns multiple values error Assign the last value returned to the variable
The expression did not return a value Variable is assigned null value Keep the original value of the variable

sql server Stored procedure SELECT And SET More about the difference between variable assignments

  1. 【 turn 】sql server Stored procedure SELECT And SET The difference between assigning values to variables

    from :http://www.cnblogs.com/micheng11/archive/2008/07/08/1237905.html SQL Server There are two ways to assign values to defined variables in , Namely ...

  2. sql server Stored procedure SELECT And SET The difference between assigning values to variables from Theo

    SQL Server There are two ways to assign values to defined variables in , Namely SET and SELECT. For the difference between the two ways ,SQL Server This is explained in detail in the online series , But a lot of the time we Didn't pay attention to , In fact this ...

  3. SQL SERVER Stored procedure SELECT Returns how a value is assigned to a variable

    When dealing with a problem today , Using a stored procedure , Is used to update and get the latest ID Of . In use , You need to get this ID And assign to variable , The result is EXEC @ID = The way to get the stored procedure failed . The details are as follows : In order to restore the whole situation ...

  4. SQL Server Examples of using table values as input parameters in stored procedures

    This article mainly introduces SQL Server Examples of using table values as input parameters in stored procedures , Use table valued parameters , You don't have to create temporary tables or many parameters , You can go to Transact-SQL Statement or routine ( Such as stored procedures or functions ) Send multiple lines of data , such ...

  5. Sql Server Query data cannot be used in stored procedures Union(All)

    original text :Sql Server Query data cannot be used in stored procedures Union(All) Microsoft Sql Server In the database , When writing stored procedures , About querying data , Can't use Union(All) Associate multiple queries . 1. Let's first look at a paragraph ...

  6. SQL Server Analysis of several common writing methods for handling multiple query conditions in stored procedure , We should write that way

    Source of this article : http://www.cnblogs.com/wy123/p/5958047.html Recently, I found that there are many small partners in development , When writing stored procedures , When referring to different ways of writing , Often confused , I don't know about all kinds of ...

  7. SQL Server Prevent thread reentry in stored procedure

    For thread reentry , stay C# There is lock Keywords lock a SyncObject, and SQL Server It can also be simulated with a table . First, create a synchronization table , amount to C# Medium SyncObject, And insert a record ( The initial value is 1) ...

  8. 【 turn 】SQL SERVER Scope of variables in stored procedures

    I met a very interesting thing today , I haven't noticed before , So write it down . Let's start with an example . SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE ...

  9. sql server Using variable tables in stored procedures , Analysis of temporary tables ( To continue )

    lately , I have a friend , To me, many stored procedures in his database , Execution times out . Let me see for him why . I have a look at , It turns out that his stored procedure uses a lot of temporary tables and variable tables . So I told him it wasn't as good as . Use temporary tables or variable tables in stored procedures , send ...

Random recommendation

  1. VBA Lament the drama —— Simple cell settings ( example )

    Because there are so many Word file , So the application macro will be more convenient for typesetting , And the layout is more unified . Sub Set column width () ' ' Set column width macro ' ' ActiveDocument.Tables().Cell(, ).Width ...

  2. obtain WIN10 Technology Preview

    explain This is a pre release software Before a commercial release , We might be right Windows Technical Preview Make a lot of changes . Microsoft No warranty, express or implied, is given with respect to the information provided herein . Some products ...

  3. iOS - Code view console print memory usage :

    1. First import : #import <mach/mach.h> 2. Write this method . The unit is trillion (M). void report_memory(void) { struct task_basic_info ...

  4. [HDOJ4325]Flowers( Tree array discretization )

    Topic link :http://acm.hdu.edu.cn/showproblem.php?pid=4325 An introduction to discretization :http://blog.csdn.net/gokou_ruri/article ...

  5. Android Development viewpager Study ( The headline says )

    activity_luancher.xml The code is as follows : <RelativeLayout xmlns:android="http://schemas.android.com/apk/res ...

  6. 【POJ1823】【 Line segment tree 】Hotel

    Description The "Informatics" hotel is one of the most luxurious hotels from Galaciuc. A l ...

  7. JS Advanced programming learning notes array

    How arrays are created var str = new Array(); Putting in numbers sets the length of the array var str = []; Array of length Can read but write Monitoring array Array.isArray() Method to determine a value is not ...

  8. Dynamic link library -Win32 DLL Explanation

    In actual programming , We can put functions that perform certain functions in a DLL , And then call... To other programs . WinAPI All the functions in are contained in 3 The most important DLL in . Kernel32.dll It contains those used to manage memory . Processes and lines ...

  9. C# Ini、Json、Xml Wrapper class

    1.Ini What is it? ?( My understanding of it , A file used to store user configuration information , The file is placed on the user's computer ...) INI A file is a configuration file with no fixed standard format . It is composed of simple words and simple structure , Often used in Windows operating system , or ...

  10. turn 《ionic Life cycle 》

    1. know ionic Lifecycle hooks By ionic 3.8.0 edition , The framework provides 8 A hook function , They are triggered at different stages of the page life cycle , Let's have a brief look . 1.1 ionViewDidLoad Page loading ...