You can't drop partition schemes or functions that are in use.
USE tempdb
CREATE PARTITION FUNCTION yourmom ( INT )
AS RANGE LEFT FOR VALUES ( 10, 20, 30, 40, 50 );
CREATE PARTITION SCHEME yourdad
AS PARTITION yourmom
ALL TO ([PRIMARY]);
CREATE TABLE dbo.yourauntdebbie
(
id INT,
whatever VARCHAR(50)
) ON yourdad (id);
Not even adding any data.
DROP PARTITION FUNCTION yourmom;
DROP PARTITION SCHEME yourdad;
First Error:
Msg 7706, Level 16, State 1, Line 17 Partition function 'yourmom' is
being used by one or more partition schemes.
Second Error:
Msg 7717, Level 16, State 1, Line 19 The partition scheme "yourdad" is
currently being used to partition one or more tables.
Let's create an index and add some data so you don't think I'm crazy.
CREATE CLUSTERED INDEX ix_whatever ON dbo.yourauntdebbie (id) ON yourdad (id)
INSERT dbo.yourauntdebbie WITH (TABLOCK) (id, whatever )
SELECT TOP 1000 n, REPLICATE('A', n % 50)
FROM (SELECT ROW_NUMBER() OVER (ORDER BY @@ROWCOUNT) AS n
FROM sys.messages AS m) AS x
Now, let's rebuild the clustered index away from the partitioning scheme.
CREATE CLUSTERED INDEX ix_whatever ON dbo.yourauntdebbie (id) WITH (DROP_EXISTING = ON) ON [PRIMARY]
We can drop the scheme;
DROP PARTITION SCHEME yourdad;
Drop the function:
DROP PARTITION FUNCTION yourmom;
And still select the 1000 rows:
SELECT *
FROM dbo.yourauntdebbie AS y
And then clean up the table.
DROP TABLE dbo.yourauntdebbie