E6的推算,分拆值等经典SQL源码及分析
E6的推算,分拆列值等经典SQL源码及分析
--查询表的默认值
if object_id(tb) is not null
drop table tb
go
create table tb(id int,name varchar(50) default abc,num int default 5)
insert into tb(id) select 1
insert into tb select 1,oo,100
insert into tb(id,name) select 1,oo
go
declare @tbname varchar(50)
set @tbname=tb--表名
select @tbname as tbname, as colname,replace(replace(replace(replace(b.[text],(,),),),((,),)),) as defaultvalue
from sysconstraints a join syscomments b on a.constid=b.id
join syscolumns c on a.id=c.id and a.colid=c.colid
where a.id=object_id(@tbname) and object_name(a.constid) like %df%
SQL code--存储过程语句查询
if object_id(proc_ttt) is not null
drop proc proc_ttt
go
create proc proc_ttt
as
select 1 union select 2
go
select [text] from syscomments
where id=object_id(proc_ttt)
EXEC SP_HELPTEXT proc_ttt
--通过身份证获得户籍
create function f_getcityfromcid (@cid varchar(18))
returns varchar(50)
as
begin
declare @acity varchar(1000)
set @acity = ____,____,____,____,____,____,____,____,____,____,____,北京__,天津__,河北__,山西__,内蒙古_,____,____,____,____,____,辽宁__,吉林__,黑龙江_,____,____,____,____,____,____,____,上海__,江苏__,浙江__,安微__,福建__,江西__,山东__,____,____,____,河南__,湖北__,湖南__,广东__,广西__,海南__,____,____,____,重庆__,四川__,贵州__,云南__,西藏__,____,____,____,____,____,____,陕西__,甘肃__,青海__,宁夏__,新疆__,____,____,____,____,____,台湾__,____,____,____,____,____,____,____,____,____,香港__,澳门__,____,____,____,____,____,____,____,____,国外__,
set @cid = upper(@cid)
IF (len(@cid) 18 OR patindex(%[^0-9X]%,@cid) 0)
RETURN 你小子骗我,这不是合法的身份证
IF substring(@acity,cast(left(@cid,2) as int)* 5+1,4) =
RETURN 你小子骗我,这身份证的地区码不存在
RETURN 这小子是:+replace(substring(@acity,cast(left(@cid,2) as int)* 5+1,4),_,)
end
go
select dbo.f_getcityfromcid(32108519760502ttt9)
/*
你小子骗我,这不是合法的身份证
(所影响的行数为 1 行)
*/
select dbo.f_getcityfromcid***026**9)
/*
这小子是:江苏
(所影响的行数为 1 行)
*/
drop function f_getcityfromcid
--随机选择
您可能关注的文档
- 环境词汇——Chna Daily.doc
- hack游戏教程.doc
- 【翟鸿森教授经典录】.doc
- WMIC 命令行理方式.doc
- 员工学习分享工作得.ppt
- FreeBSD72支持的网卡驱动列表.doc
- 中国学生健康体检理.ppt
- linux orcle安装操作步骤总结.doc
- 桌面云用户常见问手册.doc
- 口袋怪兽绿宝石攻(超详细).doc
- 小区绿化施工协议书.docx
- 墙面施工协议书.docx
- 1 古诗二首(课件)--2025-2026学年统编版语文二年级下册.pptx
- (2026春新版)部编版八年级道德与法治下册《3.1《公民基本权利》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《4.3《依法履行义务》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《6.2《按劳分配为主体、多种分配方式并存》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《6.1《公有制为主体、多种所有制经济共同发展》PPT课件.pptx
- 初三教学管理交流发言稿.docx
- 小学生课外阅读总结.docx
- 餐饮门店夜经济运营的社会责任报告(夜间贡献)撰写流程试题库及答案.doc
最近下载
- 2025年陕西省汉中市某中学小升初入学分班考试英语考试真题含答案.docx VIP
- DB31T 1236-2020 未成年人司法社会工作服务规范.docx VIP
- 宣贯培训(2026年)《DLT 2772—2024火力发电厂输煤廊道巡检装置技术规范》.pptx VIP
- 2026年北京中考白皮书.pdf VIP
- 2025届苏锡常镇高三(一模)数学试题及参考答案.pdf VIP
- 《人工智能辅助的翻译技术》课件.ppt VIP
- 沉浸式非遗体验—宋代点茶.pptx VIP
- PET Complete精品教学课件 unit 3 having fun.pptx
- 年产2万吨马铃薯全粉项目可行性研究报告.docx
- 《计算机网络基础》课件——OSI参考模型.pptx VIP
原创力文档

文档评论(0)