Quantcast
Channel: CodeSection,代码区,SQL Server(mssql)数据库 技术分享 - CodeSec
Viewing all articles
Browse latest Browse all 3160

一些有用的SQL语句 sql SQLServer SQL语句 清空数据表

$
0
0

一些有用的SQL语句

1.清空一张数据表

truncate table word(慎用)

2.找出所有带有单引号的单词(单引号用两个单引号转义)

select * from Word where soundMarkUs like '%''%'

3.调用replace函数将双引号替换成单引号

update Word set soundMarkUs=REPLACE(soundMarkUs,'"','''') where soundMarkUs like'%"%'

4.备份一张数据表

select * into Course_bak from Course

5.显示一张表中去重之后的数据

select distinct spelling from Word

6.查询一张表中重复的数据

select * from Word where spelling in (select spelling from Word group by spelling having count(1) >= 2)

7.通过某个字段按字母顺序排序:ASC-升序(A-Z);DESC-降序(Z-A)

select * from Word order by spelling asc

8.把字段数据类型由varchar改为nvarchar可以解决一些乱码的问题


Viewing all articles
Browse latest Browse all 3160

Trending Articles