Firstly, the SERVICE needs to be running >
Secondly, you need to allow communication (Allow Inbound and Allow Outbound tickboxes below) >
SELECT t.text , s.* FROM sys.dm_exec_query_stats s CROSS APPLY sys.dm_exec_sql_text(sql_handle) t WHERE t.text NOT like 'SELECT * FROM(SELECT coalesce(object_name(s2.objectid)%' ORDER BY execution_count DESC
SELECT * FROM(SELECT COALESCE(OBJECT_NAME(s2.objectid),'Ad-Hoc') AS ProcedureName,execution_count, (SELECT TOP 1 SUBSTRING(s2.TEXT,statement_start_offset / 2+1 , ( (CASE WHEN statement_end_offset = -1 THEN (LEN(CONVERT(NVARCHAR(MAX),s2.TEXT)) * 2) ELSE statement_end_offset END) - statement_start_offset) / 2+1)) AS sql_statement, last_execution_time FROM sys.dm_exec_query_stats AS s1 CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS s2 ) x WHERE sql_statement NOT like 'SELECT * FROM(SELECT coalesce(object_name(s2.objectid)%' ORDER BY execution_count DESC
select * from sys.indexes where object_id = object_id('production.transactionhistory')
select i.name, s.* from sys.dm_db_index_usage_stats s inner join sys.indexes i on s.object_id = i.object_id and s.index_id = i.index_id where database_id = DB_ID('adventureworks2008') and s.object_id = object_id('production.transactionhistory')
DECLARE @id BIGINT DECLARE tablecursor CURSOR FORWARD_ONLY FOR SELECT id FROM SCHEMA.table OPEN tablecursor FETCH NEXT FROM tablecursor INTO @id WHILE (1 = 1) BEGIN IF @@FETCH_STATUS <> 0 BREAK; PRINT @id --DO SOMETHING USEFUL HERE ! FETCH NEXT FROM tablecursor INTO @id END CLOSE tablecursor DEALLOCATE tablecursor
"The bottom line is that SQL Server uses a thread for each unique disk drive, NOT files. In SQL 2000, you can fool the system if the disk drives are volumes on the same physical disk. However in SQL 2005 the system checks to see if these are the same physical disk.http://www.sqlservercentral.com/blogs/steve_jones/archive/2009/10/13/sql-server-legend-data-files-and-threads.aspx
There are some caveats, but if you hear this rumor, dispel it. Let people know that multiple file groups (or files) only help if you have different physical I/O paths and drives."
USE TestDB; GO --- Step 8 : (Optional/Recommended) Create Index on Partitioned Table CREATE UNIQUE CLUSTERED INDEX IX_TestTable ON TestTable(ID) ON TestDB_PartitionScheme (ID); GO
CREATE TABLE [dbo].[WebActivity]( [Id] [bigint] IDENTITY(1,1) NOT NULL, [Url] [varchar] (255) NULL, [TrackingDateTime] [datetime2] (0) NOT NULL, [TrackingSeconds] AS DATEDIFF(SECOND,'20000101',TrackingDateTime) PERSISTED, [TrackingDay] AS DATEDIFF(DAY,'20000101',TrackingDateTime) PERSISTED) ON [PRIMARY] GO
CREATE TABLE [dbo].[WebActivity]( [Id] [bigint] IDENTITY(1,1) NOT NULL, [Url] [varchar] (255) NULL, [TrackingDateTime] [datetime2] (0) NOT NULL, [TrackingSeconds] AS CONVERT(INTEGER,DATEDIFF(SECOND,CONVERT(DATETIME2,'20000101',112),TrackingDateTime)) PERSISTED, [TrackingDay] AS CONVERT(SMALLINT,DATEDIFF(DAY,CONVERT(DATETIME2,'20000101',112),TrackingDateTime)) PERSISTED, ON PRIMARY GO
SELECT * FROM ::fn_dblog(NULL, NULL) WHERE operation = 'LOP_DELETE_SPLIT'ref ; http://killspid.blogspot.com/2006/07/using-fndblog.html
Select COUNT(1) AS NumberOfSplits, AllocUnitName , Context From fn_dblog(NULL,NULL) Where operation = 'LOP_DELETE_SPLIT' Group By AllocUnitName, Context Order by NumberOfSplits descref - Identifying Page Splits
ALTER TABLE REBUILD WITH(DATA COMPRESSION=PAGE,MAXDOP=8)
DECLARE @Counter INT DECLARE @CounterText VARCHAR(30) DECLARE @MaxCount INT DECLARE @Stepsize INT SELECT @Counter = 0 SELECT @MaxCount = 40000 SELECT @Stepsize = 1000 WHILE @Counter <= @MaxCount BEGIN SET @CounterText = CONVERT(VARCHAR(30),@Counter,23) RAISERROR (@CounterText, 10, 1) WITH NOWAIT -- do useful stuff here SELECT @Counter = @Counter + @Stepsize ENDand counting down....
DECLARE @Counter INT DECLARE @CounterText VARCHAR(30) DECLARE @MinCount INT DECLARE @Stepsize INT SELECT @Counter = 40000 SELECT @MinCount = 0 SELECT @Stepsize = 1000 WHILE @Counter >= @MinCount BEGIN SET @CounterText = CONVERT(VARCHAR(30),@Counter,23) RAISERROR (@CounterText, 10, 1) WITH NOWAIT -- do useful stuff here SELECT @Counter = @Counter - @Stepsize END