Wandenkolk さんのプロフィールWandenkolk Netoフォトブログつながりその他 ツール ヘルプ
7月30日

Grouping Sets

This is a feature on SQL 2008, it is meant to allow multiple groupings within the same statement.

It could make this

 

SELECT customer, NULL as year, SUM(sales) FROM T GROUP BY customer

UNION ALL

SELECT NULL as customer, year, SUM(sales) FROM T GROUP BY year

 

into this

SELECT customer, year, SUM(sales)
FROM T
GROUP BY GROUPING SETS ((customer), (year))

 

(samples from MSDN website)

Sparse Property and Sparse columns

This could be interesting to save space in case we have a lot of records that could be filled or null.

 

Take a look at the books online excerpt

Sparse columns are ordinary columns that have an optimized storage for null values. Sparse columns reduce the space requirements for null values at the cost of more overhead to retrieve nonnull values. Consider using sparse columns when the space saved is at least 20 percent to 40 percent. Sparse columns and column sets are defined by using the CREATE TABLE or ALTER TABLE statements.

Sparse columns can be used with column sets and filtered indexes:

  • Column sets
    INSERT, UPDATE, and DELETE statements can reference the sparse columns by name. However, you can also view and work with all the sparse columns of a table that are combined into a single XML column. This column is called a column set. For more information about column sets, see Using Column Sets.
  • Filtered indexes
    Because sparse columns have many null-valued rows, they are especially appropriate for filtered indexes. A filtered index on a sparse column can index only the rows that have populated values. This creates a smaller and more efficient index. For more information, see Filtered Index Design Guidelines.

Sparse columns and filtered indexes enable applications, such as Windows SharePoint Services, to efficiently store and access a large number of user-defined properties by using SQL Server 2008.

if you have the books online installed, take a look at the full article.

have fun

ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.en/s10de_1devconc/html/ea7ddb87-f50b-46b6-9f5a-acab222a2ede.htm

 

 

USE AdventureWorks
GO

CREATE TABLE DocumentStore
(DocID int PRIMARY KEY,
Title varchar(200) NOT NULL,
ProductionSpecification varchar(20) SPARSE NULL,
ProductionLocation smallint SPARSE NULL,
MarketingSurveyGroup varchar(20) SPARSE NULL ) ;
GO

INSERT DocumentStore(DocID, Title, ProductionSpecification, ProductionLocation)
VALUES (1, 'Tire Spec 1', 'AXZZ217', 27)
GO

INSERT DocumentStore(DocID, Title, MarketingSurveyGroup)
VALUES (2, 'Survey 2142', 'Men 25 - 35')
GO
7月27日

Back from Vacations!

Opa!

Estou de volta das minhas férias! Sorry pelo silencio no Blog no ultimo semestre, houve uma combinação entre turbulências e bastante cansaço devido a 3 anos sem férias, e além disso como eu estava ministrando cursos boa parte das noites, isso estava consumindo boa parte do meu dia!

Mas esse semestre, com todo gás vou linkar no Blog coisas interessantes sobre SQL Server.  :)

ps. Como eu ja disse antes, normalmente eu escrevo em ingles por dois motivos, pra melhorar o meu ingles e ajudar mais gente. Até os indianos q trabaham comigo ja consultaram meu blog antigo. hehehe

Se nao tiver entendido algo, por favor pergunte nos comentários.

Hugs

Hi.

I´m back from my vacations. Sorry for the silence on last semester, there was a combination between turbulences and i was very tired due to 3 years without a single day off, besides i was teaching classes in the evenings so my day got shorten.

But this semester everythiung will be different, i hope i could write interesting stuff about sql server. Enjoy.

 

Hugs