tsql – 有没有办法在t-sql中的print语句后停止额外的新行?
发布时间:2020-12-12 06:26:29 所属栏目:MsSql教程 来源:网络整理
导读:这是一个小问题,但对我来说真是太痛苦了.通常,我会在其中编写包含多个查询的存储过程.为了使调试更容易,我这样写: print 'Some notes about query 1'select * from someTableprint 'some notes about query 2'update sometable set column = null 然后我得到
这是一个小问题,但对我来说真是太痛苦了.通常,我会在其中编写包含多个查询的存储过程.为了使调试更容易,我这样写:
print 'Some notes about query 1' select * from someTable print 'some notes about query 2' update sometable set column = null 然后我得到这样的结果: Some notes about query 1 (8 row(s) affected) Some notes about query 2 (8 row(s) affected) 它们的空间本身使它难以阅读.我希望结果看起来像这样: Some notes about query 1 (8 row(s) affected) Some notes about query 2 (8 row(s) affected) 我知道它很小,但它让我很烦.有人有什么想法? 解决方法汇总你得到的答案:--Set up test data DECLARE @someTable AS TABLE(id int identity,somevalue int) INSERT INTO @someTable (somevalue) VALUES (1) INSERT INTO @someTable (somevalue) VALUES (2) INSERT INTO @someTable (somevalue) VALUES (3) INSERT INTO @someTable (somevalue) VALUES (4) INSERT INTO @someTable (somevalue) VALUES (5) INSERT INTO @someTable (somevalue) VALUES (6) INSERT INTO @someTable (somevalue) VALUES (7) INSERT INTO @someTable (somevalue) VALUES (8) --Here's the method. SET NOCOUNT ON --As kd7 said this will get rid of spaces. Along with the rowcount. print 'Some notes about query 1' select * from @someTable print '(' + CONVERT(varchar,@@rowcount) +' row(s) affected)'--This adds the row count back in print '' --Formatting row to add the space you require. print 'Some notes about query 2' update @sometable set somevalue = null print '(' + CONVERT(varchar,@@rowcount) +' row(s) affected)' (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |