第一版比较粗略
http://blog.youkuaiyun.com/happyflystone/archive/2008/07/23/2700649.aspx
这次收录比较详细 ,并且形成表格放在DB中
需要的朋友可以到我的资源里下载使用
http://download.youkuaiyun.com/user/happyflystone
其实也没有什么技术含量
- ------------------------------------
- --Author:Flystone
- --Version:V1.001
- --Date:2008-08-0421:56:11
- --转载注明出处
- ------------------------------------
- alterfunctionf_getinfo(@cidvarchar(18))
- returnsvarchar(100)
- as
- begin
- --不做合法性检测
- declare@svarchar(100)
- select@s=isnull(@s,'')+casewhendescrp='县'then''elsedescrpend
- fromsfz_info
- wheredm=left(@cid,2)+'0000'ordm=left(@cid,4)+'00'ordm=left(@cid,6)
- orderbydm
- return@s
- end
- go
- selectdbo.f_getinfo('110229')
- /*
- ----------------------------------------------------------------------------------------------------
- 北京市延庆县
- (所影响的行数为1行)
- */
- selectdbo.f_getinfo('110102')
- /*
- ----------------------------------------------------------------------------------------------------
- 北京市市辖区西城区
- (所影响的行数为1行)
- */
- selectdbo.f_getinfo('431229')
- /*
- ----------------------------------------------------------------------------------------------------
- 湖南省怀化市靖州苗族侗族自治县
- (所影响的行数为1行)
- */
本文介绍了一个SQL函数f_getinfo,该函数可以根据输入的身份证号前六位返回对应的地区信息。通过左截取身份证号码的不同长度并与数据库中的地区代码进行匹配,能够返回详细的地区名称,如省份、城市和县区等。
2504

被折叠的 条评论
为什么被折叠?



