Use temp table variables instead of temp tables for certain applications
Temp tables are your friend, but there are other options. One of those is using a local TABLE variable table in your query.…
Read MoreAll things SQL Server
Temp tables are your friend, but there are other options. One of those is using a local TABLE variable table in your query.…
Read More
1 2 3 4 |
EXEC sys.sp_check_log_shipping_monitor_alert SELECT secondary_database, last_restored_date FROM msdb.dbo.log_shipping_secondary_databases |
First check the last file copied and restored to the secondary. Run the following queries on the secondary node. The following query…
Read More
1 2 3 4 5 6 7 8 9 |
SELECT sqltext.TEXT, req.session_id AS 'SPID', req.status AS 'Status', req.command AS 'Command', req.cpu_time AS 'CPU Time', req.total_elapsed_time/1000 AS 'Total Elapsed Time in Seconds' FROM sys.dm_exec_requests req CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext ORDER BY [CPU Time] DESC |
Views – 2238
Read More
1 2 3 4 5 6 7 8 9 10 |
SELECT name, DATABASEPROPERTYEX(name, 'Recovery') AS [recovery], DATABASEPROPERTYEX(name, 'IsAutoShrink') AS [auto-shrink], CASE WHEN primary_database IS NULL THEN 'no' ELSE 'yes' END AS [log-shipped], DATABASEPROPERTYEX(name, 'IsInStandBy') AS [stand-by], DATABASEPROPERTYEX(name, 'Status') AS [status] FROM master.dbo.sysdatabases sdb LEFT JOIN msdb.dbo.log_shipping_primary_databases lspd ON lspd.primary_database = sdb.name ORDER BY 1 |
Views – 2198
Read MoreHere is a short script to quickly shrink your log file if you DO NOT NEED to ever recover the database before the…
Read MoreThe implementation & syntax feels like an afterthought, like the engineers of SQL Server made something self-consistent, and then the market research wing…
Read MoreIf the disk drive that receives the log-shipping transaction files (*.trn) fills up, it will cause the log shipping chain to break for…
Read MoreYou can run the following SQL script to ensure email alerts are configured for the LSCopy and LSRestore jobs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
-- Get the job_id values and stick them into a cursor: DECLARE @jobID UNIQUEIDENTIFIER DECLARE cur CURSOR LOCAL FOR SELECT [job_id|job_id] FROM [msdb|msdb].[dbo|dbo].[sysjobs|sysjobs] WHERE [name|name] LIKE 'LSCopy_%' OR [name|name] LIKE 'LSRestore_%' -- Loop through the cursor: OPEN cur FETCH NEXT FROM cur INTO @jobID WHILE @ @FETCH_STATUS = 0 BEGIN -- Call sp_update_job for each ID. Set email level to 2 -- (alert on fail) and the operator name: EXEC [msdb|msdb].[dbo|dbo].sp_update_job @job_id=@jobID, @notify_level_email=2, @notify_email_operator_name=N'DBA-EmailGroup' FETCH NEXT FROM cur INTO @jobID END CLOSE cur DEALLOCATE cur |
Views – 2608
Read Morefrom Pinal Dave’s article here: http://blog.sqlauthority.com/
1 2 3 4 5 6 7 8 9 10 11 12 13 |
SELECT * FROM Employee WHERE FirstName LIKE 'A%' OR FirstName LIKE 'B%' OR FirstName LIKE 'C%' OR FirstName LIKE 'D%' OR FirstName LIKE 'E%' OR FirstName LIKE 'F%' OR FirstName LIKE 'G%' OR FirstName LIKE 'H%' OR FirstName LIKE 'I%' OR FirstName LIKE 'J%' OR FirstName LIKE 'K%' |
The previous query does find FirstName values beginning with the letters ‘A’ thru ‘K’. However, when…
Read MoreHere is an awesome extentions of the sp_who and sp_who2 (undocumented) sprocs DBA’s use to see slow running queries etc. Download link for…
Read More