如何把一个表中的多条数据插入到已经存在的临时表中(不要用游标)
IF @airways <> 'ALL '
BEGIN
CREATE Table #AirCode ( Code nvarchar(10) collate Latin1_General_BIN)
-- Edit By:Echo xue 2006/02/15 Begin
-- SET @airways = 'INSERT INTO #AirCode select '+ Replace(@airways , ', ', ' AS tt union select ')
-- EXEC (@airways)
SET @airways = ISNULL( @airways, ' ')+ ', '
WHILE CHARINDEX( ', ',@airways) > 0
BEGIN
INSERT INTO #AirCode(Code) Values(LEFT (@airways ,CHARINDEX( ', ',@airways)-1))
SET @airways =STUFF (@airways,1 , CHARINDEX( ', ',@airways), ' ')
END
END
ELSE
BEGIN
If Object_id( 'TempDB..#AirCode ') Is Not NULL
BEGIN
DROP Table #AirCode
SELECT airlinecode INTO #AirCode FROM MST_Airlines
END
[解决办法]
题目应该是怎样加快插入表的速度吧
关注高手 帮忙up
[解决办法]
是指后面的部分吗?直接insert into .. select ...不就可以了吗?
CREATE Table #AirCode ( Code nvarchar(10) collate Latin1_General_BIN)
IF @airways <> 'ALL '
begin
...
end
else
insert into #AirCode(code) SELECT airlinecode FROM MST_Airlines