34,588
社区成员
发帖
与我相关
我的任务
分享
------------------------------------
ALTER PROCEDURE [dbo].[T_Menu_User_Role_ExistsByMenuAll]
@aid int,
@rids nvarchar(200),
@mid int,
@other1 int
AS
DECLARE @TempID int
SELECT @TempID = count(1) FROM [T_Menu_User_Role] WHERE (aid=@aid AND other1=@other1) OR (rid IN (@rids) AND other1=@other1)
IF @TempID = 0
RETURN 0
ELSE
RETURN 1
消息 245,级别 16,状态 1,过程 T_Menu_User_Role_ExistsByMenuAll,第 14 行
在将 nvarchar 值 '1,2' 转换成数据类型 int 时失败。
ALTER PROCEDURE [dbo].[T_Menu_User_Role_ExistsByMenuAll]
@aid int,
@rids varchar(200),
@mid int,
@other1 int
AS
DECLARE @TempID int
DECLARE @SQL NVARCHAR(MAX)
Declare @count int
SET @SQL = N'SELECT @TempID = count(1) FROM [T_Menu_User_Role] WHERE (aid=@aid AND other1=@other1) OR (rid IN (' + @rids + ') AND other1=@other1)'
EXEC SP_EXECUTESQL @SQL,N'@aid int,@other1 int,@TempID INT OUTPUT',@aid,@other1 ,@TempID OUTPUT
IF @TempID = 0
RETURN 0
ELSE
RETURN 1
ALTER PROCEDURE [dbo].[T_Menu_User_Role_ExistsByMenuAll]
@aid int,
@rids nvarchar(200),
@other1 int
AS
DECLARE @StrSql nvarchar(1024)
DECLARE @TempID int
set @strSql = 'SELECT @TempID = count(1) FROM [T_Menu_User_Role] WHERE (aid=@aid AND other1=@other1) OR (rid IN (@rids) AND other1=@other1)'
execute sp_executesql @strSql ,N'@TempID int output,@aid int,@rids nvarchar,@other1 int',@TempID output ,@aid,@rids,@other1
IF @TempID = 0
RETURN 0
ELSE
RETURN 1
ALTER PROCEDURE [dbo].[T_Menu_User_Role_ExistsByMenuAll]
@aid int,
@rids nvarchar(200),
@mid int,
@other1 int
AS
DECLARE @StrSql nvarchar(1024)
DECLARE @TempID int
set @strSql = 'SELECT @TempID = count(1) FROM [T_Menu_User_Role] WHERE (aid=@aid AND other1=@other1) OR (rid IN ('' + @rids + '') AND other1=@other1)
'
execute sp_executesql @strSql ,N'@TempID int output,@aid int,@mid int,@other1 int',@TempID output ,@aid,@mid,@other1
IF @TempID = 0
RETURN 0
ELSE
RETURN 1
if object_id('T_Menu_User_Role_ExistsByMenuAll') is not null
drop PROCEDURE [dbo].[T_Menu_User_Role_ExistsByMenuAll]
go
CREATE PROCEDURE [dbo].[T_Menu_User_Role_ExistsByMenuAll]
@aid int,
@rids nvarchar(200),
@mid int,
@other1 int
AS
DECLARE @TempID int
SELECT @TempID = count(1) FROM [T_Menu_User_Role] WHERE (aid=@aid AND other1=@other1) OR (rid IN (ltrim(@rids)) AND other1=@other1)
-- print @tempid
IF @TempID = 0
RETURN 0
ELSE
RETURN 1
ALTER PROCEDURE [dbo].[T_Menu_User_Role_ExistsByMenuAll]
@aid int,
@rids nvarchar(200),
@mid int,
@other1 int
AS
DECLARE @TempID int
DECLARE @SQL NVARCHAR(MAX)
SET @SQL = N'
SELECT @TempID = count(1) FROM [T_Menu_User_Role] WHERE (aid=@aid AND other1=@other1) OR (rid IN (' + @rids + ') AND other1=@other1)'
EXEC SP_EXECUTESQL @SQL,'@aid int,@other1 int,@TempID INT OUTPUT',@aid,@other1 ,@TempID OUTPUT
IF @TempID = 0
RETURN 0
ELSE
RETURN 1
ALTER PROCEDURE [dbo].[T_Menu_User_Role_ExistsByMenuAll]
@aid int,
@rids nvarchar(200),
@mid int,
@other1 int
AS
DECLARE @TempID int
SELECT @TempID = count(1) FROM [T_Menu_User_Role] WHERE (aid=@aid AND other1=@other1) OR (CHARINDEX(',' + rtrim(rid) + ',',',' + @rids + ',') > 0 AND other1=@other1)
IF @TempID = 0
RETURN 0
ELSE
RETURN 1
ALTER PROCEDURE [dbo].[T_Menu_User_Role_ExistsByMenuAll]
@aid int,
@rids nvarchar(200),
@mid int,
@other1 int
AS
DECLARE @TempID int
SELECT @TempID = count(1) FROM [T_Menu_User_Role] WHERE (aid='+@aid+' AND other1='+@other1+') OR (rid IN (ltrim(@rids)) AND other1='+@other1+')
IF @TempID = 0
RETURN 0
ELSE
RETURN 1