TEMP NOTE PHÂN TÍCH
Ý nghĩa chức năng
temp dùng để lưu vết cấu trúc, nguyên tắc tạo báo cáo
khi sửa đổi bổ sung thì nên chèn dòng và mô tả lý do tại sao
Code tạo temp Phân tích
declare @nghiepvu int = 1034
select N'.I. Mô tả nội dung nghiệp vụ'+ char(13)
+ char(13) + N'.II. Chi tiết cấu hinh nghiệp vụ'+ char(13)
from nghiepvu where nghiepvu=@nghiepvu
union
select N'1. ID + Tên Nghiệp vụ:'
+ char(13) + space(5) + convert(nvarchar(10),nghiepvu) +' - '+ vietnam
from nghiepvu where nghiepvu=@nghiepvu
union
select N'2. ẩn hiện chung:'
+ char(13) + space(5)+ nghiepvu.FieldShow
from nghiepvu where nghiepvu=@nghiepvu
union
select N'3. ẩn hiện chi tiết:'
+ char(13) + space(5) + nghiepvu.FieldDetail
from nghiepvu where nghiepvu=@nghiepvu
union
select N'4. ẩn hiện nút:'
+ char(13) + space(5)+ case when AnHienNut<>'' then nghiepvu.AnHienNut else '-null' end
from nghiepvu where nghiepvu=@nghiepvu
union
select N'5. Đặt mặc định:'
+ char(13) + space(5) + case when [SetDefault]<>'' then nghiepvu.[SetDefault] else '-null' end
from nghiepvu where nghiepvu=@nghiepvu
union
select N'6. Trường kiểm tra:'
+ char(13) + space(5) + case when FieldKtra<>'' then nghiepvu.FieldKtra else '-null' end
from nghiepvu where nghiepvu=@nghiepvu
union
select N'7. Trường không được trống:'
+ char(13) + space(5) + case when FieldNotEmpty<>'' then nghiepvu.FieldNotEmpty else '-null' end
from nghiepvu where nghiepvu=@nghiepvu
union
select N'8. Trường để lại sau khi lưu:'
+ char(13) + space(5) + case when DeLai<>'' then nghiepvu.DeLai else '-null' end
from nghiepvu where nghiepvu=@nghiepvu
union
select N'9. Trường readonly:'
+ char(13) + space(5)+ case when FReadOnly<>'' then nghiepvu.FReadOnly else '-null' end
from nghiepvu where nghiepvu=@nghiepvu
Code so sánh ẩn hiện của form chung giữa 2 bản
Copy text ẩn hiện của bản số 1 và gán vào biến @fieldShowSosanh
Chạy câu lệnh dưới để nhìn thấy sự khác biệt
-- Gán lại giá trị cho biến @fieldShowSosanh
declare @fieldShowSosanh nvarchar(2000) = 'Ngay,0#ChungTu,1#PtVAT,5#SoHD,3#NgayHD,4#OngBa,6#'
declare @fieldShowHientai nvarchar(2000) =''
-- sửa lại giá trị nghiệp vụ
declare @nghiepvu int = 301
set @fieldShowHientai = (select fieldshow from nghiepvu where nghiepvu=@nghiepvu)
select T1.tencot as tencotHientai, T2.tencot as tencotSosanh from
(
select *
, substring(SplitItem,1, CHARINDEX(',', splititem)-1) as tencot
from [dbo].[SplitString](@fieldShowHientai, '#')
)T1 full outer join
(
select *
, substring(SplitItem,1, CHARINDEX(',', splititem)-1) as tencot
from [dbo].[SplitString](@fieldShowSosanh, '#')
)T2
on T1.tencot =t2.tencot
Code so sánh ẩn hiện của lưới chi tiết giữa 2 bản
Copy text ẩn hiện của bản bản số 1 và gán vào biến @detailSosanh
chạy câu lệnh dưới để nhìn thấy sự khác biệt ẩn hiện cột
-- gán lại giá trị cho biến @detailSosanh
declare @detailSosanh nvarchar(2000) = 'TkCo(388)TaiKhoan,ma,ma#soLuong(391)#donGia(392)#soInvoice(100)'
declare @detailHientai nvarchar(2000) =''
-- sửa lại giá trị biến nghiệp vụ
declare @nghiepvu int = 301
set @detailHientai = (select fielddetail from nghiepvu where nghiepvu=@nghiepvu)
select T1.tencot as tencotHientai, T2.tencot as tencotSosanh from
(
select *
, substring(SplitItem, 1, CHARINDEX('(', splititem)-1) as fieldName
, substring(SplitItem, CHARINDEX(')', splititem) + 1, LEN(splitItem) - CHARINDEX(')', splititem) ) as sourceName
, case when substring(SplitItem, CHARINDEX(')', splititem) + 1, LEN(splitItem) - CHARINDEX(')', splititem) ) <>''
then substring(SplitItem, CHARINDEX(')', splititem) + 1, LEN(splitItem) - CHARINDEX(')', splititem) )
else substring(SplitItem, 1, CHARINDEX('(', splititem)-1)
end as tencot
from [dbo].[SplitString](@detailHientai, '#')
)T1 full outer join
(
select *
, substring(SplitItem, 1, CHARINDEX('(', splititem)-1) as fieldName
, substring(SplitItem, CHARINDEX(')', splititem) + 1, LEN(splitItem) - CHARINDEX(')', splititem) ) as sourceName
, case when substring(SplitItem, CHARINDEX(')', splititem) + 1, LEN(splitItem) - CHARINDEX(')', splititem) ) <>''
then substring(SplitItem, CHARINDEX(')', splititem) + 1, LEN(splitItem) - CHARINDEX(')', splititem) )
else substring(SplitItem, 1, CHARINDEX('(', splititem)-1)
end as tencot
from [dbo].[SplitString](@detailSosanh, '#')
)T2
on T1.tencot =t2.tencot
Last updated