Showing posts with label current. Show all posts
Showing posts with label current. Show all posts

Monday, September 22, 2014

Script to get elapsed time from start of current day in SQL Server

How to get elapsed time in Seconds, Minutes, Hours from start of current day?


SELECT DATEDIFF(SECOND, 0, Cast(GETDATE() AS TIME)) -- In Seconds

SELECT DATEDIFF(MINUTE, 0, Cast(GETDATE() AS TIME)) -- In Minutes

SELECT DATEDIFF(HOUR, 0, Cast(GETDATE() AS TIME)) -- In Hours

Wednesday, September 12, 2012

Error[21355] SQL-DMO: The new DB file size must be larger than the current size

Error[21355] SQL-DMO: The new DB file size must be larger than the current size.

Reduce the initial size of mdf file in sql server.



-- get the file#s / names of all the db's files
USE pubs
EXEC sp_helpfile




--Then choose the file# or filename you want to shrink. For example, to shrink the primary file to 2GB:


DBCC SHRINKFILE ( 1, 20000)