µ±Ç°Î»Ö㺠´úÂëÃÔ >> Sql Server >> Ϊʲô˵СµÜÎҵĶÔÏóÒÑ´æÔÚ
  Ïêϸ½â¾ö·½°¸

Ϊʲô˵СµÜÎҵĶÔÏóÒÑ´æÔÚ

Èȶȣº22   ·¢²¼Ê±¼ä£º2016-04-27 21:00:40.0
Ϊʲô˵ÎҵĶÔÏóÒÑ´æÔÚ£¿
ALTER   PROCEDURE   [dbo].[testProc]
AS
BEGIN
declare   @test   int;
        select   count(*)   as   c   into   test   from   table2;
print   @test

END

¾Í¶¨ÒåÁËÒ»¸ötest±äÁ¿£¬µÚÒ»´ÎÖ´Ðд洢¹ý³ÌµÄʱºòºÃµÄ£¬µÚ¶þ´ÎÒÔºó¾Í²»ÐÐÁË£¬Ëµtest±äÁ¿ÒÑ´æÔÚ¡£¡£ÎªÊ²Ã´£¿»»ÁËÆäËûµÄ±äÁ¿ÃûͬÑù
ÎÒÖ±µ½Áãʱ±í¿ÉÒÔdrop   table£¬±äÁ¿Ôõô°ìÄÄ£¿

------½â¾ö·½°¸--------------------
ALTER PROCEDURE [dbo].[testProc]
AS
BEGIN
if exists(select 1 from sysobjects where xtype= 'U ' and name= 'test ')
drop table test
declare @test int;
select count(*) as c into test from table2;
print @test

END
  Ïà¹Ø½â¾ö·½°¸