how to creat .mdf and .mdl files from live DB? - sql-server

I am very new to SQL and I want to update a table on a new site of mine with older live DB costing table. I have read that i need the .mdf and .ldf files from the live Db, but i have no idea how to create or get them? Please advice on this problem.
regards

If you're using SQL Server then what you need to know is how to Backup and Restore a database.
The following tutorials will explain how each is done.
Backup Tutorial
Restore Tutorial

Related

Database Migration Approach

I have a few databases that I want to migrate to another server. These are production Databases, what is the best way to Migrate
1) Take full back up of the Current Databse and then Restore it on to the other Server.
or
2) Detach and then Copy the mdf/ldf files on the Destination Server and then attach the files there.
I know that after Migrating Sql Logins and Sql Agent Jobs will have to be created manually. Are there any other risks that come to mind?
Any help will be helpful.
Thanks,
Ben
For Login transfer use "sp_help_revlogin" you get the script
https://support.microsoft.com/en-us/kb/918992
this Stored procedure list out all the instance login not particular database login. One special thing about this stored procedure is no need to do orphaned fix. Just migrate the logins and check. It works.

Retrieve database information from DBML files

I'm working on one project using ASP.Net 4.0 and SQL Server 2012. I have used DBML files for data access layer and Unfortunately, the database is got corrupted due to hard disk crash and not able to get the database.
Is it possible to retrieve the following things from DBML?
Tables (I didn't drag the tables into DBML before)
Stored procedures with body
Triggers
Help would be highly appreciated .
Thanks,
Dhaval
Short answer is no. If you have database backups you can restore these and get the details from there.
If you don’t have these but your database was in full recovery mode you can try to examine transaction log and see if you can get any info from there.
See this for more details
SQL Server Transaction Log Explorer/Analyzer

Attaching Database

I am very new to Sequel Server. For Practice, I created a Database where I imported some sample datasets (mostly excel files) via SSIS. The database consists of 6 tables. I was wondering if there is a way I can send the database (I created) via email or share it by any other way. Like Adventureworks was available for download and also for attaching to SQL SERVER, is there a way I can do the same for my practice database?
Thank you,
Regards,
Sourav
You can backup the database you created to a file and send it over to anyone. Right click on your database, Tasks -> Backup

How to restore a database from a backup in installshield

I'm using MSI Project with InstallShield 2010.
I have a .bak file, a backup of a SQL database (I am using SQL Server 2008 R2). How can I restore it using InstallShield?
I was looking in SQL Scripts tab and I didn't find anything about restoring backups.
Thanks for your time!
Technically you could use a SQL script to restore the .BAK file but this isn't really the best practice. What you are supposed to do is "script out" the database into one or many SQL files and execute those files to create your database during the install.
say suppose you have xyz.bak as a bakup and you want to restore it on to your sqlserver 2008r2 try running following query in ssms
Restore database DatabaseName from disk='path of your bak file'
this will restore your database.
In hopes of getting an answer to this thread's original question, let's say that building up the database via the "script out" approach would take way too long to perform at install-time.
Scripted out, the database I am working with takes ~90 min to get built up. Restoring a 1.6 GB compressed .bak takes ~90 sec.
I am interested in restoring a .bak as part of my IS2010 msi project. Currently CAs are used but a more elegant solution (especially one that can provide progress back to the user) would be more ideal.

Restore individual tables on Microsoft SQL Server 7?

is it possible to restore individual tables from a full backup file of Microsoft SQL Server 7 (yes, I know this is really old, but our client can't upgrade for various reasons).
The total backup file is about 180GB in size and restoring the whole database once a week to a development server is not pratical, as it takes several days (literally). But for development, we'd just need some tables out of this huge file.
Is it somehow possible to extract only the tables we need from the backup file?
Thanks in advance!
Best regards,
Martin
It's probably not quite what you're after, because I don't think what you're after is possible.
However you could place the tables in question into a different file group. Then when it comes to restoring, you need only restore the file group that relates to the tables.
File Groups in SQL SERVER
Not without 3rd party tools.. and I don't know of any off hand.
Or you export/import from prod the tables (or just new/changed data) you need
We have been using the Red Gate tools to transfer some tables between Db, and it works great. However, it's NOT free tool, you can download the 14-day demo to try it out.

Resources