假设我有10个表,我需要编写一个简单的LOG条目,说明每个表有多少条记录.
就像是
Declare @msg Varchar(MAX)
Set @msg = 'Process Succeeded; Table1 has xx record, Table2 has zz records, Table3 has ww records ...'
Insert INTO LOG (msg) VALUES (@msg)
Run Code Online (Sandbox Code Playgroud)
HAB*_*ABO 11
或者将其卷入:
declare @Summary as VarChar(256)
select @Summary =
'Foo: ' + Cast( ( select Count(42) from Foo ) as VarChar(10) ) +
', Bar: ' + Cast( ( select Count(42) from Bar) as VarChar(10) )
select @Summary
Run Code Online (Sandbox Code Playgroud)