基本原则:能用表变量就用表变量.实在不行才使用临时表
表变量主要是开销系统的内存,而临时表则使用tempdb.对于小数据量的中间数据存储,可以使用表变量,而当需要临时保存的数据很大时,建议使用临时表.

declare @table table(id int identity(1,1),tid int) --创建表变量
select * from @table

 

create table #table (id int identity(1,1),tid int) --创建临时表
select * from #table
drop table #table   --删除临时表

 

相关文章:

  • 2022-03-07
  • 2021-10-16
  • 2021-07-03
  • 2021-04-25
  • 2021-06-11
  • 2021-07-09
猜你喜欢
  • 2021-06-26
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
  • 2022-01-03
相关资源
相似解决方案