-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date, ,>
-- Description: <Description, ,>
--
-- =============================================
CREATE FUNCTION [dbo].[GetRoleLevel]
(
@ID varchar(1000)
)
RETURNS varchar
AS
BEGIN
-- Declare the return variable here
DECLARE @Level varchar(4000)
-- Add the T-SQL statements to compute the return value here
SELECT @Level=name FROM dbo.products where id in (@ID)

-- Return the result of the function
RETURN @LevelEND

解决方案 »

  1.   

    SELECT @Level=name FROM dbo.products where CHARINDEX(','+id+',',','+@ID+',')>0
      

  2.   

    SELECT @Level=name FROM dbo.products where id in ('+@ID+')
      

  3.   

    CREATE FUNCTION [dbo].[GetRoleLevel]
    (
        @ID varchar(1000)
    )
    RETURNS varchar
    AS
    BEGIN
        -- Declare the return variable here
        DECLARE @Level varchar(4000)
        -- Add the T-SQL statements to compute the return value here    
        SELECT @Level=ISNULL(@Level+',','')+name FROM dbo.products CHARINDEX(','+id+',',','+@ID+',')>0
                                    
        -- Return the result of the function
        RETURN @LevelEND看楼主的意思应该是这样
      

  4.   

    怎么还是不行.我的数据库内有一条记录.可是查出的还是空值.也不为<NULL>
      

  5.   


    服务器: 消息 170,级别 15,状态 1,过程 GetRoleLevel,行 9
    第 9 行: ',' 附近有语法错误。