【SQL】表变量使用注意事项

         declare @table table (id int)
         declare @table2 table (id int)
         insert into @table values(1)
         select * from @table
         delete from @table
         insert into @table values(2)
         select * from @table
         select * from @table join @table2  on @table2.id = @table1.id --表变量在on后直接使用会报错,要用别名的形式
         select * from @table as t1 join @table2 as t2 on t1.id = t2.id --要用别名的形式

 

posted @ 2016-05-05 16:11  阿玛  阅读(162)  评论(0)    收藏  举报