创建公共配置表,并以全国区县代码维护为例
Posted 我思故我在我有我精彩--liangqihui
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了创建公共配置表,并以全国区县代码维护为例相关的知识,希望对你有一定的参考价值。
---------------------
--创建通用选项表
/****** Object: Table [dbo].[sysComOption] Script Date: 01/08/2017 14:08:18 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[sysComOption]( [ID] [int] IDENTITY(1,1) NOT NULL, [Code] [nvarchar](20) NOT NULL, [ParentCode] [nvarchar](20) NULL, [Version] [int] NOT NULL, [Status] [int] NOT NULL, [OptionType] [nvarchar](20) NULL, [OptionTag] [nvarchar](150) NULL, [OtherTag] [xml] NULL, [OptionName] [nvarchar](50) NOT NULL, [OptionCNName] [nvarchar](50) NOT NULL, [OptionDisplayName] [nvarchar](50) NULL, [OptionAbbPYName] [nvarchar](20) NULL, [OptionFullPYName] [nvarchar](150) NULL, [OptionValueType] [int] NOT NULL, [OptionDisplayValue] [nvarchar](50) NULL, [OptionValueInt] [int] NULL, [OptionValueNvarchar] [nvarchar](150) NULL, [OptionValueFloat] [float] NULL, [OptionValueNum] [numeric](18, 0) NULL, [Comments] [nvarchar](500) NULL, [Create_By] [int] NULL, [Create_date] [datetime] NULL, [lastmaintenance_by] [int] NULL, [Lastmodify_date] [datetime] NULL, CONSTRAINT [PK_sysComOption] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO EXEC sys.sp_addextendedproperty @name=N\'MS_Description\', @value=N\'1 int;5 nvarchat; 10 float;15 Num\' , @level0type=N\'SCHEMA\',@level0name=N\'dbo\', @level1type=N\'TABLE\',@level1name=N\'sysComOption\', @level2type=N\'COLUMN\',@level2name=N\'OptionValueType\' GO
--创建区县初始化数据表
--创建区县数据初始化表 /****** Object: Table [dbo].[regionTemp] Script Date: 01/08/2017 14:09:42 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[regionTemp]( [code] [float] NULL, [parentcode] [varchar](10) NULL, [parentRegionname] [nvarchar](255) NULL, [Regionname] [nvarchar](255) NULL, [GPS] [varchar](46) NULL ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO
code parentcode parentRegionname Regionname GPS
110000 110000 北京市 北京市 GPS(39.9081726,116.3979471)
110101 110000 北京市 东城区 GPS(39.9351199,116.4093947)
110102 110000 北京市 西城区 GPS(39.9351775,116.3638616)
110103 110000 北京市 崇文区 GPS(39.8882042,116.4318180)
110104 110000 北京市 宣武区 GPS(39.8771968,116.3530469)
110105 110000 北京市 朝阳区 GPS(39.9527472,116.4977252)
110106 110000 北京市 丰台区 GPS(39.8307687,116.2682462)
-----------------------------------------------
创建拼音缩写(全拼转换 & 将汉字转换首个拼音大写字母)
/****** Object: UserDefinedFunction [dbo].[fn_GetFullPinyin] Script Date: 01/08/2017 14:27:01 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE function [dbo].[fn_GetFullPinyin](@words nVARCHAR(2000),@withblank int) --@withblank确定每个中文字转为拼音后,每个汉字之间是否需要留下空格0为不留,1为留 RETURNS VARCHAR(8000) AS BEGIN DECLARE @word nchar(1) DECLARE @paceword nvarchar(1) DECLARE @pinyin VARCHAR(8000) DECLARE @i INT DECLARE @words_len INT DECLARE @unicode INT SET @i = 1 SET @words =ltrim(rtrim(@words)) SET @words_len =len(@words) WHILE(@i <= @words_len)--循环取字符 BEGIN SET @word =substring(@words, @i, 1) SET @unicode =unicode(@word) if (@withblank=0) begin set @paceword =\'\' end else if(@withblank=1) begin set @paceword =SPACE(1) end SET @pinyin =ISNULL(@pinyin +@paceword ,\'\')+ (CASE WHEN unicode(@word)between 19968 and 19968+20901 then (SELECT TOP 1 py FROM ( SELECT\'a\'AS py,N\'厑\'AS word UNION ALL SELECT \'ai\',N\'靉\' UNION ALL SELECT\'an\',N\'黯\' UNION ALL SELECT\'ang\',N\'醠\' UNION ALL SELECT\'ao\',N\'驁\' UNION ALL SELECT\'ba\',N\'欛\' UNION ALL SELECT\'bai\',N\'瓸\'--韛兡瓸 UNION ALL SELECT\'ban\',N\'瓣\' UNION ALL SELECT\'bang\',N\'鎊\' UNION ALL SELECT\'bao\',N\'鑤\' UNION ALL SELECT\'bei\',N\'鐾\' UNION ALL SELECT\'ben\',N\'輽\' UNION ALL SELECT\'beng\',N\'鏰\' UNION ALL SELECT\'bi\',N\'鼊\' UNION ALL SELECT\'bian\',N\'變\' UNION ALL SELECT\'biao\',N\'鰾\' UNION ALL SELECT\'bie\',N\'彆\' UNION ALL SELECT\'bin\',N\'鬢\' UNION ALL SELECT\'bing\',N\'靐\' UNION ALL SELECT\'bo\',N\'蔔\' UNION ALL SELECT\'bu\',N\'簿\' UNION ALL SELECT\'ca\',N\'囃\' UNION ALL SELECT\'cai\',N\'乲\'--縩乲 UNION ALL SELECT\'can\',N\'爘\' UNION ALL SELECT\'cang\',N\'賶\' UNION ALL SELECT\'cao\',N\'鼜\' UNION ALL SELECT\'ce\',N\'簎\' UNION ALL SELECT\'cen\',N\'笒\' UNION ALL SELECT\'ceng\',N\'乽\'--硛硳岾猠乽 UNION ALL SELECT\'cha\',N\'詫\' UNION ALL SELECT\'chai\',N\'囆\' UNION ALL SELECT\'chan\',N\'顫\' UNION ALL SELECT\'chang\',N\'韔\' UNION ALL SELECT\'chao\',N\'觘\' UNION ALL SELECT\'che\',N\'爡\' UNION ALL SELECT\'chen\',N\'讖\' UNION ALL SELECT\'cheng\',N\'秤\' UNION ALL SELECT\'chi\',N\'鷘\' UNION ALL SELECT\'chong\',N\'銃\' UNION ALL SELECT\'chou\',N\'殠\' UNION ALL SELECT\'chu\',N\'矗\' UNION ALL SELECT\'chuai\',N\'踹\' UNION ALL SELECT\'chuan\',N\'鶨\' UNION ALL SELECT\'chuang\',N\'愴\' UNION ALL SELECT\'chui\',N\'顀\' UNION ALL SELECT\'chun\',N\'蠢\' UNION ALL SELECT\'chuo\',N\'縒\' UNION ALL SELECT\'ci\',N\'嗭\'--賜嗭 UNION ALL SELECT\'cong\',N\'謥\' UNION ALL SELECT\'cou\',N\'輳\' UNION ALL SELECT\'cu\',N\'顣\' UNION ALL SELECT\'cuan\',N\'爨\' UNION ALL SELECT\'cui\',N\'臎\' UNION ALL SELECT\'cun\',N\'籿\' UNION ALL SELECT\'cuo\',N\'錯\' UNION ALL SELECT\'da\',N\'橽\' UNION ALL SELECT\'dai\',N\'靆\' UNION ALL SELECT\'dan\',N\'饏\' UNION ALL SELECT\'dang\',N\'闣\' UNION ALL SELECT\'dao\',N\'纛\' UNION ALL SELECT\'de\',N\'的\' UNION ALL SELECT\'den\',N\'扽\' UNION ALL SELECT\'deng\',N\'鐙\' UNION ALL SELECT\'di\',N\'螮\' UNION ALL SELECT\'dia\',N\'嗲\' UNION ALL SELECT\'dian\',N\'驔\' UNION ALL SELECT\'diao\',N\'鑃\' UNION ALL SELECT\'die\',N\'嚸\'--眰嚸 UNION ALL SELECT\'ding\',N\'顁\' UNION ALL SELECT\'diu\',N\'銩\' UNION ALL SELECT\'dong\',N\'霘\' UNION ALL SELECT\'dou\',N\'鬭\' UNION ALL SELECT\'du\',N\'蠹\' UNION ALL SELECT\'duan以上是关于创建公共配置表,并以全国区县代码维护为例的主要内容,如果未能解决你的问题,请参考以下文章