关于T-SQL
句柄类型优先级与表达式中numeric
使用的各种类型的方式,我完全是一棵树CASE
.你能用以下测试解释一下吗:
-- Consider the query:
SELECT
CASE
WHEN 1=1 THEN CAST(1.555 AS numeric(16,3))
ELSE CEILING((1+1) * CAST(1 AS Numeric(16,2)) * CAST(1 AS int))
END AS Test
-- This returns 2 (scale = 0)
-- Now, remove the CEILING function:
SELECT
CASE
WHEN 1=1 THEN CAST(1.555 AS numeric(16,3))
ELSE (1+1) * CAST(1 AS Numeric(16,2)) * CAST(1 AS int)
END AS Test
-- and it gives 1.56 (scale = 2)
-- Now replace (1+1) …
Run Code Online (Sandbox Code Playgroud) 为了隐藏DBCC SHRINKFILE
我试过的输出:
CREATE TABLE #Swallow(DbId int, Fileld int, CurrentSize int, MininumSize int, UsedPages int, EstimatedPages int)
INSERT INTO #Swallow EXEC('DBCC SHRINKFILE(''filename'', 0, TRUNCATEONLY)')
Run Code Online (Sandbox Code Playgroud)
但它返回以下错误:
无法在用户事务中执行shrinkfile操作.终止事务并重新发出该语句.
如何才能做到这一点?