在sql语句中加入变量。

declare @local_variable data_type

声明时须要指定变量的类型,

能够使用set和select对变量进行赋值,

在sql语句中就能够使用@local_variable来调用变量

 

声明中能够提供值,否则声明之后全部变量将初始化为NULL。

 

比如:declare @id int

         declare @id int = 3

         set @id=2

         select id

         select @id = column_id from table where column_user = 'ABC'

相关文章:

  • 2021-09-26
  • 2022-12-23
  • 2021-12-01
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
猜你喜欢
  • 2021-05-30
  • 2021-12-30
  • 2022-02-09
  • 2022-12-23
  • 2021-11-18
  • 2022-01-07
相关资源
相似解决方案