/*
ASP.NET 2.0 Unleashed (Unleashed) (Hardcover)
by Stephen Walther
# Publisher: Sams; Bk&CD-Rom edition (June 6, 2006)
# Language: English
# ISBN: 0672328232
*/
<%@ Page Language="C#" %>
MultiView Tabs
Trovato qui.
/*
ASP.NET 2.0 Unleashed (Unleashed) (Hardcover)
by Stephen Walther
# Publisher: Sams; Bk&CD-Rom edition (June 6, 2006)
# Language: English
# ISBN: 0672328232
*/
<%@ Page Language="C#" %>
MultiView Tabs
USE MASTER;
GO
IF DATABASEPROPERTYEX ('DBMaint2008', 'Version') > 0
DROP DATABASE DBMaint2008;
CREATE DATABASE DBMaint2008;
GO
USE DBMaint2008;
GO
SET NOCOUNT ON;
GO
-- Create the 10MB filler table at the 'front' of the data file
CREATE TABLE FillerTable (c1 INT IDENTITY, c2 CHAR (8000) DEFAULT 'filler');
GO
-- Fill up the filler table
INSERT INTO FillerTable DEFAULT VALUES;
GO 1280
-- Create the production table, which will be 'after' the filler table in the data file
CREATE TABLE ProdTable (c1 INT IDENTITY, c2 CHAR (8000) DEFAULT 'production');
CREATE CLUSTERED INDEX prod_cl ON ProdTable (c1);
GO
INSERT INTO ProdTable DEFAULT VALUES;
GO 1280
-- check the fragmentation of the production table
SELECT [avg_fragmentation_in_percent] FROM sys.dm_db_index_physical_stats (
DB_ID ('DBMaint2008'), OBJECT_ID ('ProdTable'), 1, NULL, 'LIMITED');
GO
-- drop the filler table, creating 10MB of free space at the 'front' of the data file
DROP TABLE FillerTable;
GO
-- shrink the database
DBCC SHRINKDATABASE (DBMaint2008);
GO
-- check the index fragmentation again
SELECT [avg_fragmentation_in_percent] FROM sys.dm_db_index_physical_stats (
DB_ID ('DBMaint2008'), OBJECT_ID ('ProdTable'), 1, NULL, 'LIMITED');
GO
avg_fragmentation_in_percent
----------------------------
0.390625
DbId FileId CurrentSize MinimumSize UsedPages EstimatedPages
------ ----------- ----------- ----------- ----------- --------------
6 1 1456 152 1448 1440
6 2 63 63 56 56
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
avg_fragmentation_in_percent
----------------------------
99.296875Look at the output from the script! The logical fragmentation of the clustered index before the shrink is a near-perfect 0.4%. After the shrink, it's almost 100%. The shrink operation *completely* fragmented the index, removing any chance of efficient range scans on it by ensuring the all range-scan readahead I/Os will be single-page I/Os.CREATE INDEX ... WITH (DROP_EXISTING) ON filegroup syntax, to move the tables and remove fragmentation from them at the same timeUSE TempDb GO -- Create a Table CREATE TABLE Employee( EmployeeID INT PRIMARY KEY, Name NVARCHAR(50), ManagerID INT ) GO -- Insert Sample Data INSERT INTO Employee SELECT 1, 'Mike', 3 UNION ALL SELECT 2, 'David', 3 UNION ALL SELECT 3, 'Roger', NULL UNION ALL SELECT 4, 'Marry',2 UNION ALL SELECT 5, 'Joseph',2 UNION ALL SELECT 7, 'Ben',2 GO -- Check the data SELECT * FROM Employee GO
-- Inner Join SELECT e1.Name EmployeeName, e2.name AS ManagerName FROM Employee e1 INNER JOIN Employee e2 ON e1.ManagerID = e2.EmployeeID GO
-- Outer Join SELECT e1.Name EmployeeName, ISNULL(e2.name, 'Top Manager') AS ManagerName FROM Employee e1 LEFT JOIN Employee e2 ON e1.ManagerID = e2.EmployeeID GO
Protected Sub gridDocs_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gridDocs.RowDataBound
With e.Row
If .RowType = DataControlRowType.DataRow Then
Dim s As String = "return confirm('Eliminare il documento \'"
s &= DataBinder.Eval(.DataItem, f1.Descrizione.ToString).ToString & "\'?');"
Dim btn As Button = CType(.FindControl("cmdDelete"), Button)
btn.OnClientClick = s
End If
End With
End Sub