SQL Server Reorganizing and Rebuilding Indexes

"The SQL Server Database Engine automatically maintains indexes whenever insert, update, or delete operations are made to the underlying data. Over time these modifications can cause the information in the index to become scattered in the database (fragmented). Fragmentation exists when indexes have pages in which the logical ordering, based on the key value, does not match the physical ordering inside the data file. Heavily fragmented indexes can degrade query performance and cause your application to respond slowly."

"You can remedy index fragmentation by either reorganizing an index or by rebuilding an index. For partitioned indexes built on a partition scheme, you can use either of these methods on a complete index or on a single partition of an index."

http://technet.microsoft.com/en-us/library/ms187874.aspx

http://technet.microsoft.com/en-us/library/ms189858.aspx

http://technet.microsoft.com/en-us/library/ms188388.aspx

SQL Server Data Type Mappings (ADO.NET)

"SQL Server and the .NET Framework are based on different type systems. For example, the .NET Framework Decimal structure has a maximum scale of 28, whereas the SQL Server decimal and numeric data types have a maximum scale of 38. To maintain data integrity when reading and writing data, the SqlDataReader exposes SQL Server–specific typed accessor methods that return objects of System.Data.SqlTypes as well as accessor methods that return .NET Framework types. Both SQL Server types and .NET Framework types are also represented by enumerations in the DbType and SqlDbType classes, which you can use when specifying SqlParameter data types."

The following article shows the inferred .NET Framework type, the DbType and SqlDbType enumerations, and the accessor methods for the SqlDataReader.

http://msdn.microsoft.com/en-us/library/cc716729.aspx

Response.Close()

I found myself researching Response.Close() recently because of an issue with streaming attachments back to the browser.

This code had always worked, but in one particular environment we found that not all of the data was making it through the BinaryWrite:

Response.Buffer = False
Response.ClearHeaders()
Response.ContentType = File.FileType
Response.AddHeader("Content-Disposition", "attachment; filename=" & File.FileName)
Response.BinaryWrite(File.FileData)
Response.Close()
Response.End()

Removing the Response.Close() fixed it. The cause was most likely the load balancer in that environment, which the other environments did not have.

Leaving Response.Close() out works in every situation I have run into, so I standardized on not using it unless there is a specific reason to.