SQL Zip Compression, RegEx and Random Functions
2016-08-23
0 0 0
no vote
Other
Earn points
Translated by maninwest@Codeforge Author Brad Joss@Codeproject
The attached code exposes the SharpZipLib zip compression library as a thread-safe Common Language Runtime (CLR) SQL functions. Additional functions included in the library (since they were already compiled into our production systems) are provided for Regular Expression (RegEx) evaluation within SQL. This is probably best introduced though a quick example:
-- Zip Example -- DECLARE @input nvarchar(4000) = REPLICATE(N'HELLO 1 HELLO 2 HELLO 3 HELLO', 100) DECLARE @zipped nvarchar(1000) = dbo.ZipString(@input) SELECT @zipped, -- eJztyTENACAMADArswBoIN ... LEN(@input), -- 2900 bytes LEN(@zipped), -- 68 bytes 100.0 - (100.0 * ((LEN(@zipped)*1.0)/(LEN(@input)*1.0))), -- 97.6% Reduction IIF(@input = dbo.UnzipString(@zipped), 'PASS', 'FAIL') -- Pass -- RegEx Example -- select dbo.RegexMatchCount([Phone], '\d') as [DIGIT_COUNT] from #Users
c#
压缩
zip
regex
函数
随机
Related Source Codes
No. 186: DX0110- Source code for community propert
0
0
no vote
No. 219: DX0149- Source code for community propert
0
0
no vote
Verification code identification
0
0
no vote
CSV data analysis tool
0
0
no vote
Source code of hospital medical record information
0
0
no vote
No comment