本文介绍了如何删除空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DECLARE @cols AS NVARCHAR(MAX),
@query AS NVARCHAR(MAX)
select @cols = STUFF((SELECT distinct ',' + QUOTENAME(StuDocname)
from StudentDocuments
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,1,'')
set @query = 'SELECT StudentCode,Stuname, ' + @cols + ' from
(
select DISTINCT SC.StuCurrentId,StudentCode,upper(First_Name + '' '' + Middle_Name + '' '' + Last_Name) as Stuname
,Sd.StuDocname,SASD.IsSelected,(case when IsSelected = 1 then ''YES''
when IsSelected = 0 then ''NO''
end) as status
from tbl_Student_Current SC
inner join StudentAdmission SA on SC.StudentId=SA.StudentId
inner join StudentAdmission_StudentDocuments SASD on SA.StudentId=SASD.StudentId
left outer join StudentDocuments SD on SASD.StudentDocId=SD.StuDocId
) x
pivot
(
MAX(status)
for StuDocname in (' + @cols + ')
) p '
execute(@query)
推荐答案
Declare @var as varchar(10)=null
select isnull(@var,0) as Result
这篇关于如何删除空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!