SQL操作應用——1=1,1=2的使用,在SQL語句組合時用的較多
提問人:ylm發(fā)布時間:2020-09-30
、1=1,1=2的使用,在SQL語句組合時用的較多
“where 1=1” 是表示選擇全部 “where 1=2”全部不選,
如:
if @strWhere !=''
begin
set @strSQL = 'select count(*) as Total from [' + @tblName + '] where ' + @strWhere
end
else
begin
set @strSQL = 'select count(*) as Total from [' + @tblName + ']'
end
我們可以直接寫成
錯誤!未找到目錄項。
set @strSQL = 'select count(*) as Total from [' + @tblName + '] where 1=1 安定 '+ @strWhere 2、收縮數據庫
--重建索引
DBCC REINDEX
DBCC INDEXDEFRAG
--收縮數據和日志
DBCC SHRINKDB
DBCC SHRINKFILE
繼續(xù)查找其他問題的答案?
相關視頻回答
點擊加載更多評論>>