Trying to move NDF file to the PRIMARY filegroup

We have a DB with an MDF file and an NDF file on different filegroups: MDF is on PRIMARY and NDF is on XYZ filegroup.
Is there a way to move the NDF file from the XYZ filegroup to the PRIMARY filegroup (so they are both on the same filegroup)?
DB Architect

Hi Ben
As Olaf already told you can change filegroup for file once done. But before deleting you have to make sure you move all data.
I tried on my machine to check, please use refrence of below code as steps
/**************Create database with 2 file groupse*************/
CREATE DATABASE [Check_filegroup]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'Check_filegroup', FILENAME = N'G:\Saurabh\Check_filegroup.mdf' ),
FILEGROUP [secondry]
( NAME = N'Check_filegroup_data1', FILENAME = N'G:\Saurabh\Check_filegroup_data1.ndf' )
LOG ON
( NAME = N'Check_filegroup_log', FILENAME = N'G:\Saurabh\Check_filegroup_log.ldf' )
GO
/**************create table on secondry file group*************/
USE Check_filegroup
create table test (col1 int , col2 varchar (50)) on [secondry]
/**************insert data into table*************/
USE Check_filegroup
insert into test values (1,'saurabh')
insert into test values (1,'saurabh')
insert into test values (1,'saurabh')
insert into test values (1,'saurabh')
insert into test values (1,'saurabh')
/**************Transfer data into primary file group*************/
USE Check_filegroup
create table test1 (col1 int , col2 varchar (50)) on [Primary]
insert into test1
select * from test
Drop table Test
sp_rename test1, test
---> Do same for all tables and objects if created
/**************Clear Secondry group before delete*************/
USE Check_filegroup
GO
DBCC SHRINKFILE (N'Check_filegroup_data1' , EMPTYFILE)
GO
/************* Delete ndf file ***************/
USE [Check_filegroup]
GO
ALTER DATABASE [Check_filegroup] REMOVE FILE [Check_filegroup_data1]
GO
Please make sure you move all objects in file group and file , belofre deleting them.
Thanks Saurabh Sinha
http://saurabhsinhainblogs.blogspot.in/
Please click the Mark as answer button and vote as helpful if this reply solves your problem

Similar Messages

  • I am trying to move a file via ftp

    I am trying to move a file from my local share drive on my computer to another server via ftp protocol. I can log into the server and get acknowledgments after entering my user name and password. The problem lies when trying to send my file. I am getting an error which states unexpected command. I am trying to use the "put" command. This works in a dos window but the ni visa is giving this error not the server itself I believe. It occurs with the last write/read statement. I am attaching my vi. Any help would be appreciated. Thanks 
    Attachments:
    ftp to omega.vi ‏85 KB

    VISA supports TCP/IP but it doesn't support FTP afaik. NI sells an Internet Toolkit with FTP functions or you could use System Exec to run the DOS command. That's what I do for tftp transfers.
    Message Edited by Dennis Knutson on 07-21-2005 01:43 PM

  • HT1338 Purchased a used macbook pro with Mountain Lion. My old Mac runs Snow Leopard is backed up to Time machine. How do I register the operating system to me and how do I use Time Machine to move my files to the new used computer?

    Purchased a used macbook pro with Mountain Lion. My old Mac runs Snow Leopard is backed up to Time machine. How do I register the operating system to me and how do I use Time Machine to move my files to the new used computer?

    If you look at the User Tips tab, you will find a write up on just this subject:
    https://discussions.apple.com/docs/DOC-4053
    The subject of buying/selling a Mac is quite complicated.  Here is a guide to the steps involved. It is from the Seller's point of view, but easily read the other way too:
    SELLING A MAC A
    Internet Recovery, and Transferability of OS & iLife Apps
    Selling an Old Mac:
    • When selling an old Mac, the only OS that is legally transferable is the one that came preinstalled when the Mac was new. Selling a Mac with an upgraded OS isn't doing the new owner any favors. Attempting to do so will only result in headaches since the upgraded OS can't be registered by the new owner. If a clean install becomes necessary, they won't be able to do so and will be forced to install the original OS via Internet Recovery. Best to simply erase the drive and revert back to the original OS prior to selling any Mac.
    • Additionally, upgrading the OS on a Mac you intend to sell means that you are leaving personally identifiable information on the Mac since the only way to upgrade the OS involves using your own AppleID to download the upgrade from the App Store. So there will be traces of your info and user account left behind. Again, best to erase the drive and revert to the original OS via Internet Recovery.
    Internet Recovery:
    • In the event that the OS has been upgraded to a newer version (i.e. Lion to Mountain Lion), Internet Recovery will offer the version of the OS that originally came with the Mac. So while booting to the Recovery Disk will show Mountain Lion as available for reinstall since that is the current version running, Internet Recovery, on the other hand, will only show Lion available since that was the OS shipped with that particular Mac.
    • Though the Mac came with a particular version of Mac OS X, it appears that, when Internet Recovery is invoked, the most recent update of that version may be applied. (i.e. if the Mac originally came with 10.7.3, Internet Recovery may install a more recent update like 10.7.5)
    iLife Apps:
    • When the App Store is launched for the first time it will report that the iLife apps are available for the user to Accept under the Purchases section. The user will be required to enter their AppleID during the Acceptance process. From that point on the iLife apps will be tied to the AppleID used to Accept them. The user will be allowed to download the apps to other Macs they own if they wish using the same AppleID used to Accept them.
    • Once Accepted on the new Mac, the iLife apps can not be transferred to any future owner when the Mac is sold. Attempting to use an AppleID after the apps have already been accepted using a different AppleID will result in the App Store reporting "These apps were already assigned to another Apple ID".
    • It appears, however, that the iLife Apps do not automatically go to the first owner of the Mac. It's quite possible that the original owner, either by choice or neglect, never Accepted the iLife apps in the App Store. As a result, a future owner of the Mac may be able to successfully Accept the apps and retain them for themselves using their own AppleID. Bottom Line: Whoever Accepts the iLife apps first gets to keep them.
    SELLING A MAC B
    Follow these instructions step by step to prepare a Mac for sale:
    Step One - Back up your data:
    A. If you have any Virtual PCs shut them down. They cannot be in their "fast saved" state. They must be shut down from inside Windows.
    B. Clone to an external drive using using Carbon Copy Cloner.
    1. Open Carbon Copy Cloner.
    2. Select the Source volume from the Select a source drop down menu on the left side.
    3. Select the Destination volume from the Select a destination drop down menu on the right
    side.
    4. Click on the Clone button. If you are prompted about creating a clone of the Recovery HD be
    sure to opt for that.
    Destination means a freshly erased external backup drive. Source means the internal
    startup drive. 
    Step Two - Prepare the machine for the new buyer:
    1. De-authorize the computer in iTunes! De-authorize both iTunes and Audible accounts.
    2, Remove any Open Firmware passwords or Firmware passwords.
    3. Turn the brightness full up and volume nearly so.
    4. Turn off File Vault, if enabled.
    5. Disable iCloud, if enabled: See.What to do with iCloud before selling your computer
    Step Three - Install a fresh OS:
    A. Snow Leopard and earlier versions of OS X
    1. Insert the original OS X install CD/DVD that came with your computer.
    2. Restart the computer while holding down the C key to boot from the CD/DVD.
    3. Select Disk Utility from the Utilities menu; repartition and reformat the internal hard drive.
    Optionally, click on the Security button and set the Zero Data option to one-pass.
    4. Install OS X.
    5. Upon completion DO NOT restart the computer.
    6. Shutdown the computer.
    B. Lion and Mountain Lion (if pre-installed on the computer at purchase*)
    Note: You will need an active Internet connection. I suggest using Ethernet if possible because
    it is three times faster than wireless.
    1. Restart the computer while holding down the COMMAND and R keys until the Mac OS X
    Utilities window appears.
    2. Select Disk Utility from the Mac OS X Utilities window and click on the Continue button. 
    3. After DU loads select your startup volume (usually Macintosh HD) from the left side list. Click
    on the Erase tab in the DU main window.
    4. Set the format type to Mac OS Extended (Journaled.) Optionally, click on the Security button
    and set the Zero Data option to one-pass.
    5. Click on the Erase button and wait until the process has completed.
    6. Quit DU and return to the Mac OS X Utilities window.
    7. Select Reinstall Lion/Mountain Lion and click on the Install button.
    8. Upon completion shutdown the computer.
    *If your computer came with Lion or Mountain Lion pre-installed then you are entitled to transfer your license once. If you purchased Lion or Mountain Lion from the App Store then you cannot transfer your license to another party. In the case of the latter you should install the original version of OS X that came with your computer. You need to repartition the hard drive as well as reformat it; this will assure that the Recovery HD partition is removed. See Step Three above. You may verify these requirements by reviewing your OS X Software License.

  • How do I move music files from the startup disc to iTunes in the other internal hard disk os 10.5.8?

    How do I move music files from the startup disc to iTunes in the other internal hard disk os 10.5.8?
    The music I want to move was in iTunes but is now just files. I had to reinstall a new iTunes and lost all my old music.
    Thank you!

    That article is about using your iPod as an external hard drive, to move files from one computer to another computer.  It is not related to your question.
    You can't use iTunes to move song files from iPod to computer, except for songs you purchased from the iTunes Store (and you can also re-download purchases).  However, there are third-party methods and utilities that can move song files from iPod to computer.  If you do a Google search on something like "ipod transfer," you should get some links.
    Once the song files are on your current computer, add them to that computer's iTunes library by dragging the files (or folder containing the files) to the iTunes window.  After confirming everything is there (and fixing the data issue you mentioned) you can sync the iPod.  You may want to do a Restore on the iPod, if it might have a data corruption issue, which will erase the iPod's hard drive, re-install the latest software, and set it to defautl settings.

  • How do I move aiff files from the viewer to the timeline-it is not working when I try to drag and click or clicking on overwrite or insert in Final Cut Pro 7. Thanks

    How do I move aiff files from the viewer to the timeline-it is not working when I click and drag or when I try to move the files to the overwrite or insert buttons-Thanks.

    hi
    You cannot move audio from the viewer
    Mark your in and out points then in the browser grab hold of the audio tracks icon and drag that to the time line
    PJ

  • Trying to move a file based on file name

    ok, so i feel like this should be an easy thing to accomplish, but sadly, i can't seem to get it. here's what i got...i have an automator app that will take a file that has been scanned in (pdf) and rename it to the name in a field in one of my filemaker databases. got that working. now, depending on the name of the file, i need this applescript to move that file to the correct folder. for instance...if the file name starts with "P", then i need it to move to 'folder 1'. if it starts with 'L", it needs to move to 'folder 2'....and so on. this is what i've got, but it doesn't work. can someone point me in the right direction?
    on run {input, parameters}
    set FileName to input as text
    tell application "Finder"
    if name of FileName starts with "P" then
    move file FileName to folder "Drive:Folder:Folder1"
    else if name of FileName starts with "8" then
    move file FileName to folder "Drive:Folder:Folder2"
    else if name of FileName starts with "L" then
    move file FileName to folder "Drive:Folder:Folder3"
    else if name of FileName starts with "T" then
    move file FileName to folder "Drive:Folder:Folder4"
    end if
    end tell
    return input
    end run

    try...
    if character 1 of FileName is "P"
    edit:
    Whoops rereading your code I realized I completely misdiagnosed the problem there as "begins with" is proper applescript. What are you passing in as Filename? Try a "display dialog FileName" near the beginning of your script and see what you get. You might also try ...if fileName contains "string"...so you don't need to worry about starts with etc.

  • How to move all files to the top level folder?

    I want to move all files within a particular folder -- and all files in all sub folders -- to the top level. i.e. I want to collapse the folder structure to just one folder. Assume that there are no files with the same name.
    *Method 1*
    My first thought was to use Find:
    1. Limit Find to the particular folder.
    2. Find all files in the folder with Size > 0.
    3. Switch to List view. All files are listed.
    4. Select all files and drag to the top folder
    5. Delete all sub folders manually.
    Problem: Pages files are not found, and maybe others aren't.
    This is a simple method and I'd like to stick with it.
    *QUES 1*
    What condition should I set within Find so that I can be guaranteed of finding all files?
    *Method 2*
    It was suggested in another thread that I use Terminal to move all files to the top level, but I couldn't get it to work. And there was a problem with files that consist of bundles.
    *QUES 2*
    What is the easiest way to consolidate all files within a folder to the top level -- assume no duplicate names -- and at the same time remove all sub folders?
    Message was edited by: Guy Burns

    Thanks for the suggestion of EasyFind.
    To find all files in a certain folder I typed in *[a-z 0-9] as a Boolean search (this thread won't let me post the exact characters required by EasyFind). That should cover every file I've ever named. EasyFind came back with "11719found/12316done".
    Any idea what the missing 500 files would be? I'm hoping they are files that I don't need to know about (invisible files, system files and so on).
    Message was edited by: Guy Burns

  • Trying to open a file in the browser and Adobe reader/acrobat says to quit and try again (1:9) HELP

    trying to open a file in the browser and Adobe reader/acrobat says to quit and try again (1:9)
    Do this over and over and even reinstalled several times to no avail. Mac running the latest Mt. Lion
    HELP

    click file > place formats to import graphic files.
    http://helpx.adobe.com/indesign/kb/supported-file-formats-indesign-cs5.html

  • I was trying to move my photos from the iPhoto library to an external hard drive.  I now have a desktop display of thousands of cascading photos.  How do I remove them from my desktop screen?

    I was trying to move my photos from the iPhoto library to an external hard drive.  I now have a desktop display of thousands of cascading photos.  How do I remove them from my desktop screen?

    Strangely enough we can not see you so it really helps if you share with use exactly what you have, exactly what you did and details about the problem
    what version of iPhoto and of the OS? What exact steps did you do? where are you seeing these "thousands of cascading photos" now and using what software and what exactly did you want to accomplish
    The correct way to move your iphoto library to an external drive is to verify the drive is formatted Mac OS extended (journal) and then drag the iphotl library intact as a single entity to is
    The correct way to move some or all of your photos is to select them in iphoto and export 9file menu ==> export  --  https://discussions.apple.com/docs/DOC-4921 ) to the external drive
    LN

  • Select statement from a join file deletes the primary records with MS Expl.

    Hello,
    is reality,
    Select statement from a join file deletes the primary records with MS Explorer 6, Firefox not, this with a normal data provider or with a normal "select..." statement.
    This is very strange, I should have a.a.s.p. a solution or workaround
    Thanks, Franco.
    Message was edited by:
    fbiaggi

    Please see the following excerpt from the online documentation.
    http://docs.oracle.com/cd/E11882_01/server.112/e22490/ldr_modes.htm#SUTIL1332
    Enabled Constraints
    During a direct path load, the constraints that remain enabled are as follows:
    NOT NULL
    UNIQUE
    PRIMARY KEY (unique-constraints on not-null columns)
    NOT NULL constraints are checked at column array build time. Any row that violates the NOT NULL constraint is rejected.
    Even though UNIQUE constraints remain enabled during direct path loads, any rows that violate those constraints are loaded anyway (this is different than in conventional path in which such rows would be rejected). When indexes are rebuilt at the end of the direct path load, UNIQUE constraints are verified and if a violation is detected, then the index will be left in an Index Unusable state. See "Indexes Left in an Unusable State".

  • Import Error: Could not move a file to the requested location.

    After importing with the move option I get "Could not move a file to the requested location." and a list of all the
    images. The images were all moved so the sync option finds them in the destination folders. It is just a pain to go through this two step process. Note this wasn't the initial behavior at first the process worked.
    Lightroom v3 (release copy)
    Vista

    Odd thing was this wasn't a problem when I first started using the LR3 release this has developed in the last few hours even after a reboot.

  • Could not allocate space for object temporary system object: ... in database 'tempdb' because the 'PRIMARY' filegroup is full.

    Using SQL Server 2008 R2. Tempdb resides on disks W and X
    both of those are 250 GB each. Nothing else resides on these disks. The recovery mode for tempdb is set to Simple and is split in 8 files and one log file. Each of the tempdb file is set for auto growth by 128 MB and max size is unlimited. The log file is
    set for auto growth by 10% and max size unlimited. 
    I get the following error at least once a week while running an ETL:
    [SQLSTATE 01003] (Message 8153) Could not allocate space for object '<temporary system object: 335532118192937>' in database 'tempdb' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup,
    adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup. [SQLSTATE 42000] (Error 50000). The step failed.
    I have to then shrink the tempdb log and files to create space on the disks.
    What is a permanent solution to this problem, I don't want my ETL to break due to TempDB diskspace full.
    Thanks in advance. 

    Hi,
    Permanent solution would be finding out query which is causing tempdb log file to grow out of proportion and fill it and I would like you to take help of below article
    Troubleshooting out of space issue in Tempdb
    Please change Autogrowth value for Log file from 10 % to may be 100 M. This is just a tentative value you need to study
    growth of tempdb to reach to correct value. You kept 128 MB autogrowth for tempdb data file is this value tentative or you just put it.
    Below article can be referred for tempdb details
    Working with tempdb
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • A PDF file was filed in documents. when trying to move this file to trash i got response : operation can't be completed because the itempdf is in usen

    A PDF file was filed in DOCUMENTS, when trying to move this PDF file to trash I got the response: "Operation can't be completed because the item ..... is in use".
    How do I get this document deleted from the system?

    The suggestion to move items from documetns to desktop and then moving to trash is the one that worked.
    I have now one other question and that is that during my strugle with the original problem I called with Apple helpline and there they suggested to move the application "Preview" to trash and then the  issue would be solved. I did so but clearly the issue was not solved.
    Bottom line is that with your solution I got rid of the PDF files, but I still need to reinstall the Preview application. Do you have suggestions how to do that??

  • I moved itunes file to external hard drive and want to move the file on my pc to recycle bin. When I move i get an error message that it cannot delete ituneshelper.dll access is denied. Can I move that file to the recycle bin?

    I am trying to free up space on my pc and moving itunes files to external hard drive. I have followed instructions and believe I have file copied to new drive, but I am having trouble moving file to recycle bin as the instructions say. I am getting the following error message: cannot delete ituneshelper.dll:access denied, make sure disk is not full or write protected and file not in use. I know the file is not in use when trying to move. Any help would be most appreciated. I am on Windows XP.

    Yes. And you should not have moved that folder. Put it back. To move your iTunes library move the folder from User's Music.
    tt2

  • Error while trying to move a file from a folder to another

    Hi,
    I have created an application that processes files. When a file is processed, the application moves it to another subfolder.
    I am working on Netweaver Developer Studio 7.2. The application is a standard DC Web Dynpro.
    The code used to move the file is the following:
    File destFolder = new File(destinationFolder);
    if (!destFolder.exists())
         repCible.mkdirs();
    if (destFolder.exists()) {
         File fileToMove = new File(parentFolder + "\" + fileName);
         boolean isFileMoved = fileToMove.renameTo(new File(
                   destinationFolder + "\" + fileName));
         disp("Etat du déplacement du fichier: " + isFileMoved);
    The code is surrounded with a try catch to catch any SecurityException or NullPointerException. None of these exception is caught, and the isFileMoved boolean always return false.
    When the destination folder does not exist, it is created but the file isn't moved. Since the files and folders are situated in a network folder, I have tried to implement the exact same code in a stand alone Java application (not WDPJ). The code works fine. What is wrong with my Web Dynpro DC ? Any thoughts ?
    Thanks in advance for your help,
    Thibault

    Problem solved: I used the Scanner to extract data from the files and forgot to close the scanner.
    As a result, the file was still processed by thread and could not be deleted or moved !!

Maybe you are looking for