Is it possible to create a copy of entire database, not the data, but just database structure?

Greetings community,
This question is related to EXPRESS edition.
Let’s say that I have MyDatabase2014 and I’ve been populating it with some data during the year 2014. Before the end of the year, I want to prepare another database named MyDatabase2015, which should be empty, but of course it should have
all tables, relations, indexes and stored procedures just like MyDatabase2014. The idea is just to change a connection string and to continue using the same app for the same job.
So in SSMS, I right-clicked the database, choose script database as / create to / new query, but I didn’t get what I wanted. In query window I’ve got just create database statement, and below that few dozen of alter database set ansi this
or that statements, and set many other things. However, no table creation was scripted. Also, no stored procedures have been created, and about users, and other security objects better not to start to talk about.
I could have achieved that simply by right-clicking databases node and select new database. So what’s the point of “script database as”?
Does this work in SQL server editions other than EXPRESS?
When it comes to express edition, what’s the best practice to get the empty copy of a database?
Thanks for any help.

For scripting out the users and their permissions you can use this script
-- Capture permissions for all users in a DB
SET NOCOUNT ON
DECLARE @Database varchar(max)
SET @Database = '<Db_Name>'-- set the database name here
IF EXISTS (SELECT * FROM SYS.SYSDATABASES WHERE name = @Database)
EXEC('USE ' + @Database + ';
DECLARE @temp table(Extract Varchar(MAX))
INSERT INTO @temp (Extract)
SELECT ''EXEC( ''''USE ' + @Database + '; IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = N'''''''''' + name + '''''''''')IF EXISTS (SELECT *
FROM sys.database_principals WHERE name = N'''''''''' + name + '''''''''') DROP USER ['' + name + '']''''); ''
FROM sys.sysusers WHERE islogin = 1 AND hasdbaccess = 1 AND name NOT IN (''dbo'')
INSERT INTO @temp (Extract)
SELECT ''EXEC( ''''USE ' + @Database + '; IF NOT EXISTS
(SELECT * FROM sys.database_principals WHERE name = N'''''''''' + dp.name + '''''''''')
CREATE USER ['' + dp.name + ''] FOR LOGIN ['' + sp.name + '']''''); ''
FROM sys.server_principals sp
JOIN sys.database_principals dp ON (sp.sid = dp.sid)
AND dp.name NOT IN (''dbo'')
INSERT INTO @temp (Extract)
SELECT ''EXEC( ''''USE ' + @Database + '; IF NOT EXISTS
(SELECT * FROM sys.database_principals WHERE name = N'''''''''' + dp.name + '''''''''')
CREATE USER ['' + dp.name + ''] WITHOUT LOGIN ''''); ''
FROM sys.database_principals dp left
JOIN sys.server_principals sp ON (sp.sid = dp.sid)
where dp.principal_id between 5 and 16383
INSERT INTO @temp (Extract)
SELECT ''EXEC( ''''USE ' + @Database + '; EXEC sp_addrolemember '''''''''' + User_Name([groupuid]) + '''''''''', '''''''''' + User_Name([memberuid]) +
FROM sys.sysmembers WHERE User_Name([memberuid]) NOT IN (''dbo'')
INSERT INTO @temp (Extract)
SELECT ''EXEC( ''''USE ' + @Database + '; ''
+ CASE [a].[state_desc] WHEN ''GRANT_WITH_GRANT_OPTION'' THEN ''GRANT '' ELSE [a].[state_desc] END
+ '' ''
+ [a].[permission_name] + CASE class WHEN 1 THEN '' ON [''
+ [c].[name]
+ ''].[''
+ Object_Name([a].[major_id]) + ''] '' ELSE '''' END + '' TO [''
+ User_Name([a].[grantee_principal_id])
+ ''] '' + CASE [a].[state_desc] WHEN ''GRANT_WITH_GRANT_OPTION'' THEN '' WITH GRANT OPTION'' ELSE '''' END
+ ''''''); '' COLLATE Latin1_General_CI_AS AS [SQL]
FROM sys.database_permissions a
inner join [sys].[all_objects] b
ON [a].[major_id] = [b].[object_id]
inner join [sys].[schemas] c
ON [b].[schema_id] = [c].[schema_id]
INSERT INTO @temp (Extract)
SELECT ''EXEC( ''''USE ' + @Database + '; ''
+ [a].[state_desc]
+ '' ''
+ [a].[permission_name]
+ '' TO [''
+ USER_NAME([a].[grantee_principal_id])
+ ''] '''');''
from sys.database_permissions a
where a.class=0
INSERT INTO @temp (Extract)
SELECT ''EXEC( ''''USE ' + @Database + '; ''
+ [a].[state_desc]
+ '' ''
+ [a].[permission_name]
+ '' ON SCHEMA ::''
+ '' [''
+ SCHEMA_NAME([a].[major_id]) +
+ ''] TO [''
+ USER_NAME([a].[grantee_principal_id])
+ ''] '''');''
from sys.database_permissions a
where a.class=3
SELECT Extract AS [Extract] FROM @temp
GO
ELSE
SELECT '--NO'
GO
 

Similar Messages

  • Having problems uploading an album to create a book.  iPhoto will compile the data, but fails to upload. Error message allows a "Retry", but its a dead end.  (iPhoto 11)

    I can't get iPhoto 11 to accept my album to create a book.  Compiles OK, but bombs out when uploading.  I have tried Safe Mode and eliminating Energy Saver. I have pulled out the Preference file and re-inserted after logging back in, but nothing seems to work.  This problem seems pretty prevalent, since it keeps coming up in discussion groups.  I had the same problem with iPhoto 6, and hoped that it would have been cured by now, but apparently not.  I guess Apple likes to collect $49 from each caller to give out the proper solution.  Help!
    Andy in Spring

    OK - so I have tried deleting my iPhoto preferences, repairing my keychain, rebuilding my iPhoto library, uninstalling Safari Beta 4 and I still can't get this one photo album (that has 140 videos) to upload properly to MobileMe. I left it to upload when I went to bed and when I woke up, I saw that my iPhoto quit itself yet again. So again, if there was an error message, I missed it. Before I left for work, I started an upload of an album of just photos to see if that works, thinking that perhaps there's a video in the other album that iPhoto is getting stuck on. If that works, I suppose I could try uploading the videos one at a time, right? Just keep adding them to the Gallery till something fails? If I find that the album of photos failed, then I think my only choice will be to pay $49 for AppleCare's assistance. I love how one solution they already gave me (for free) is to purchase a new laptop. Yeah, that would solve it! LOL

  • Is it possible to create a DVD in iDVD without using the themes they provide?

    Is it possible to create a DVD in iDVD without using the themes they provide?

    Hi
    No Menu DVD
    from. Mishmunken
    How to create a DVD in iDVD6 without menu (there are several options)
    1. Easy. Drop your iMovie in the auto-play box in iDVD's Map View, then set your auto-play item (your movie) to loop continuously.
    Disadvantage. The DVD plays until you hit stop on the remote
    2. Still easy. If you don't want your (auto-play) movie to loop, you can create a black theme by replacing the background of a static theme with a black background and no content in the drop-zone (text needs to be black as well).
    Disadvantage. The menu is still there and will play after the movie. You don't see it, but your disc keeps spinning in the player.
    3. Still quite easy but takes more time. Export the iMovie to DV tape, and then re-import using One-Step DVD.
    Disadvantage. One-Step DVD creation has been known to be not 100% reliable.
    4. (My preferred method) Easy enough but needs 3rd party software. Toast lets you burn your iMovie to DVD without menu - just drag the iMovie project to the Toast Window and click burn.
    Disadvantage. you'll need to spend some extra $$ for the software. In Toast, you just drop the iMovie project on the Window and click Burn.
    5. The "hard way". Post-production with myDVDedit (free-ware)
    Tools necessary. myDVDedit ( www.mydvdedit.com )
    • create a disc image of your iDVD project, then double-click to mount it.
    • Extract the VIDEO_TS and AUDIO_TS folders to a location of your choice. select the VIDEO_TS folder and hit Cmd + I to open the Inspector window
    • Set permissions to "read & write" and include all enclosed items; Ignore the warning.
    • Open the VIDEO_TS folder with myDVDedit. You'll find all items enclosed in your DVD in the left hand panel.
    • Select the menu (usually named VTS Menu) and delete it
    • Choose from the menu File > Test with DVD Player to see if your DVD behaves as planned. If it works save and close myDVDedit.
    • Before burning the folders to Video DVD, set permissions back to "read only", then create a disc image burnable with Disc Utility from a VIDEO_TS folder using Laine D. Lee's DVD Imager.
    //lonestar.utsa.edu/llee/applescript/dvdimager.html
    hope this helps!
    From LynnLU USA
    www.mediasoftmac.com/dvd-creator-articles/convert-mov-video-to-dvd-on-mac.html#1 29
    Yours Bengt W

  • I can't import any photos. 'Could not copy to requested location' is the given but i have tried importing to both hard drive and external drive.

    i can't import any photos. 'Could not copy to requested location' is the given but i have tried importing to both hard drive and external drive. Help please ?

    Most likely, the "requested location" where you are trying to copy files to does not have WRITE permission, and so you need to change the permissions.

  • If I have an EntityBean that mappes to two tables within one database, when I create that EJB, whoes reponsibilty to generate the primary key in database table? The RDBMS or EJB?

    If I have an EntityBean that mappes to two tables within one database, when I create
    that EJB, whoes reponsibilty to generate the primary key in database table? The
    RDBMS or EJB?
    Thanks,
    JW

    Refer to http://e-docs.bea.com/wls/docs81/faq/ejb.html/#257430
    "Jingwei Zhang" <[email protected]> wrote:
    >
    If I have an EntityBean that mappes to two tables within one database,
    when I create
    that EJB, whoes reponsibilty to generate the primary key in database
    table? The
    RDBMS or EJB?
    Thanks,
    JW

  • How to copy the data from one database to another database without DB link

    Good Day,
    I want to copy the data from one database to another database with out DB link but the structure is same in both.
    Thanks
    Nihar

    You could use SQL*Plus' COPY command
    http://technology.amis.nl/blog/432/little-gold-nugget-sqlplus-copy-command
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/apb.htm#sthref3702
    Edited by: Alex Nuijten on Sep 16, 2009 8:13 AM

  • I have a Samsung Convoy "dumb" phone, and I plan to keep it until Verizon forces me to some **** overpriced "smart" phone.  Since they migrated Backup Assistant to "the Cloud", I am unable to print a hard copy list of contacts. The web site just runs you

    I have a Samsung Convoy "dumb" phone, and I plan to keep it until Verizon forces me to some **** overpriced "smart" phone.  Since they migrated Backup Assistant to "the Cloud", I am unable to print a hard copy list of contacts. The web site just runs you around in circles, never getting to the answer of how to print out contacts.  I'm sure the marketing people and web creators just love this Frankenstein monster they have built, but for me and my phone, it's just a huge pain in the ***!  Do they plan to fix this, or just let us dinosaurs go away and die?

    there is a point : no workie
    how hard would it be to place my (or yours I am told) iPhone4S on a city block curb………..
    and just walk away.. .. ..

  • Help Please!  I've created a slideshow in iPhoto 09 and the first song just repeats 50 seconds into it.  How do I get the song to continue?

    I've created a slideshow in iPhoto 09 and the first song just repeats 50 seconds into it.  How do I get the song to continue?

    With iPhoto open click Help from the iPhoto menu bar top of your screen. From the drop down menu click iPhoto Help.
    Type slideshow music  in the search field top right corner of that window.
    You should see:   To add music to a slideshow    instructions.

  • Is it possible to create a copy cube from business content cube

    Dear Experts,
    I have to  create the new cubes which is a copy of Business content statistics cubes .
    Request you to let me know how can i create a copy cube from Business content cube. My doubt is,weather is't the same as normal customized cube creation by giving copy from option.....
    Thanks in advance for your valuable assistance.
    Regards,
    Ramesh - Kumar.

    for copying the cube whose copy is to be made should be available in infoprovider tab in modelling of RSA1.
    first you have to install the business content cube ,so that it is found in the Info-providers tab in modelling .
    for that,first go to business content option found in the modelling tab of t-code RSA1 .
    find the cube and transfer it to the right and execute . It will be available in infoprovider tab of modelling .
    then you can create a copy as we do normally .

  • Is it possible to create a form that allows users to import data from an excel spreadsheet

    I have not been able to start my reading on scripting or other livecycle features to be able to try to figure this out but I was wondering if anyone else had ever created a form with this feature or had any ideas of how it would be possible.  Our company currently uses and excel form that would have a variable number of rows of data for each time it is filled out and we would be replacing it with an adobe form.  I would like to know if the users, who will be using the new adobe form in adobe reader, could have the capability to imort the lines from the previous excel form into the new adobe version.

    Hi,
    You can set up a data connection with an Excel spreadsheet. However for the data connection to work for users with Reader, you would need to Reader Enable the form with the LiveCycle Reader Extensions ES2.5 (server component). See here for summary: http://assure.ly/etkFNU.
    However if you are just trying to get the existing data into the form, you should have a look at some of Stefan Cameron's posts: http://forms.stefcameron.com/ (try a search). You can start a new form using the wizzard and select import from Excel. This will allow you to paste from your spreadsheet to a new form. This should help set up the data structure/schema, which you can then replicate in a new form. I haven't done this before, but it should be possible.
    Hope that helps,
    Niall

  • Is it possible to create a book in size other than the presets? [was:Books]

    Is it possible to cerate a book in size other than the presets? If so, where do I go to enter my own dimensions?

    Create your design on one or more  master slides:    View > Edit Master Slide
    delete unwanted master
    then save as a Theme:    File > Save Theme
    Save as;  is achieved by pressing the option key then File > Save as...

  • Is it possible to create Qt Widgets inside After Effects using the SDK?

    Hi,
    I would like to use Qt to create Dialogs and Widgets inside AfterEffects.
    I started out with the Panelator example in the SDK. I can include QtGui into the project, but as soon as I create any object with QObject as a base-class After Effects crashes immediately with the following error: '[...] could not be loaded (48::46)'
    When I try delay load QtCore.dll and QtGui.dll I can at least start the plugin and see, that the crash happens in the initializer of the QObject.
    I use
    VS 2010
    QT 4.8.5
    and my buildenvironment is x64
    I was wondering if there is any kind of incompatibility of embedding Qt in After Effects (due to linker/compiler setting or defines or something like this).
    This is the debugger output:
    Locals:
    Threads:
    My code in the Panel-constructor function:
        int argc = 0;
        char *argv[1] = {""};
        QApplication* a = new QApplication(argc, argv); // THE ERROR OCCURS IN THIS LINE. for a test I exchanged it to QWidget* w = new QWidget(); and it happens as well.
        QWidget* w = new QWidget();
        w->show();
        a->exec();
    Outside of AfterFX Qt works fine and I also can delay-load QtGui and QtCore.
    If anyone of you already has experience in using QT in AfterEffects, I would really appreciate your help!
    Thanks in advance.

    It finds QtGui and QtCore, it misses out some other dependencies further down in the hierarchy of USER32.DLL:
    Which doesn't seem to disturb if I don't include and use QT:

  • Copy database structure but not the data

    I'm looking to create a new version of a database but with completely reloaded data - so I want to retain the database structure but none of the data.
    Is there an easy way (read: without a DBA on staff) to copy an existing database structure - preferably with views and stored procedures - and not take the data along for the ride?
    Thanks in advance for suggestions...!

    My mistake Judith.
    Using Object Explorer, [Right Click] on the database,
    Select [Tasks],
    Then [Generate Scripts...]
    On the first screen, check the 'Script all objects' checkbox.
    You can either save to a file or into a window. When the scripts are finished, go to the top and change the name of the database, then run the scripts.
    That 'should' get you what you want.

  • Do we have option not to refresh the data in AP invoice while copying from GRN and change the date of the invoice in SAP 9 PL 0

    Hi
    I have update tax details in GRPO but while copy to AP invoice system pick posting date/ document date as system date and if i change the date the screen refresh and the tax details i have updated it change. that i do not want.
    Is there any option so that GRPO date will copy in ap invoice so that i need not to refresh the screen
    regards
    Ashish Garg 

    Hi,
    Please provide an example for tax details. Make note on these,
    1. Whenever copy GRPO to AP invoice, posting and document date is system date. This is default design system
    2. If you change these dates in AP invoice, your payment to vendor leads to confusion.
    For example:
    You have received items on 25-03-2014. But vendor raised invoice on 03/04/2014.
    Thanks & Regards,
    Nagarajan

  • How to create a procedure in oracle to write the data into file

    Hi All,
    I am just wondered on how to create a procedure which will do following tasks:
    1. Concat the field names
    2. Union all the particular fields
    3. Convert the date field into IST
    4. Prepare the statement
    5. write the data into a file
    Basically what I am trying to achieve is to convert one mysql proc to oracle. MySQL Proc is as follows:
    DELIMITER $$
    USE `jioworld`$$
    DROP PROCEDURE IF EXISTS `usersReport`$$
    CREATE DEFINER=`root`@`%` PROCEDURE `usersReport`(IN pathFile VARCHAR(255),IN startDate TIMESTAMP,IN endDate TIMESTAMP )
    BEGIN
    SET @a= CONCAT("(SELECT 'User ID','Account ID','Gender','Birthdate','Account Registered On') UNION ALL (SELECT IFNULL(a.riluid,''),IFNULL(a.rilaccountid,''),IFNULL(a.gender,''),IFNULL(a.birthdate,''),IFNULL(CONVERT_TZ(a.creationDate,'+0:00','+5:30'),'') INTO OUTFILE '",pathFile,"' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\n' FROM account_ a where a.creationDate>='",startDate,"' and a.creationdate <='",endDate,"')");
    PREPARE stmt FROM @a;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt ;
    END$$
    DELIMITER ;
    Regards,
    Vishal G

    1. Concat the field names
    Double Pipe (||) is the concatenation operator in Oracle. There is also a function CONCAT for this purpose
    2. Union all the particular fields
    Not sure what do you mean by UNION ALL particular fields? UNION ALL is a set operation applied on two different result sets that have the same projection.
    3. Convert the date field into IST
    SQL> select systimestamp "Default Time"
      2       , systimestamp at time zone 'Asia/Calcutta' "IST Time"
      3    from dual;
    Default Time                                       IST Time
    05-05-15 03:14:52.346099 AM -04:00                 05-05-15 12:44:52.346099 PM ASIA/CALCUTTA
    4. Prepare the statement
    What do you mean by prepare the statement?
    5. write the data into a file
    You can use the API UTL_FILE to write to a file.

Maybe you are looking for