How to move the tables without having clustered index from one file group to another file group simply in SQL 2008.?

Hello All,

This might not be the proper for the blog post but it helps me to understand more regarding the transfer of tables within different file groups in MS-SQ L. So, I think it will be more helpful to the others who indeed needs such information related to file groups .

I had posted as below within MSDN

I have few issues regarding the transfer of the tables from one file group to another file group  in SQL 2008 and also How can we  backup and restore the particular database based on file group level.

Let’s say I have a tables stored within the different FG. such as

Tables                                                                                                                           File group

Dimension tables                                                                                                              Primary

Fact tables                                                                                                                           FG1


zzz_tables                                                                                                                           DEFAULT_FG

dim.table1                                                                                                                           DEFAULT_FG

dim.table2                                                                                                                           DEFAULT_FG

…                                                                                                                                             ….

Here all I want to transfer the dim.table1 ,dim.table2  from  DEFAULT_FG to the Primary File group .So is there simple methods for transfer the dim.table1,2  from one FG to another .I have tried somewhat but I couldn’t get the exact way .So if someone have better idea please share your knowledge that would be really appreciated.

Secondly after moving those dim.table1 ,dim.table2 from DEFAULT_FG to Primary ,All I want to backup and restore the database only containing  the Primary and FG1,FG2… not a DEFAULT_FG.Is it possible or not.?

Currently I have no any clustered index defined within the dim.table1 ,dim.table2 and so on.

Cannot we transfer the tables from DEFAULT_FG to another FG without having clustered index on that tables or without select/insert operation so that I couldn’t have to recreate the tables. I have researched somewhat and found that we couldn’t  move the tables without having the clustered index to another file group simply in MS-SQL so sad :(..!!!

Hope to hear from the one who knows better approach for this kind of task .Your simple help will be much appreciated.

Some helpful links regarding transfer of tables between different FG’s and restore/backup FG’s.

Well after all my full day research on this topic had paid off, I finally got the solution and am so happy to research on these things. It makes us feel really happy after all our research and hard work doesn’t goes as waste.

Finally I got what I am looking for and want to make sure that I am able to transfer the tables from DEFAULT_FG to another FG without tables having clustered index on that tables .

With the help of the link below I finally got my solution where Roberto’s coded store procedure simply works for this.

Really thanks to him for his great post and thanks to everyone for their response in MSDN and their valuable time.


Anil Maharjan

How Can I know who has changed anything in SQL?

Hello all,

After such a long time , I would like to post some another blog which might be helpful to the one who works in SQL.

I need to find the one who has changed the tables within my SQL Database that I have created.

For certain reason ,we may need to find /to know who has done any changes within SQL. Such as add view, delete table, modify table, create database, add column, stopped SQL agent job, create new job, modify rules, add roles, new login, and etc.

In order to trace this information and find out my solution, I have researched somewhat and find the solution as.

we can enable and disable the default trace in SQL Server. Meanwhile we can use the default trace enabled option to enable or disable the default trace log files.

If we want to capture the information about who changed the objects in SQL Server. Please try to run the script, which works for me as below:

DECLARE @filename VARCHAR(255) 
SELECT @FileName = SUBSTRING(path, 0, LEN(path)-CHARINDEX('', REVERSE(path))+1) + 'Log.trc'  
FROM sys.traces   
WHERE is_default = 1;  

--Check who dropped and created objects, altered objects
SELECT gt.HostName, 
       te.Name AS EventName,
FROM [fn_trace_gettable](@filename, DEFAULT) gt 
JOIN sys.trace_events te ON gt.EventClass = te.trace_event_id 
where gt.ObjectName ='DimTable' and gt.DatabaseName ='Database'
ORDER BY StartTime;
 --DimTable -replace with the trace table and Database -replace with your DB

I am able to find the one who have changed my tables that I have created.

Also we should have to know that, SQL Server only shows you the IP address of the Terminal Server machine. It has no knowledge about how the user connected to that server. You would have to find the RDP logs and enter them into the database somehow to correlate the information. Which still can be inconclusive if there are more than one user connected through RDP at the same time.

Reference from the link:—the-power-of-performance-and-security-auditing/

Is there any alternative solution for this kind of issue .Hope someone have some idea regarding on this.

Hope this post will be useful for all of us in the field of BI mainly SQL.


Anil Maharjan

How to schedule and automate backups of all SQL Server databases in SQL Server.

Hello all,

With the course of time, you might need to backup all the databases within a server instance automatically and schedule to backup these database monthly wise or according to your specific time set.

Also, what I want to say is that ,I cannot stop myself to write this another blog of mine.

writing a blog and sharing some knowledge through the blog makes us really feels happy and also somewhat we also become addicted to it. 🙂

This may be simply for one but for someone it will be helpful for those who don’t know how to do it.

May be there are a lot of alternative methods to perform this task and many solution’s.

But I have researched a lot regarding to backup all the SQL database as well the SSAS catalogs database backup with in a particular server instance.

Here ,I am going to show how to obtain the SQL database backup automatically along with schedule time set.
Firstly, I have created a SSIS package where I used simply “Back up Database Task “ from toolbox and click right then clicking in edit tab, we can set the connection as show in figure1 below:

Then we can set the Backup Type as full or other type after that you can select the databases to backup as show in figure2 below where we can set required databases to backup.

After that you can set the other different properties like
1.Backup set Expire
2.Bakup to
3.Append or overwrite if backup exist
4.for everyday backup options
5.Backup location directory currently I set to default location.
6.allow compression or not.
You can figure out by looking the figure3 below.

Now all you need to create a job agent to schedule the backup task and run SSIS package. In order to do this you can check out the link by Brian Knight as

or simply go to SSMS and start Sql Server Agent and right click and create new job where you have to setup some properties as shown in figure4.

Here you can schedule the backup going into the schedule tab and then just check the job working or not by right clicking it and Start job at step then you can check the all the backup database within the default location as : C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLBackup

Hope you get some ideas to obtain the schedule Sql databases backup automatically ,also I am thinking to post into my another blog for “ Automate and schedule all SSAS catalogs database backup with in a server instance by using Job Agent” or similar approach which have taken most of my research time and I am happy to obtain the result successfully.

Lastly,this may be simple but I think it may work out for someone .

Anil Maharjan