首页 新闻 搜索 专区 学院

exec惹得祸

0
悬赏园豆:50 [已关闭问题] 关闭于 2008-09-02 14:44
<P>DECLARE @NewPath NVARCHAR(4000)<BR>SET @NewPath='1/20/44'</P> <P>DECLARE @PCF TABLE(PKID int IDENTITY(1,1),&nbsp; ClassificationID int)<BR>--插入要更新的数据</P> <P>DECLARE @strSql NVARCHAR(4000)<BR>SET @strSql=' (SELECT ClassificationID FROM&nbsp; Classification WHERE CHARINDEX(<A href="mailto:'''+'/'+@NewPath+'/'+''',''/''">'''+'/'+@NewPath+'/'+''',''/''</A>+ PriCfPath+''/'') &gt; 0)'</P> <P>INSERT INTO @PCF select * from (EXEC(@strSql)) a<BR></P> <P>如何 执行EXEC(@strSql)并把结果insert到@PCF?</P> <P>请大虾指教</P> <P>&nbsp;</P> <P>&nbsp;</P>
roboth的主页 roboth | 初学一级 | 园豆:28
提问于:2008-08-22 13:31
< >
分享
所有回答(3)
0
DECLARE @NewPath NVARCHAR(4000) SET @NewPath='1/20/44' DECLARE @PCF TABLE(PKID int IDENTITY(1,1), ClassificationID int) --插入要更新的数据 DECLARE @strSql NVARCHAR(4000) SET @strSql='INSERT INTO @PCF SELECT ClassificationID FROM Classification WHERE CHARINDEX('''+'/'+@NewPath+'/'+''',''/''+ PriCfPath+''/'') > 0' exec (@strSql)
绝版色狼 | 园豆:315 (菜鸟二级) | 2008-08-22 13:38
0
DECLARE @id INT DECLARE @NewPath NVARCHAR(4000) SET @NewPath='1/20/44' DECLARE @PCF TABLE(PKID int IDENTITY(1,1), ClassificationID int) --插入要更新的数据 DECLARE @strSql NVARCHAR(4000) SET @strSql=' (SELECT @id=ClassificationID FROM Classification WHERE CHARINDEX('''+'/'+@NewPath+'/'+''',''/''+ PriCfPath+''/'') > 0)' EXEC(@strSql) INSERT INTO @PCF @id
MyFavorite | 园豆:159 (初学一级) | 2008-08-22 14:36
0
声明一个中间变量就可以了吧。
玉开 | 园豆:8822 (大侠五级) | 2008-08-22 16:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册