Posts

Showing posts from 2024

Azure SQL Managed Instance Database Query.

The below piece of code is explaingin about Azure SQL Managed Instance backup status. However this can be taken care by Azure internally. SELECT TOP ( 30 ) bs.machine_name, bs. server_name , DB_NAME(DB_ID(bs.database_name)) AS [ Database Name], bs.recovery_model, CONVERT ( BIGINT , bs.backup_size / 1048576 ) AS [Uncompressed Backup Size (MB)], CONVERT ( BIGINT , bs.compressed_backup_size / 1048576 ) AS [Compressed Backup Size (MB)], CONVERT ( NUMERIC ( 20 , 2 ), ( CONVERT ( FLOAT , bs.backup_size) / CONVERT ( FLOAT , bs.compressed_backup_size))) AS [Compression Ratio], bs.has_backup_checksums, bs.is_copy_only, bs.encryptor_type, DATEDIFF ( SECOND , bs.backup_start_date, bs.backup_finish_date) AS [Backup Elapsed Time (sec)], bs.backup_finish_date AS [Backup Finish Date ], bmf.physical_device_name AS [Backup Location ], bmf.physical_block_size, * FROM msdb.dbo.backupset AS bs WITH (NOLOCK) INNER JOIN msdb.dbo.backupmediafamily AS bmf WITH (NOLOCK) ON bs.me

Moving the table to new file group in SQL Server

Image
The below link will explain how to move table from one file group to another file group. How to move table from one filegroup to another After the link opens search with the below text to go to the respective topic. D. Dropping a clustered index online and moving the table to a new filegroup. In the below example I am moving Person.Person table to new file group and new data file and new drive. USE master go ALTER DATABASE [AdventureWorks2014] ADD FILEGROUP MyGroup go ALTER DATABASE [AdventureWorks2014] ADD FILE (NAME = 'MyDataFile_Data' , FILENAME = 'G:\AdventureWorks\NEWFILEGROUP\MyDataFile_data.ndf' ) TO FILEGROUP MyGroup GO /* The below piece of code will move the table from pirmary to newly created file group called "MyGroup". And in this piece of code "UNIQUE" is compusory However this is not referring to UNIQUE index. This command may throw an error if the table has "XML" indexes.Scriptout those tables drop it and rec