Advertisement
anchormodeling

Overflow partition and NULL values

Dec 8th, 2011
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.73 KB | None | 0 0
  1. drop table Test_Partitioning;
  2. drop partition scheme Test_Partition_Scheme;
  3. drop partition function Test_Partition_Function;
  4.  
  5. create partition function Test_Partition_Function (datetime)
  6. as range left for values (null);
  7.  
  8. create partition scheme Test_Partition_Scheme
  9. as partition Test_Partition_Function
  10. all to ([PRIMARY]);
  11.  
  12. create table Test_Partitioning (
  13.     id int not null,
  14.     stamp datetime null
  15. ) ON Test_Partition_Scheme (stamp);
  16.  
  17. insert into Test_Partitioning values (1, '2001-01-01');
  18. insert into Test_Partitioning values (2, null);
  19.  
  20. SELECT
  21.     $partition.Test_Partition_Function(t.stamp) AS [Partition Number],
  22.     t.*
  23. FROM
  24.     Test_Partitioning t
  25.  
  26. /*
  27. Partition Number    id  stamp
  28. 1           2   NULL
  29. 2           1   2001-01-01 00:00:00.000
  30. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement