一个SQL查询语句的问题,请高手指点!!在线等候!!

lqlin 2004-04-20 02:46:28
CREATE PROCEDURE Up_Convert
@strServer VARCHAR(30),
@strDBName VARCHAR(30)
AS
DECLARE @strCodetype VARCHAR(30)

SET NOCOUNT ON
SET @strCodetype = ''

SELECT @strCodetype = codetype FROM '+@strServer+'].'+@strDBName+'.dbo.syscode WHERE codename= 'scxtquerymenu')

SET NOCOUNT OFF
GO

请问我怎么执行,如果用exec()时,系统提示没有declare strCodetype
...全文
79 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
8992026 2004-04-20
我的没改对,作废,楼上的对
回复
8992026 2004-04-20
CREATE PROCEDURE Up_Convert
@strServer VARCHAR(30),
@strDBName VARCHAR(30)
AS
DECLARE @strCodetype VARCHAR(30)
DECLARE @SQL nvarchar(500)
declare @strCodetype varchar(100)

SET NOCOUNT ON
SET @strCodetype = ''

set @SQL = N'SELECT @strCodetype = codetype FROM ' + '['+ @strServer+'].['+@strDBName+'].dbo.syscode WHERE codename= ''scxtquerymenu'')'


-------------------------------------------
execute sp_executesql @SQL,
N'@strCodetype output',
@strCodetype = @strCodetype
-------------------------------


SET NOCOUNT OFF
GO

回复
viptiger 2004-04-20
上面写错了哦


CREATE PROCEDURE Up_Convert
@strServer VARCHAR(30),
@strDBName VARCHAR(30)
AS
DECLARE @strCodetype VARCHAR(30)
DECLARE @SQL nvarchar(500)
declare @@strCodetype varchar(100)

SET NOCOUNT ON
SET @strCodetype = ''

set @SQL = N'SELECT @strCodetype = codetype FROM ' + '['+ @strServer+'].'+@strDBName+'.dbo.syscode WHERE codename= ''scxtquerymenu'')'


-------------------------------------------
execute sp_executesql @SQL,
N'@strCodetype varchar(100) output',
@strCodetype = @strCodetype
-------------------------------


SET NOCOUNT OFF
GO
回复
viptiger 2004-04-20
CREATE PROCEDURE Up_Convert
@strServer VARCHAR(30),
@strDBName VARCHAR(30)
AS
DECLARE @strCodetype VARCHAR(30)
DECLARE @SQL nvarchar(500)
declare @strCodetype varchar(100)

SET NOCOUNT ON
SET @strCodetype = ''

set @SQL = N'SELECT @strCodetype = codetype FROM ' + '['+ @strServer+'].'+@strDBName+'.dbo.syscode WHERE codename= ''scxtquerymenu'')'


-------------------------------------------
execute sp_executesql @SQL,
@strCodetype output,
@strCodetype = @strCodetype
-------------------------------


SET NOCOUNT OFF
GO
回复
viptiger 2004-04-20
CREATE PROCEDURE Up_Convert
@strServer VARCHAR(30),
@strDBName VARCHAR(30)
AS
DECLARE @strCodetype VARCHAR(30)
DECLARE @SQL nvarchar(500)
declare @@strCodetype varchar(100)

SET NOCOUNT ON
SET @strCodetype = ''

set @SQL = N'SELECT @strCodetype = codetype FROM ' + '['+ @strServer+'].'+@strDBName+'.dbo.syscode WHERE codename= ''scxtquerymenu'')'


-------------------------------------------
execute sp_executesql @SQL,
@strCodetype output,
@strCodetype = @strCodetype
-------------------------------


SET NOCOUNT OFF
GO
回复
相关推荐
发帖
疑难问题
创建于2007-09-28

2.1w+

社区成员

MS-SQL Server 疑难问题
申请成为版主
帖子事件
创建了帖子
2004-04-20 02:46
社区公告
暂无公告