You can do it like this:exec tempdb..sp_executesql N'print ''Database = ''+db_name()dbcc shrinkfile (tempdev, 1000)dbcc shrinkfile (templog, 1000)select size,name from sysfiles'
Results:Database = tempdbCannot shrink file '1' in database 'tempdb' to 128000 pages as it only contains 12160 pages.DBCC execution completed. If DBCC printed error messages, contact your system administrator.Cannot shrink file '2' in database 'tempdb' to 128000 pages as it only contains 96 pages.DBCC execution completed. If DBCC printed error messages, contact your system administrator.size name ----------- ------------------------------------12160 tempdev 96 templog (2 row(s) affected)
CODO ERGO SUM