Ê×Ò³ Ê«´Ê ×Öµä °å±¨ ¾ä×Ó ÃûÑÔ ÓÑ´ð ÀøÖ¾ ѧУ ÍøÕ¾µØͼ
µ±Ç°Î»ÖÃ: Ê×Ò³ > ½Ì³ÌƵµÀ > Êý¾Ý¿â > SQL Server >

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

2012-01-23 
Ϊʲô˵ÎҵĶÔÏóÒÑ´æÔÚ£¿ALTERPROCEDURE[dbo].[testProc]ASBEGINdeclare@testintselectcount(*)ascintote

Ϊʲô˵ÎҵĶÔÏóÒÑ´æÔÚ£¿
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

ÈȵãÅÅÐÐ