6

I would like to know how I would go about of creating my table or choosing an insert that make sure that I do not get duplicate values.

create table test.dbo.test
product, 
time,
primary key(product, time)
go

When using Clustered ColumnStore I can not have any unique constraints to know that the data that has been inserted is unique. Is there another way to check this?

Jithin Shaji
  • 5,073
  • 5
  • 21
  • 45
eleijonmarck
  • 3,374
  • 4
  • 18
  • 24
  • Since you have a primary key in place, wouldn't sql throw an error if you tried to insert a duplicate key value? – nire Sep 01 '14 at 10:24
  • 3
    You can't have a primary key on a clustered columnstore index. – Jonathan Allen Sep 01 '14 at 10:31
  • How about using this info from msdn to create an index: [link]http://msdn.microsoft.com/en-us/library/dn589807.aspx – nire Sep 01 '14 at 10:38

1 Answers1

4

Here is a work-around that uses materialized views.

http://sqlwithmanoj.com/2014/07/24/maintaining-uniqueness-with-clustered-columnstore-index-sql-server-2014/

Jonathan Allen
  • 63,625
  • 65
  • 234
  • 426