sql server 我常用的语句
Posted 兴杰(stooges.com.my)
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql server 我常用的语句相关的知识,希望对你有一定的参考价值。
1. computed column
alter table tableName add columnName as (cast(aColumn as float) / bColumn * 100) persisted;
2. unique nullable
create unique nonclustered index[UniqueName] on [tableName]([columnNameA] asc) where ([columnNameA] is not null);
3. foreign key cascade delete
alter table [tableNameA] drop constraint [FKName]; alter table [tableNameA] with check add constraint [FKName] foreign key(foreignColumnName) references [tableNameB]([Id]) on delete cascade -- or on delete set null;
4. reset auto increment
dbcc checkident (‘tableName‘) --check current dbcc checkident (‘tableName‘, reseed, 0); --reset to 0 , next is 1
以上是关于sql server 我常用的语句的主要内容,如果未能解决你的问题,请参考以下文章