一些有用的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可以解決一些亂碼的問題
看文倉www.kanwencang.com網友整理上傳,為您提供最全的知識大全,期待您的分享,轉載請注明出處。
歡迎轉載:http://www.kanwencang.com/bangong/20170215/102045.html
文章列表