How to copy a database with all the objects and relationship but with no data

Hello Experts
I am here for your advise as usual, I  want to create a copy of my current database from an existing one on SQL Server 2008r2 Standard Edition, here is what I need, I want all the objects including any relationship between the objects and I do
not need any data. I have some idea for using the general script in SSMS, but I still need you expertise advise please, thank you kindly for your help.
Regards

One option is to run BACKUP/RESTORE, once you have restored you run:
SELECT 'ALTER TABLE ' + quotename(s.name) + '.' + quotename(o.name) +
       ' DISABLE TRIGGER ALL '
FROM   sys.schemas s
JOIN   sys.objects o ON o.schema_id = s.schema_id
WHERE  o.type = 'U'
  AND  EXISTS (SELECT *
               FROM   sys.triggers tr
               WHERE  tr.parent_id = o.object_id)
Copy result and paste into a query window do to run. Next:
SELECT 'DELETE ' + quotename(s.name) + '.' + quotename(o.name)
FROM   sys.schemas s
JOIN   sys.objects o ON o.schema_id = s.schema_id
WHERE  o.type = 'U'
Run this result until you don't get any more errors.
Run the first query again, but change DISABLE to ENABLE.
This is more long-winding than scripting, particularly if you have lots of data. But you know that you will not make any changes whatsoever to the schema.
The scripting in SSMS generally does it right, I believe, but some items are not scripted by default. If you run BACKUP/RESTORE, you know that you get a faithful copy.
Of course, the best way is to keep your code under version control and take the version control system as your ultimate truth.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • I need to know how to edit a drawing - basically remove the arrows and text but at the same time match the background of the existing pic. then re add new text. how do i erase the arrows and text and arrows but match current background of pic. step by ste

    i need to know how to edit a drawing - basically remove the arrows and text but at the same time match the background of the existing pic. then re add new text. how do i erase the arrows and text and arrows but match current background of pic. step by step explanation please beginner

    Please post (a relevant section of) it right on this Forum.

  • How to connect to database for all the reports FR

    Hi,
    I have developed 100 reports in production client, for testing purpose I have moved to
    test client. How can I connect to database for all the reports at a time?
    Regards
    Taruni

    Hi Taruni,
    You can connect to the database connection for all the reports through workspace in HFM.
    Connect to HFM Workspace-->click on Explore option-->and click on Tools-->click on Data Base Connection Manager and change the respective connections from Production Instance to Test Instance with required information, and than you will be able to connect to Test database for all the reports at a time.
    Regards,
    Srikanth

  • HT4967 I can sync data from my Mac to my iPhone and iPad and from my iPhone to the Mac and iPad, but cannot sync data from the iPad to either device. My iPad is configured to Push. Is there another setting than I'm forgetting?

    I can update data from my Mac to my iPhone and iPad, and from my iPhone to my Mac and iPad, but cannot get data to update from my iPad to either my Mac or my iPhone.

    If new calendar events entered on your iPad do not appear on icloud.com, go to Settings>Mail,Contacts,Calendars>Default Calendar on your iPad and be sure you have selected an iCloud calendar as your default and not something else like On My iPhone, a Gmail or Yahoo calendar, etc.  If you haven't, make this change, then add a new event and see if it appears on your calendar on icloud.com now.
    If your settings are correct and new events still aren't appearing on icloud.com, add any missing calendar events from your iPad to your calendar on icloud.com.  Once the calendar on icloud.com is up to date with your iPad, go to Settings>iCloud, turn Calendars to Off, choose Delete from My iPad when prompted (they will still be in iCloud), then after a 15 seconds or so, turn Calendars back to On.  Then add a new event on your iPad and see if it appears on your calendar on icloud.com now, and on your other devices.

  • My 5 year old iMac's hard drive is at the point of failing.  I'm trying to save al files on it, but it wont allow backup via Time Machine to an external hard drive.  How can I keep from losing all the files and programs if the hard drive fails?

    I'm concerned that my iMac, purchased 5 years ago, is about the crash and I can't back up my files and programs to an external hard drive via Time Machine because the computer freezes after only a couple hundred MB and gets nowhere near the required amount.
    How can I save these files and programs if the computer hard drive fails or has to be replaced without the backup being able to be done? I need to do something quickly, but I'm not sure what I can or should be doing.

    Get an external hard drive, some good ones that I like are the OWC, http://www.macsales.com Mercury Elite Pro drives...they are very good and reasonably priced.
    Get the drive, connect via USB or FireWire, then use Disk Utility to format the new drive as Mac OS X Extended (Journaled), and then use Disk Utility to Restore the current drive to the new drive.  Restore actually clones the drive so you will have a bootable backup on the external drive.
    After you have formatted and named the external drive, click Restore in the main Disk Utility window, drag the name of the old hard drive to the Source box, and drag the name of the new external drive to the Destination box.  DU will make an exact clone of the internal drive on the external drive.
    That clone will be a complete backup of the operating system and all of your data.
    You can test it by restarting the iMac and hold the Option key.  That will give you a grey screen showing all bootable drives.  Just click the external drive, then click the upward pointing arrow under it and the iMac will boot from that drive.

  • How do I duplicate a spreadsheet keeping all the layout and formulae but without the data?

    I have a good spreadsheet set up. I wish to start a new set of 'books' using the same layout and formula set up but with no data. Other than duplicating the spread sheet and manually deleting the data while preserving the formulae how can I do this?

    Hi Frasercat,
    You could have a table where you input values, and another table with formulae that refer to the input table. Save the original document, then duplicate. Delete the values in the input table. You could Save As Template for future use.
    Regards,
    Ian.

  • Using the REST API for files, how do I get information on all the folders and files in a folder?

    I have an app that can successfully get a list of a folders content. However, by default the list is limited to 200 entries. I luckily ran into this limit when getting the list on a folder that contained 226 entries and realized I needed to then request
    a list of the next items but it wasn't obvious from the REST API document how to do that. I tried sending the skipToken query parameter and setting it to 0 initially and incrementing each time I sent the request but always got the same 200 items back. So,
    how do I get the list of files and folders beyond the initial list?

    In SP2013 the skiptoken query parameter does not work with list items. You can look at the link below which discusses using the "__next" parameter.
    http://stackoverflow.com/questions/18964936/using-skip-with-the-sharepoint-2013-rest-api
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

  • My headphone jack is not working but the mic is working fine i have chked my headphones too . They r working fine i have cleared all the dust and my phone is upto date . Please help me how can i fix this problem

    please help me

    The problem would seem to be in the firewall in your router.  Have you tried disabling it? I assume you've updated the router firmware, right?  Consider bypassing the ISP provided router (using it as a modem only) and unsing another device such as an Aiport Express.

  • Where does itunes store my playlists on my pc,I can locate my itunes media which contains all the albums and artists but not my playlists?

    Im a bit of a tech dummy and am trying to add a playlist to an iphone that is NOT synced with my itunes account, with ipod/ipad this is simple as I can manually manage content, however this feature doesn't work on iphone. I have a program installed which allows me to add to the iphone however I need to add directly from the itunes folder not within itunes. I have created a playlist in itunes to add to this device however I can not locate this folder in my itunes files!! I'm sure I am missing something simple here

    iTunes playlists are stored within the library database iTunes Library.itl. Perhaps you need to create a m3u playlist for use with your other software. Right-click on the playlist name in the sidebar for export options.
    Or use iTunes to manage the content on the device in the way that it is designed to.
    tt2

  • TS1591 I followed all the steps and everything but my ipod is still not showing up at all. Help Please!!!

    I have looked at everyones comments and everything.  When i plug in my ipod the usb works and everything because my ipod is charging.  It will not show up anywhere in iTunes at all. Anyone help please?!

    Have you tried another cable and USB port?
    If you have OSX 10.6.8 on the computer did you look at the Additional Information paragraph of the article you cited?
    Try on another computer to help determine if yo have an iPod or computer problem

  • When i plug my ipod up, itunes says it has all the music and videos, but when i unplug it to listen to them, it says it has nothing on it

    I just had to reover my Ipod original and now im moving all of my music and videos back onto it, and when i have it plugged into Itunes, everything shows up on the ipod.  when i unplug it though, it says i have no videos, music, etc. help? I don't want to lose this thing, it was too expensive.

    Hello kittypie,
    You may need to restore your iPod to factory defaults.
    Restoring iPod to factory settings
    http://support.apple.com/kb/HT1339
    Cheers,
    Allen

  • How do i copy album artwork to all the songs in an album

    How do i copy album artwork to all the songs in an album as some of the songs do not have the artwork, as with the previous version of itunes you had to load artwork individually.
    I have tried the copy and paste option and that does not work
    Look forward to hearing from you

    "How do i copy album artwork to all the songs in an album as some of the songs do not have the artwork, as with the previous version of itunes you had to load artwork individually."
    That suggests some underlying issue, as iTunes has always (AFAIR) allowed artwork to be assigned with multiple tracks in a single action.  For an album, right-click on the album, select Get Info, select the Artwork tab.  You then have three options:
    If the artwork image exists as a file, click the Get Artwork button, browse to and select the file, then click Open.
    Drag and drop the image file from Windows Explorer to the Artwork tab (previous releases also allowed drag and drop from a web browser, this functionality is missing - either by design or as the result of a bug - in iTunes 12).
    If you've copied the artwork image to the clipboard, press Ctrl-V on the keyboard to paste in the image (prior to the 1st release of iTunes 12 this could also be done using right-click > Paste - hopefully this will be restored as a bug-fix in the next update)
    "I have tried the copy and paste option and that does not work."
    There are three possible causes for this:
    The format of your media files doesn't support embedded artwork - specifically, uncompressed audio in WAV format.  You'll need to convert to Apple Lossless (without loss of quality) or either MP3 or AAC (if you're OK with lossy media) before artwork images can be associated with your media.
    Windows' permissions are preventing your media files from being updated when iTunes attempts to embed the images (in a perfect world iTunes should report this as an error, but it actually does nothing).  To check this, find the folder that contains media of interest in Windows Explorer (by default this will be C:\Users\user_name\Music\iTunes\iTunes Media\Music\artist_name\album_name), right-click and select Properties, Security tab - check that your Windows user account has full control over the folder.
    The media files that you're trying to add artwork to may be set to read-only in Windows. Select the folder as before in Windows Explorer, right-click > Properties and make sure that the Read-only flag is cleared.

  • How to write select query for all the user tables in database

    Can any one tell me how to select the columns from all the user tables in a database
    Here I had 3columns as input...
    1.phone no
    2.memberid
    3.sub no.
    I have to select call time,record,agn from all the tables in a database...all database tables have the same column names but some may have additional columns..
    Eg: select call time, record,agn from ah_t_table where phone no= 6186759765,memberid=j34563298
    Query has to execute not only for this table but for all user tables in the database..all tables will start with ah_t
    I am trying for this query since 30days...
    Help me please....any kind of help is appreciated.....

    Hi,
    user13113704 wrote:
    ... i need to include the symbol (') for the numbers(values) to get selected..
    eg: phone no= '6284056879'To include a single-quote in a string literal, use 2 or them in a row, as shown below.
    Starting in Oracle 10, you can also use Q-notation:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements003.htm#i42617
    ...and also can you tell me how to execute the output of this script. What front end are you using? If it's SQL*Plus, then you can SPOOL the query to a file, and then execute that file, like this:
    -- Suppress SQL*Plus features that interfere with raw output
    SET     FEEDBACK     OFF
    SET     PAGESIZE     0
    -- Run preliminary query to generate main query
    SPOOL     c:\my_sql_dir\all_ah_t.sql
    SELECT       'select call time, record, agn from '
    ||       owner
    ||       '.'
    ||       table_name
    ||       ' where phone_no = ''6186759765'' and memberid = j34563298'
    ||       CASE
               WHEN ROW_NUMBER () OVER ( ORDER BY  owner          DESC
                              ,        table_name      DESC
                              ) = 1
               THEN  ';'
               ELSE  ' UNION ALL'
           END     AS txt
    FROM       all_tables
    WHERE       SUBSTR (table_name, 1, 4)     = 'AH_T'
    ORDER BY  owner
    ,       table_name
    SPOOL     OFF
    -- Restore SQL*Plus features that interfere with raw output (if desired)
    SET     FEEDBACK     ON
    SET     PAGESIZE     50
    -- Run main query:
    @c:\my_sql_dir\all_ah_t.sql
    so that i form a temporary view for this script as a table(or store the result in a temp table) and my problem will be solved..Sorry, I don't understand. What is a "temporary view"?

  • Copy all the objects from the one system that start with (ZANK)

    hi to all,
    I have installed the name space /ank/ in the US system, we need to copy all the objects from the India system that start with (Zank) and re-create them as /ank/. problem is how can i copy objects and re-create.
    thanks

    Hi Ankal,
    I guess this is your second thread on the same question. Ok provide these information
    >>I have installed the name space /ank/ in the US system,
    Are you saying that you have a machine (US System) and i has a namespace /ank/ ? What all objects are there in this namespace?
    >>we need to copy all the objects from the India system that start with (Zank) and re-create them as /ank/.
    Is the India system on the same US system?
    Also tell me whether you have opened the home page of SAP XI/PI?  If yes , are you able to open Integration Repository? If yes then how these US and India systems are referred in Integration Repository? Are they referred as separate software components?
    Regards
    Suraj

  • I have an iMac, an iPhone, and a MacBook Pro.  My full iTunes library is on the iMac and iPhone, but only a handful of songs are on my MacBook.  They are all associated with the same Apple ID.  How do I get all of my music on the laptop?

    I have an iMac, an iPhone, and a MacBook Pro.  My full iTunes library is on the iMac and iPhone, but only a handful of songs are on my MacBook.  They are all associated with the same Apple ID.  When I try to sync, I get a warning message stating that I will lose songs on my phone which aren't on the laptop.  How transfer my music from my phone to the laptop?

    Hey kbert73
    I would do a transfer of purchases from the phone and not sync. If you sync then it will want to start over and sync music that is on the MacBook Pro. If you want to transfer the music, check out the article below that will give you multiple options on how to move. I have also provided on how to sync with multiple computers.
    iTunes: How to move your music to a new computer
    http://support.apple.com/kb/ht4527
    Using iPhone, iPad, or iPod with multiple computers
    http://support.apple.com/kb/ht1202
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

Maybe you are looking for

  • Caught in the Adobe information labyrinth and unable to find my way out

    I am a native English speaker and live in France. (Already, I prefer English but in Adobe's zeal for optimization, they impose the use of French, or an additional ten minutes of research time to find how and where to customize the language interface.

  • Best practice for making form read-only at certain steps in process?

    I have a process with a single form and 4 Assign Task operations.  During Assign Task operations 1 and 3, the form is edited.  During Assign Task operation 2 and 4, it should be read-only (it is reviewed and acknowledged, but not changed).   There is

  • Display Detection

    I am trying to connect my 2008 unibody MacBook Pro to a Sony Bravia 1080p TV with a Monoprice minidisplay to HDMI cable. Plug it in, nothing happens. Go to display preferences, click Detect Displays and Gather Windows, a display pref window pops up w

  • Not show the header on the first page of a section

    I am writing a manual that has about 7 chapters. Each chapter is its own section. I have been able to go in and create a header for each of these sections very easily. However, it's not quite clear how to NOT show the header on the first page of the

  • How to set database name default for oracle discoverer 10g

    Hi Do you have idea of setting the database name default for oracle discoverer 10g