MSSQL SERVER 2008 New Features for Developers

来源:互联网 发布:jdk java se v1.8 编辑:程序博客网 时间:2024/06/05 11:47
Data Types
MSSQL Server 2k8 contains some new datatypes. These are DATE, TIME and some CLR based types.
DATE type stores only date without time. And TIME type stores only time withouth date. J It was alittle hard work to use date functions for time actions. I think these types can help us.
There is an another type for date. DATETIME2, is similir to standart DATETIME  but allows for greater precision. The range of the type is Jan 1 year 1 to 12/31/9999. So it wont be a problem to store DateTime.MinValue with this type. Also the clock is 24 hour cycle so 8 pm can be stored as the military time 20:00.
SELECT CAST('2007-10-20 20:30:05.1234567' as DATETIME2)
Results:  2007-10-20 20:30:05.1234567
SELECT CAST('2007-10-20 20:30:05.1234567' as DATETIME2(4))
Results:  2007-10-20 20:30:05.1235
 
Values that need to be time zone aware can now be stored in Mssql Server 2k8 with the DATETIMEOFFSET.
SELECT CAST('2007-10-20 20:30:05.1234567 +5:0' as DATETIMEOFFSET)
Results:  2007-10-20 20:30:05.1234567 +05:00
Demos :
CAST('2007-10-20 20:30:05.1234567 +5:0' as DATE) = 2007-10-20
CAST('2007-10-20 20:30:05.1234567 +5:0' as TIME(7)) = 20:30:05.1234567
CAST('2007-10-20 20:30:05.123' as SMALLDATETIME) = 2007-10-20 20:30:00
CAST('2007-10-20 20:30:05.123' as DATETIME) = 2007-10-20 20:30:05.123
CAST('2007-10-20 20:30:05.1234567 +5:0' as DATETIME2(7)) = 2007-10-20 20:30:05.1234567
CAST('2007-10-20 20:30:05.1234567 +5:0' as DATETIMEOFFSET(7)) = 2007-10-20 20:30:05.1234567 +05:00
FILESTREAM Data type
We always think where to store our BLOB files, in the FileSystem or in to the DB. It is hard desicion between them. You can store your files in to the db with filesystem support. For more details i think you should read this post : http://blogs.msdn.com/manisblog/archive/2007/10/21/filestream-data-type-sql-server-2008.aspx
 
HIERARCHYID
When do we need to have parent – child relationship we create a foreignKey to the table itself. So HierarchyID type will make it easy and it has some helpful funtions.Details on here :http://blogs.msdn.com/manisblog/archive/2007/08/17/sql-server-2008-hierarchyid.aspx
http://blogs.msdn.com/manisblog/archive/2007/08/28/sql-server-2008-hierarchyid-part-ii.aspx
 
GEOGRAPHY
Spatial data types means businesses and products can now handle complex location data and apply it against other business or technical specific data without requiring expense GIS systems.
Now we are able to insert many records to be inserted using VALUES clause of the INSERT statement.
INSERT INTO SalesFeed(CustomerID, Product, SaleAmount)VALUES(1,'PoolTable', 1000),(2,'BigScreen', 955),(3,'Computer', 590),(4,'BigScreen', 880),(5,'Computer', 700)
There is a new Linq2Sql provider for sql server 2008.
There are some comprassion features, some more new T-SQL enchantments. I wantted to list these features that i like and I want to notice that Microsoft will stop supporting ms sql server 2000 in April 08’.
I hope it helps..
原文地址:http://www.dogaoztuzun.com/post/MSSQL-SERVER-2008-New-Features-for-Developers.aspx