一个存储过程问题,马上结贴

cnidb 2004-03-08 01:31:43
CREATE PROC netShopQuery
@shopID int,
@userID int,
@RootCategoryID int,
@showNameLike nvarchar(30),
@shopType int
As declare
@sql nvarchar(3000),
@inShopID nvarchar(100),
@inUserID nvarchar(100),
@inRootCategoryID nvarchar(100),
@inShopNameLike nvarchar(200),
@inShopType nvarchar(100)

if @shopID > 0
begin
set @inShopID = ' and ship_ID = '+cast(@shopID As nvarchar(10))
end
else
begin
set @inShopID = ''
end

if @userID > 0
begin
set @inuserID = ' and user_ID = '+cast(@userID As nvarchar(10))
end
else
begin
set @inuserID = ''
end

if @RootCategoryID > 0
begin
set @RootCategoryID = ' and RootCategory_ID = '+cast(@RootCategoryID As nvarchar(10))
end
else
begin
set @RootCategoryID = ''
end

if @ShopType > 0
begin
set @inShopType = ' and shop_Type = '+cast(@ShopType As nvarchar(10))
end
else
begin
set @inShopType = ''
end

if @showNameLike <> '0'
begin
set @inShopNameLike = ' and shop_Name like %'+cast(@showNameLike As nvarchar(200))+'%'
end
else
begin
set @inShopNameLike = ''
end
set @sql ='select * from sq_shop where shop_ID > 0 '+ @inShopID+@inuserID+@RootCategoryID+@inShopNameLike+@inShopType+' order By shop_Order asc'
exec(@sql)
GO

报错:
[Microsoft][ODBC SQL Server Driver][SQL Server]将 nvarchar 值 ' and user_ID = 53' 转换为数据类型为 int 的列时发生语法错误。

/Shop.asp,行 53

...全文
11 点赞 收藏 12
写回复
12 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
MS-SQL Server
创建于2007-09-28

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2004-03-08 01:31
社区公告
暂无公告