sigh! why people want to migrate from 2k to 70?
if the expression in AccountMonth is not complex, expand it.
Or,
you may have to change the select statement to a "select into".
expect a temporary table in your AccountMonth.
such as select * into #resultand create this temporary table before you call the stored procedure.
if the expression in AccountMonth is not complex, expand it.
Or,
you may have to change the select statement to a "select into".
expect a temporary table in your AccountMonth.
such as select * into #resultand create this temporary table before you call the stored procedure.
1.使用临时表。楼上的朋友说的也就是这个意思,不过有一点我不同意的就是应该使用##result,而不是#result,因为临时表是有生存期的,以#开头的临时表会随着当前会话事务的终结而终结,而这个临时表既然分开两个存储过程分别读写记录,所以还是应该使用##开头的临时表比较好,因为以##开头的临时表是全局性的。
2.使用动态SQL中的变量值传递方法。你可以参考: http://www.csdn.net/expert/Topic/183/183467.xml
和http://www.csdn.net/expert/topic/443/443157.xml两个帖子,适当地变通一下,反正思路差不多,在这里我就不详述了。
这两种方法我都知道,但不管用临时表,还是用output参数输出变量,都无法通过简单的改动转换原来的程序。现在系统已经全部改写了,我明天结账,不知各位还有什么高见?
用连接服务器,和openquery来做分布式查询。
select * from openquery(selfserverlinked,'exec sp_proc') a 有空测试一下看行不行,现在先看世界杯吧!
create table #temp (name varchar(8))
insert into #temp values('test1')
insert into #temp values('test2')
select * from #temp
drop table #temp
GOcreate table #test( test varchar(10))
insert #test exec test
select * from #test
drop table #test
存储过程A调用存储过程B,存储过程B返回个游标给A,A拿着游标继续处理。
下面这个没试验过。
/*Master中的一个函数*/
Create function fn_MSFullText()
returns @retTab table(LCID int)
as
begin
declare @tempLang table(LCID int)
insert @tempLang values (2052) /* Chinese_Simplified */
insert @tempLang values (1028) /* Chinese_Traditional */
insert @tempLang values (1043) /* Dutch */
insert @tempLang values (2057) /* English_UK */
insert @tempLang values (1033) /* English_US */
insert @tempLang values (1036) /* French */
insert @tempLang values (1031) /* German */
insert @tempLang values (1040) /* Italian */
insert @tempLang values (1041) /* Japanese */
insert @tempLang values (1042) /* Korean */
insert @tempLang values (0) /* Neutral */
insert @tempLang values (1053) /* Swedish_Default */ insert @retTab select * from @tempLang
return
end
/*可以直接使用*/
Select * from fn_MSFullText() where ......
EXECUTE roy_check 'BU1032', 1050, @pc = @percent OUTPUT
SET Percent = @percent