4

I want to get information through SQL query for any database in SQL Server 2016 whether it is already set to be memory optimized or not. I know following query

SELECT DatabasePropertyEx('DATABASENAME', 'IsXTPSupported');

tells you that whether you can set (by setting the Memory Optimized Data file Group) the database to have in memory tables or not. But I want to know that whether db is already set to contain in memory table or not i.e. its Memory Optimized Data File Group have been already set or not?

How I can achieve this through SQL Query for any given database?

TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
  • 1
    Googling the title of your question I found this: https://msdn.microsoft.com/en-CA/library/dn232522.aspx SELECT quotename(schema_name(o.schema_id)) + N'.' + quotename(o.name) AS [table], s.name AS [statistics object], 1-s.no_recompute AS [auto-update enabled] FROM sys.stats s JOIN sys.tables o ON s.object_id=o.object_id WHERE o.is_memory_optimized=1 – Peter4499 Jan 05 '17 at 13:45
  • You can post it as an answer @Peter4499 – Shakeer Mirza Jan 05 '17 at 13:48

3 Answers3

1

Googling the title of your question I found this: https://msdn.microsoft.com/en-CA/library/dn232522.aspx

SELECT 
    quotename(schema_name(o.schema_id)) + N'.' + quotename(o.name) AS [table],
    s.name AS [statistics object],
    1-s.no_recompute AS [auto-update enabled]
FROM sys.stats s JOIN sys.tables o ON s.object_id=o.object_id
WHERE o.is_memory_optimized=1
Peter4499
  • 685
  • 7
  • 15
  • The above query basically tells about table whether its memory optimized or not, but I want to know about database whether its already memory optimized or not. Anyone else can help me out please? – Abdul Qayyum Jan 13 '17 at 04:57
1

Try this:

SELECT distinct DB_NAME()
FROM sys.master_files sdf
INNER JOIN
sys.filegroups fg
ON sdf.data_space_id=fg.data_space_id and fg.type='FX'
Bugs
  • 4,491
  • 9
  • 32
  • 41
  • 2
    it would be worth expanding on your answer with an explanation to help future visitors. Thank you. – Bugs Jul 14 '17 at 15:32
1

Many ways... One more alternative than the above list:

SELECT type, name, memory_node_id, pages_kb/1024 AS pages_MB   
FROM sys.dm_os_memory_clerks WHERE type LIKE '%xtp%' 
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Tarun
  • 59
  • 4