title: Find Partition Schema Definitions in SQL Server Database
body: <p>I have access to a database and I need to know the Partition Scheme definitions in the database. i.e. I need to know the partition scheme name, which Partition function is it using, what file groups are the partitions assigned, etc... </p>
  
  <p>For example someone creates a partition scheme as so (taken from msdn):</p>
  
  <pre><code>CREATE PARTITION SCHEME myRangePS1
  AS PARTITION myRangePF1
  TO (test1fg, test2fg, test3fg, test4fg);
  </code></pre>
  
  <p>Then I want
  the name: myRangePS1,
  the function: myRangePF1, 
  and the partitions: (test1fg, test2fg, test3fg, test4fg),
  Whether it is partition ALL or not</p>
  
  <p>How would I go about this using SQL statements only? 
  I can query the names and some data about partitions by using the system view sys.partition_scheme, but it is not enough.</p>
  
  <p>The below shows a similar solution on finding the definition of Partition functions:
  <a href="http://social.msdn.microsoft.com/forums/sqlserver/en-US/d0ce92e3-bf48-455d-bd89-c334654d7e97/how-to-find-partition-function-text-applied-to-a-table" rel="noreferrer">http://social.msdn.microsoft.com/forums/sqlserver/en-US/d0ce92e3-bf48-455d-bd89-c334654d7e97/how-to-find-partition-function-text-applied-to-a-table</a> </p>