title: Change FileGroup of File
body: <p>While working on <code>SQL Server</code>, I faced the problem with changing the <code>FileGroup</code> of <code>File</code>.</p>
  
  <p>Suppose that, we create a database using below sql code:</p>
  
  <pre><code>CREATE DATABASE Example
  ON PRIMARY
  (NAME = example_dat,
   FILENAME = 'D:\exmaple_dat.mdf',
   SIZE = 10,
   MAXSIZE = 50,
   FILEGROWTH = 15%), 
   (NAME = example_second_dat,
    FILENAME = 'E:\example_second_dat.ndf',
    SIZE = 10,
    MAXSIZE = 50,
    FILEGROWTH = 15%)
  LOG ON
  (NAME = exmaple_log,
   FILENAME = 'D:\example.log',
   SIZE = 5,
   MAXSIZE = 25,
   FILEGROWTH = 5MB)
  GO
  </code></pre>
  
  <p>Now, i want to add file group <code>DataFileGroup</code> and add <code>exmaple_dat</code> and <code>example_second_dat</code> to it.</p>
  
  <p>Please give me a solution. </p>
  
  <p>Thanks in advance :)</p>