sql isnull用法

通过用isnull()把某一列下的所有数据组成一个字符串

DECLARE @str VARCHAR(max)

begin
--select * from [CONVERSEMDM].[mdm].[ViewProduct] where validity=1  AND SEASON in ( ''+REPLACE(@Season,',',''',''')+'') AND CN_Digital_Buying_Flag='Y'
    --= 'select * from [CONVERSEMDM].[mdm].[ViewProduct] where validity=1  AND SEASON in ('''+REPLACE(@Season,',',''',''')+''')'
 
    SET @str=''
    SELECT  @str= isnull(@str,'')+RoleName+','  FROM [Converse_MDMWEB].[dbo].[System_RoleInfo] WHERE  validity=1
    SELECT  @str
    end

效果:

 

posted @ 2020-12-18 10:37  看花人墨客  阅读(263)  评论(0编辑  收藏  举报