This is a similar question to the one I posted earlier, but with changes.
I created a table like this:
Table with partition schema applied
CREATE TABLE TB_PARTITION_SCHEMA (
COL INT,
COL2 INT
)
ON PartitionSchema (COL)
GO;
EXEC sp_addextendedproperty
@name=N'MS_Description', @value=N'Partition Schema Comment',
@level0type=N'SCHEMA', @level0name=N'dbo',
@level1type=N'TABLE', @level1name=N'TB_PARTITION_SCHEMA'
GO
Table with filegroup applied
CREATE TABLE [dbo].[TB_ONLYFG] (
[COL] [INT]
)
ON [test2fg]
GO
EXEC sp_addextendedproperty
@name=N'MS_Description', @value=N'Only FileGroup',
@level0type=N'SCHEMA', @level0name=N'dbo',
@level1type=N'TABLE', @level1name=N'TB_ONLYFG'
GO
Table with text image applied
CREATE TABLE [dbo].[TB_TEXTIMAGE] (
[COL] [VARCHAR](max)
)
TEXTIMAGE_ON [test1fg]
GO
EXEC sp_addextendedproperty
@name=N'MS_Description', @value=N'Only TextImage',
@level0type=N'SCHEMA', @level0name=N'dbo',
@level1type=N'TABLE', @level1name=N'TB_TEXTIMAGE'
GO
Table with filegroup and text image applied
CREATE TABLE [dbo].[TB_FILEGROUP] (
[COL] [INT],
[COL2] [VARCHAR](max)
)
ON [test1fg]
TEXTIMAGE_ON [test2fg]
GO
EXEC sp_addextendedproperty
@name=N'MS_Description', @value=N'fileGroup, TextImage Comment',
@level0type=N'SCHEMA', @level0name=N'dbo',
@level1type=N'TABLE', @level1name=N'TB_FILEGROUP'
GO
I want to search these tables at once. The query I've tried is:
SELECT
t.name as tableName
, f.name as fileGroupName
, f.log_filegroup_id
, t.lob_data_space_id
, CAST(ep.value AS NVARCHAR(4000)) AS comment
FROM sys.indexes as i
INNER JOIN sys.tables as t ON t.object_id = i.object_id
INNER JOIN sys.filegroups f ON i.data_space_id = f.data_space_id
LEFT JOIN sys.extended_properties ep ON ep.class = 1
AND ep.minor_id = 0
AND t.object_id = ep.major_id
AND ep.name = N'MS_Description'
WHERE t.schema_id = 1
ORDER BY t.name ASC
| tableName | fileGroupName | logFileGroupId | lob_data_space_id | comment |
|---|---|---|---|---|
| TB_FILEGROUP | test1fg | NULL | 3 | fileGroup, TextImage Comment |
| TB_ONLYFG | test2fg | NULL | 0 | Only FileGroup |
| TB_TEXTIMAGE | PRIMARY | NULL | 2 | Only TextImage |
The question is:
There is no way to query the partition schema and partition columns in the current query. What is it?
How to search data specified as text image?
For both questions, I want the partition schema for each table and the partition column to be verifiable as a column as shown in the table above.