利用SQL生成xml示例
2015-10-21 16:01
337 查看
/*
利用SQL生成xml示例
*/
/*显示空的字段*/
SELECT TOP 1 PatName,PAT.PatID,PID.ImageNo,PAT.RegPatID
FROM Patient AS PAT INNER JOIN(SELECT PATID,PatNumber AS ImageNo FROM PatientIdentify WHERE NTypeCode='0003') AS PID ON PAT.PatID=PID.PatID
WHERE PatOtherName LIKE 'YIN%' FOR XML RAW('Patient'),ELEMENTS XSINIL,ROOT('ROWDATA')
/*不显示空的字段*/
SELECT TOP 1 PatName,PAT.PatID,PID.ImageNo,PAT.RegPatID
FROM Patient AS PAT INNER JOIN(SELECT PATID,PatNumber AS ImageNo FROM PatientIdentify WHERE NTypeCode='0003') AS PID ON PAT.PatID=PID.PatID
WHERE PatOtherName LIKE 'YIN%' FOR XML RAW('Patient'),ELEMENTS ,ROOT('ROWDATA')
/*lqy 1.FOR XML RAW('Patient')*/
select top 1
PAT.PatID, PAT.PatName, PAT.PatOtherName, PAT.Birthday, PAT.IdentityNumber, PAT.SexCode,
pids.PatNumber,od.DepartmentCode,vst.OutpatientCode,vst.WardCode,vst.BedNumber,vst.InpatientCode,EXM.RegistrationDateTime,
RP.ReportID, RP.ImageFinding, RP.Impression,rp.EquipeType,rp.BiopsySiteCode,rp.Proposal,rp.HP,rp.ReportPhysicianCode,
RP.ReportBarcode, RP.ReportPhysicianCode, RP.ReportDateTime,
RP.VerifyDoctorCode1, RP.VerifyDoctorCode2, RP.VerifyDateTime1, RP.VerifyDateTime2,RP.CurrentStatus
from ReportContent as RP
INNER JOIN Examination AS EXM ON RP.ReportID=EXM.ReportID
INNER JOIN [Order] AS OD ON EXM.OrderID=OD.OrderID
INNER JOIN Visit AS VST ON OD.VisitID=VST.VisitID
INNER JOIN (SELECT PatID,PatNumber FROM PatientIdentify WHERE NTypeCode='0003') AS PIDS ON VST.PatID=PIDS.PatID
INNER JOIN Patient AS PAT ON VST.PatID=PAT.PatID
WHERE 1=1 and CurrentStatus>=140 FOR XML RAW('Patient'),ELEMENTS XSINIL,ROOT('SIMED_REPORT')
select top 1 dbo.GetDictionary('Sex','0001','DisplayText') as Sex from patient
--------------------2.FOR XML auto------------
select top 100
PAT.PatID, PAT.PatName, PAT.PatOtherName,datediff(YY,PAT.Birthday,od.OrderDateTime)AS PatAge, PAT.IdentityNumber,
dbo.GetDictionary('Sex',pat.SexCode,'DisplayText') as Sex,
dbo.GetDictionary('DepartmentInfo',od.DepartmentCode,'DisplayText') as DepartmentName,
pids.PatNumber, dbo.GetDictionary('Ward',vst.WardCode,'DisplayText') as OutpatientName,
vst.BedNumber,vst.InpatientCode,EXM.RegistrationDateTime,
RP.ReportID, RP.ImageFinding, RP.Impression,
rp.BiopsySiteCode,pids.PatNumber, rp.EquipeType,
rp.Proposal,rp.HP,rp.ReportPhysicianCode,
dbo.GetDictionary('Staff',rp.ReportPhysicianCode,'DisplayText') as ReportPhysicianName,
RP.ReportBarcode, RP.ReportPhysicianCode, RP.ReportDateTime,
RP.VerifyDoctorCode1, RP.VerifyDoctorCode2, RP.VerifyDateTime1, RP.VerifyDateTime2,RP.CurrentStatus
from ReportContent as RP
INNER JOIN Examination AS EXM ON RP.ReportID=EXM.ReportID
INNER JOIN [Order] AS OD ON EXM.OrderID=OD.OrderID
INNER JOIN Visit AS VST ON OD.VisitID=VST.VisitID
INNER JOIN (SELECT PatID,PatNumber FROM PatientIdentify WHERE NTypeCode='0003') AS PIDS ON VST.PatID=PIDS.PatID
INNER JOIN Patient AS PAT ON VST.PatID=PAT.PatID
WHERE 1=1 and rp.BiopsySiteCode<>'' and CurrentStatus>=140 FOR XML auto,ELEMENTS XSINIL,ROOT('SIMED_REPORT')
---------------------
select * from p_Dicts where Name like'%沈%'
select * from p_DictValues where ScopeId='ReportPhrase'
-------------------------
利用SQL生成xml示例
*/
/*显示空的字段*/
SELECT TOP 1 PatName,PAT.PatID,PID.ImageNo,PAT.RegPatID
FROM Patient AS PAT INNER JOIN(SELECT PATID,PatNumber AS ImageNo FROM PatientIdentify WHERE NTypeCode='0003') AS PID ON PAT.PatID=PID.PatID
WHERE PatOtherName LIKE 'YIN%' FOR XML RAW('Patient'),ELEMENTS XSINIL,ROOT('ROWDATA')
/*不显示空的字段*/
SELECT TOP 1 PatName,PAT.PatID,PID.ImageNo,PAT.RegPatID
FROM Patient AS PAT INNER JOIN(SELECT PATID,PatNumber AS ImageNo FROM PatientIdentify WHERE NTypeCode='0003') AS PID ON PAT.PatID=PID.PatID
WHERE PatOtherName LIKE 'YIN%' FOR XML RAW('Patient'),ELEMENTS ,ROOT('ROWDATA')
/*lqy 1.FOR XML RAW('Patient')*/
select top 1
PAT.PatID, PAT.PatName, PAT.PatOtherName, PAT.Birthday, PAT.IdentityNumber, PAT.SexCode,
pids.PatNumber,od.DepartmentCode,vst.OutpatientCode,vst.WardCode,vst.BedNumber,vst.InpatientCode,EXM.RegistrationDateTime,
RP.ReportID, RP.ImageFinding, RP.Impression,rp.EquipeType,rp.BiopsySiteCode,rp.Proposal,rp.HP,rp.ReportPhysicianCode,
RP.ReportBarcode, RP.ReportPhysicianCode, RP.ReportDateTime,
RP.VerifyDoctorCode1, RP.VerifyDoctorCode2, RP.VerifyDateTime1, RP.VerifyDateTime2,RP.CurrentStatus
from ReportContent as RP
INNER JOIN Examination AS EXM ON RP.ReportID=EXM.ReportID
INNER JOIN [Order] AS OD ON EXM.OrderID=OD.OrderID
INNER JOIN Visit AS VST ON OD.VisitID=VST.VisitID
INNER JOIN (SELECT PatID,PatNumber FROM PatientIdentify WHERE NTypeCode='0003') AS PIDS ON VST.PatID=PIDS.PatID
INNER JOIN Patient AS PAT ON VST.PatID=PAT.PatID
WHERE 1=1 and CurrentStatus>=140 FOR XML RAW('Patient'),ELEMENTS XSINIL,ROOT('SIMED_REPORT')
select top 1 dbo.GetDictionary('Sex','0001','DisplayText') as Sex from patient
--------------------2.FOR XML auto------------
select top 100
PAT.PatID, PAT.PatName, PAT.PatOtherName,datediff(YY,PAT.Birthday,od.OrderDateTime)AS PatAge, PAT.IdentityNumber,
dbo.GetDictionary('Sex',pat.SexCode,'DisplayText') as Sex,
dbo.GetDictionary('DepartmentInfo',od.DepartmentCode,'DisplayText') as DepartmentName,
pids.PatNumber, dbo.GetDictionary('Ward',vst.WardCode,'DisplayText') as OutpatientName,
vst.BedNumber,vst.InpatientCode,EXM.RegistrationDateTime,
RP.ReportID, RP.ImageFinding, RP.Impression,
rp.BiopsySiteCode,pids.PatNumber, rp.EquipeType,
rp.Proposal,rp.HP,rp.ReportPhysicianCode,
dbo.GetDictionary('Staff',rp.ReportPhysicianCode,'DisplayText') as ReportPhysicianName,
RP.ReportBarcode, RP.ReportPhysicianCode, RP.ReportDateTime,
RP.VerifyDoctorCode1, RP.VerifyDoctorCode2, RP.VerifyDateTime1, RP.VerifyDateTime2,RP.CurrentStatus
from ReportContent as RP
INNER JOIN Examination AS EXM ON RP.ReportID=EXM.ReportID
INNER JOIN [Order] AS OD ON EXM.OrderID=OD.OrderID
INNER JOIN Visit AS VST ON OD.VisitID=VST.VisitID
INNER JOIN (SELECT PatID,PatNumber FROM PatientIdentify WHERE NTypeCode='0003') AS PIDS ON VST.PatID=PIDS.PatID
INNER JOIN Patient AS PAT ON VST.PatID=PAT.PatID
WHERE 1=1 and rp.BiopsySiteCode<>'' and CurrentStatus>=140 FOR XML auto,ELEMENTS XSINIL,ROOT('SIMED_REPORT')
---------------------
select * from p_Dicts where Name like'%沈%'
select * from p_DictValues where ScopeId='ReportPhrase'
-------------------------
相关文章推荐
- 利用SQL生成xml示例
- [转载]MySQL concat函数的使用
- ORACLE中根据生日得到年龄
- mysql通过navicate工具图形化复制整库
- 10个出色的NoSQL数据库
- Oracle 12c 手工创建CDB数据库
- oracle 11g ocm 考试内容
- MySQL数据库
- Oracle 中Java 对象与PL/SQL类型的映射及使用
- MySql规范
- postgresql根据指定序列进行自定义排序
- MySQL数据库常用命令
- MYSQL 数据类型
- mysql 多实例案例实战
- SQL多条语句的插入
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
- sql 查询重复
- memcached集群负载均衡
- JDBC与MySql:事务
- tpc-e数据库测试EGen数据的生成