在SQL Server中設定列的約束只能是八位字元,前兩位是0,3 4為數字,第五位是下劃線,6 8位是字母

時間 2021-08-30 09:27:53

1樓:匿名使用者

substring('12345678',1,2)='00'--判斷前兩位是0

ascii(substring('12a45678',3,1)) between ascii('0') and ascii('9') --判斷第三位是數字

ascii(substring('12a45678',4,1)) between ascii('0') and ascii('9') --判斷第四位是數字

ascii(substring('12345678',5,1)) = ascii('_') --判斷第五位是下劃線

ascii(upper(substring('12345678',6,1))) between ascii('a') and ascii('z') --判斷第六位是字母

ascii(upper(substring('12345678',7,1))) between ascii('a') and ascii('z')--判斷第七位是字母

ascii(upper(substring('12345678',8,1))) between ascii('a') and ascii('z')--判斷第八位是字母

2樓:

00[0-9][0-9]_[a-z][a-z][a-z]

alter table test

add constraint ck_test check(name like '00[0-9][0-9]_[a-z][a-z][a-z]')

SQLserver在同表中,怎麼把一列中的某些欄位複製到另一列中的同欄位下

寒默憂傷 update set a select a from where id 1 where id 0 update set b select b from where id 1 where id 0 update set c select c from where id 1 where id ...

在SQL server中,用C語言,設定觸發器

只要在sql server中直接新增一個觸發器就可以了 如下 create trigger myty on 表名 for insert,update asif exists select 1 from inserted where inserted.數值 100 or inserted.數值 30 ...

在Excel中,A列有一列數字,在B列中判斷A列的數值除以1000後大於某個數返回特定值

你繞來繞去怎麼的?為何要除以1000操作,不能夠把範圍擴大1000嗎嗎?在b2單元格輸入公式 if a2 0,lookup a2,row 1 5 複製並下拉即可 或者公式 if a2 0,lookup a2, if a1 1000 2,5,if a1 1000 1.5,4,if a1 1000 1,...