當前位置:首頁 » 編程語言 » sql語句阿拉伯數字
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

sql語句阿拉伯數字

發布時間: 2022-07-27 06:42:14

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