Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 908
  • Last Modified:

how can i import mdf file into sql server 2008 ??

suppose i have data.mdf file then how can i import into sql server 2008 using query or stored procedure ??

Give me some suggestions ...
0
Parth48
Asked:
Parth48
  • 3
  • 2
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you cannot "import" data from a .mdf.
the only thing you can do is attach the file as database (presuming it's the full database) using sp_attach_db procedure.

if the source database had other files (apart from the .ldf files), you cannot attach it alone.
0
 
Parth48Author Commented:
hi @angelll: u r right but how can use it ?

use question_assistant

EXEC sp_attach_db @dbname = N'AdventureWorks2008R2', 
    @filename1 = N'C:\Documents and Settings\Administrator\Desktop\Data\AdventureWorksLT2008_Data.mdf', 
    @filename2 = N'C:\Documents and Settings\Administrator\Desktop\Data\AdventureWorksLT2008_Log.ldf';

Open in new window


but i got error in above code ....


Msg 1813, Level 16, State 2, Line 1
Could not open new database 'AdventureWorks2008R2'. CREATE DATABASE is aborted.
Msg 948, Level 20, State 1, Line 1
The database 'AdventureWorks2008R2' cannot be opened because it is version 655. This server supports version 654 and earlier. A downgrade path is not supported.


what can i do now ??
0
 
geek_vjCommented:
>>The database 'AdventureWorks2008R2' cannot be opened because it is version 655. This server supports version 654 and earlier. A downgrade path is not supported.

This cant be done as downgrading is not possible in sql server.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you cannot attach that .mdf file on your database, as it is "older" than the version you want to restore from.
options:
* restore on a db with the correct version
* update your instance to that same version
0
 
Parth48Author Commented:
but where i can find 'AdventureWorks2008R2' version 654 ??

or how can i restore on a db with the correct version ??
0
 
Parth48Author Commented:
can u please tell me how can i create mdf file for my database ??
0
 
geek_vjCommented:
>> can u please tell me how can i create mdf file for my database ??
mdf file will be automatically created whenever you create a database. This file is usually called data file. Also, a file with extension .ldf will be created along with it which is called log file.

>>but where i can find 'AdventureWorks2008R2' version 654 ??
Please check in codeplex.com

>>or how can i restore on a db with the correct version ??
You have to download the correct version and restore it accordingly.

0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now