SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE()) - 1 - FLOOR(RAND(CAST(NEWID() AS binary(4))) * 365.25 * 10), 0)
Number 10 is the year range, for example, if you want dates from recent to 10 years before, select 10.
Friday, December 24, 2010
Wednesday, November 24, 2010
How to find number of temp tables currently created in database
use tempdb
go
select * from sys.tables
go
select * from sys.tables
Monday, November 15, 2010
find last word in string
SELECT RIGHT(Address1,COALESCE(NULLIF(CHARINDEX(' ', REVERSE(Address1)) - 1,-1),LEN(Address1)))
Wednesday, October 27, 2010
Logfile Space Usage on Server
If you want to see how much log file space is free for each database on the server, use the following
DBCC sqlperf(logspace)
Friday, October 15, 2010
Enable xp_cmdshell
sp_configure 'show advanced options',1
reconfigure
sp_configure 'xp_cmdshell',1
reconfigure
reconfigure
sp_configure 'xp_cmdshell',1
reconfigure
Friday, September 3, 2010
HOW TO FIND THE LSN OF LAST TRANSACTION LOG SUCCESSFULLY RESTORED
SELECT top 5 *
FROM msdb.dbo.backupset
WHERE database_name = 'db_name'
ORDER BY backup_set_id desc
FROM msdb.dbo.backupset
WHERE database_name = 'db_name'
ORDER BY backup_set_id desc
Subscribe to:
Comments (Atom)