① sql语句查询姓名包含阿拉伯数字、英文字母等不符合规范的文字怎么写
select * from pop where datediff(day,birth_date,getdate()) >= 7*365.25 and name in ('未取名'、%[0-9]%、%[a-z]%,%[A-Z]%) or len(name)<2 len(name)<2这里你要试验一下,看看你使用的数据库对2个汉字返回什么值,有的是4,有的是2
② mssql2005 ,函数 阿拉伯数字 转成 中文
我已经测试过了 整数有效
alter function fn_numberconvertchinase(@number int)
returns varchar(20)
as
begin
declare @res varchar(20)
declare @str varchar(10)
declare @char char(1)
set @res = ''
set @str = cast(@number as varchar)
set @char = substring(@str,1,1)
select @res = (case (cast(@char as int))
when 1 then '一'
when 2 then '二'
when 3 then '三'
when 4 then '四'
when 5 then '五'
when 6 then '六'
when 7 then '七'
when 8 then '八'
when 9 then '九'
else '零' end
)
if(len(@str) > 1)
begin
select @res = @res + (case len(@str)
when 2 then '十'
when 3 then '百'
when 4 then '千'
when 5 then '万'
when 6 then '十'
when 7 then '百'
else '' end)
set @res = @res + dbo.fn_numberconvertchinase(cast(substring(@str,2,len(@str)-1) as int))
end
return @res
end
select dbo.fn_numberconvertchinase(123)
------------
一百二十三
③ 把中文数字转化成阿拉伯数字有什么好的方法用sql 语句。
你说的中文数字应该是字符一、二、三……吧?这是字符判断转为数字,可以用DECODE和CASE WHEN 来解决。如:
select decode(table_column,'一',1,'二',2,'三',3,'四',4,'五',5,'六',6,'七',7,'八',8,'九',9,'零',0,'') from (select '六' as table_column from al) your_table;
select case when table_column = '一' then 1
when table_column = '二' then 2
when table_column = '三' then 3
when table_column = '四' then 4
when table_column = '五' then 5
when table_column = '六' then 6
when table_column = '七' then 7
when table_column = '八' then 8
when table_column = '九' then 9
when table_column = '零' then 0
else null end
from (select '六' as table_column from al) your_table;
④ sql中怎么样把阿拉伯数字的日期转化成中文数字的日期 比如:2009 二〇〇九
可以写个存储过程来转换
⑤ sql语句中怎样将字符类型转换成数字类型
先检查金额列的数据是否都符合小数规范,转为数字格式只有是数字的字符串才能转,如000012转为12,.55转为0.55,若是个英文符号等字符转了就报无效数字类型的错。
⑥ 在sql语句中阿拉伯数字是字符型吗
原则上来说:
如果用 单引号引起来的话,就是字符型。
如果不用单引号引起来的话,就是数字型。
在insert语句或者 赋值等语句中,可能会出现自动类型转换的情况。
⑦ 【求大能解答】sql语句获取数据问题
我没有SQL Server数据库,你不能测试你可以试试下面的写法:SELECT SUM(t3.fieldName)从(选择表名前3字段名)T3应该的。
⑧ sql中如何将阿拉伯数字转为汉字
Create Procere AtoC
@ChangeMoney Money
as
Set Nocount ON
Declare @String1 char(20)
Declare @String2 char(30)
Declare @String4 Varchar(100)
Declare @String3 Varchar(100) –从原A值中取出的值
Declare @i int –循环变量
Declare @J Int –A的值乘以100的字符串长度
Declare @Ch1 Varchar(100) –数字的汉语读法
Declare @Ch2 Varchar(100) –数字位的汉字读法
Declare @Zero Int –用来计算连续有几个零
Declare @ReturnValue VarChar(100)
Select @ReturnValue = ”
Select @String1 = ‘零壹贰叁肆伍陆柒捌玖’
Select @String2 = ‘万仟佰拾亿仟佰拾万仟佰拾元角分’
Select @String4 = Cast(@ChangeMoney*100 as int)
select @J=len(cast((@ChangeMoney*100) as int))
Select @String2=Right(@String2,@J)
Select @i = 1
while @i<= @j Begin
Select @String3 = Substring(@String4,@i,1)
if @String3<>‘0′ Begin
Select @Ch1 = Substring(@String1, Cast(@String3 as Int) + 1, 1)
Select @Ch2 = Substring(@String2, @i, 1)
Select @Zero = 0 –表示本位不为零
end
else Begin
If (@Zero = 0) Or (@i = @J – 9) Or (@i = @J – 5) Or (@i = @J – 1)
Select @Ch1 = ‘零’
Else
Select @Ch1 = ”
Select @Zero = @Zero + 1 –表示本位为0
–如果转换的数值需要扩大,那么需改动以下表达式 I 的值。
Select Ch2 = ”
If @i = @J – 10 Begin
Select @Ch2 = ‘亿’
Select @Zero = 0
end
If @i = @J – 6 Begin
Select @Ch2 = ‘万’
Select @Zero = 0
end
if @i = @J – 2 Begin
Select @Ch2 = ‘元’
Select @Zero = 0
end
If @i = @J
Select @Ch2 = ‘整’
end
Select @ReturnValue = @ReturnValue + @Ch1 + @Ch2
select @i = @i+1
end
–最后将多余的零去掉
If CharIndex(‘仟仟’,@ReturnValue) <> 0
Select @ReturnValue = Replace(@ReturnValue, ‘仟仟’, ‘仟’)
If CharIndex(‘佰佰’,@ReturnValue) <> 0
Select @ReturnValue = Replace(@ReturnValue, ‘佰佰’, ‘佰’)
If CharIndex(‘零元’,@ReturnValue) <> 0
Select @ReturnValue = Replace(@ReturnValue, ‘零元’, ‘元’)
If CharIndex(‘零万’,@ReturnValue) <> 0
Select @ReturnValue = Replace(@ReturnValue, ‘零万’, ‘万’)
If CharIndex(‘零亿’,@ReturnValue) <> 0
Select @ReturnValue = Replace(@ReturnValue, ‘零亿’, ‘亿’)
If CharIndex(‘零整’,@ReturnValue) <> 0
Select @ReturnValue = Replace(@ReturnValue, ‘零整’, ‘整’)
If CharIndex(‘零佰’,@ReturnValue) <> 0
Select @ReturnValue = Replace(@ReturnValue, ‘零佰’, ‘零’)
If CharIndex(‘零仟’,@ReturnValue) <> 0
Select @ReturnValue = Replace(@ReturnValue, ‘零仟’, ‘零’)
If CharIndex(‘元元’,@ReturnValue) <> 0
Select @ReturnValue = Replace(@ReturnValue, ‘元元’, ‘元’)
Select @ReturnValue
GO
⑨ 用sql语句建表和设置约束
val c = a.par.aggregate(5)(_+_,_+_)
def apply(i: Int): T
同下面代码,取出指定索引处的元素
val first = numbers(0) // 读取第一个元素
⑩ SQL语句提取字符串中数字
问题确认:你是要提取以下划线(_)为分隔符的字串的第三个子字串。
答案:
select
dbo.getpara('14层_303盘区_5307工作面',3,'_')
条件:先要再数据库中加入这个自定议函数。这里免费奉献给你一个有用的函数,用于按指定分隔符提取字串。
create
function
getpara
(@sql
nvarchar(3000),--要分割的原字串。
@sn
int,
--要取第几个
@deli
varchar(1))--分隔符
returns
varchar(1000)--返回值
as
begin
declare
@first
int,@last
int,@result
varchar(1000),@sn0
int
select
@sn0=0,@first=0,@last=1,@sql=@sql+replicate(@deli,5)
while
@sn0!=@sn
begin
select
@sn0=@sn0+1,@first=@last,@last=charindex(@deli,@sql,@last)+1
end
set
@result=substring(@sql,@first,@last-@first-1)
return
(
@result
)
end
go