Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. --Drop table if exists
  2. IF (OBJECT_ID('dbo.Test')) IS NOT NULL DROP TABLE dbo.Test;
  3.  
  4. --Create Table for Testing
  5. CREATE TABLE dbo.Test(Id INT IDENTITY(1,1) CONSTRAINT PK_Test PRIMARY KEY CLUSTERED, TextValue VARCHAR(20) NULL);
  6.  
  7. --Insert enough data so we have more than 8Mb (the threshold at which sampling kicks in)
  8. INSERT INTO dbo.Test(TextValue)
  9. SELECT TOP 1000000 'blahblahblah'
  10. FROM sys.objects a, sys.objects b, sys.objects c, sys.objects d;
  11.  
  12. --Create Index on TextValue
  13. CREATE INDEX IX_Test_TextValue ON dbo.Test(TextValue);
  14.  
  15. --Update Statistics without specifying how many rows to sample
  16. UPDATE STATISTICS dbo.Test IX_Test_TextValue;
  17.  
  18. --View the Statistics
  19. DBCC SHOW_STATISTICS('dbo.Test', IX_Test_TextValue) WITH STAT_HEADER;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement