attaching to nerddinner.mdf using which ms sql?

Mar 27, 2012 at 10:17 AM
Edited Mar 27, 2012 at 2:15 PM

Hi Everyone!I

have downloaded nerddinner from the source code tab (http://nerddinner.codeplex.com/SourceControl/list/changesets)

I am now working with the "trunk folder version". I'm trying to script the content of the nerddinner.mdf to a file (in order to recreate the nerddinner database in  ms sql server 2008). However I keep having problem with attaching to the mdf file. I have tried using sql server 2008 and the R2 version and sql express 2008 sp 1, but Im getting a error regarding something with a backward compatibility. 

here is an error message for sql express sp1:


The database '...NERDDINNER.MDF' cannot be opened because it is version 661. This server supports version 655 and earlier. A downgrade path is not supported...

 

And here is an error with sql express sp2

The database '...NERDDINNER.MDF' cannot be opened because it is version 661. This server supports version 662 and earlier. A downgrade path is not supported.

 

Does anyone know what sql version has been used to create this mdf file? I supppose its sql express, but is it sp1, 2 or something else?

In short what type/version of MS SQL will I need in order to attach to nerddinner.mdf and create a sql script?

Ofcourse the best thing would be, if someone could just script the nerddinner.mdf file into a sql script, which users could use to create the database into whatever ms sql they wanted to. 

Mar 27, 2012 at 3:00 PM

Hi guys!

I have asked a db administrator at work about the issue and he managed to solve it. 

This is what has to be done. 

  1. Download and install SQL Express 2012
  2. Inside SQL Express 2012 server management studio; Attach to NerdDinner.mdf (just right-click on the Databases and choose Attach )
  3. After Attach: Click on the NerdDinner and choose: Tasks > Generate Scripts > Choose everything and make it show the generated script in Query Windows
  4. Now open sql server 2008 management studio (or any sql server), Stand on the Databases and open a new query windows and insert this script and run it. 
    use master;
    go
    CREATE database NerdDinner
    
     
  5.  Now the NerdDinner database has been created. Now you should be able to pick the NerdDinner database from a drop down list at the top of the management studio, choose NerdDinner, now open a new query windows and insert the following.
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE FUNCTION [dbo].[DistanceBetween] (@Lat1 as real,
                    @Long1 as real, @Lat2 as real, @Long2 as real)
    RETURNS real
    AS
    BEGIN
    
    DECLARE @dLat1InRad as float(53);
    SET @dLat1InRad = @Lat1 * (PI()/180.0);
    DECLARE @dLong1InRad as float(53);
    SET @dLong1InRad = @Long1 * (PI()/180.0);
    DECLARE @dLat2InRad as float(53);
    SET @dLat2InRad = @Lat2 * (PI()/180.0);
    DECLARE @dLong2InRad as float(53);
    SET @dLong2InRad = @Long2 * (PI()/180.0);
    
    DECLARE @dLongitude as float(53);
    SET @dLongitude = @dLong2InRad - @dLong1InRad;
    DECLARE @dLatitude as float(53);
    SET @dLatitude = @dLat2InRad - @dLat1InRad;
    /* Intermediate result a. */
    DECLARE @a as float(53);
    SET @a = SQUARE (SIN (@dLatitude / 2.0)) + COS (@dLat1InRad)
                     * COS (@dLat2InRad)
                     * SQUARE(SIN (@dLongitude / 2.0));
    /* Intermediate result c (great circle distance in Radians). */
    DECLARE @c as real;
    SET @c = 2.0 * ATN2 (SQRT (@a), SQRT (1.0 - @a));
    DECLARE @kEarthRadius as real;
    /* SET kEarthRadius = 3956.0 miles */
    SET @kEarthRadius = 6376.5;        /* kms */
    
    DECLARE @dDistance as real;
    SET @dDistance = @kEarthRadius * @c;
    return (@dDistance);
    END
    GO
    /****** Object:  Table [dbo].[Dinners]    Script Date: 03/27/2012 15:37:09 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Dinners](
    	[DinnerID] [int] IDENTITY(1,1) NOT NULL,
    	[Title] [nvarchar](50) NOT NULL,
    	[EventDate] [datetime] NOT NULL,
    	[Description] [nvarchar](256) NOT NULL,
    	[HostedById] [nvarchar](256) NULL,
    	[HostedBy] [nvarchar](256) NOT NULL,
    	[ContactPhone] [nvarchar](20) NOT NULL,
    	[Address] [nvarchar](50) NOT NULL,
    	[Country] [nvarchar](30) NOT NULL,
    	[Latitude] [float] NOT NULL,
    	[Longitude] [float] NOT NULL,
     CONSTRAINT [PK_Dinners] PRIMARY KEY CLUSTERED 
    (
    	[DinnerID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[RSVP](
    	[RsvpID] [int] IDENTITY(1,1) NOT NULL,
    	[DinnerID] [int] NOT NULL,
    	[AttendeeName] [nvarchar](256) NOT NULL,
    	[AttendeeNameId] [nvarchar](256) NULL,
     CONSTRAINT [PK_RSVP] PRIMARY KEY CLUSTERED 
    (
    	[RsvpID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE FUNCTION [dbo].[NearestDinners]
    	(
    	@lat real,
    	@long real
    	)
    RETURNS  TABLE
    AS
    	RETURN
    	SELECT     Dinners.DinnerID
    	FROM         Dinners 
    	WHERE dbo.DistanceBetween(@lat, @long, Latitude, Longitude) <100
    GO
    
    ALTER TABLE [dbo].[RSVP]  WITH CHECK ADD  CONSTRAINT [FK_RSVP_Dinners] FOREIGN KEY([DinnerID])
    REFERENCES [dbo].[Dinners] ([DinnerID])
    GO
    ALTER TABLE [dbo].[RSVP] CHECK CONSTRAINT [FK_RSVP_Dinners]
    GO
     
  6.  Now you should have a fully working sql server NerdDinner database 

     
Mar 27, 2012 at 8:11 PM

However!

I'm having problems connecting to the databases, NerdDinner.

If anyone figures it out, then please provide us with the details. 

Nov 3, 2012 at 2:48 PM

Did you figure this out?  I'm putting mine into SQL Server 2008 and and having issues connecting the project to the database, db in the project is null.

Nov 3, 2012 at 5:12 PM

Try sql server 2012 express. And then use tasks > export to file. Then go back to sql server 2008 and restore from file

Den 03/11/2012 14.48 skrev "scottskiblack" <notifications@codeplex.com>:

From: scottskiblack

Did you figure this out? I'm putting mine into SQL Server 2008 and and having issues connecting the project to the database, db in the project is null.

Read the full discussion online.

To add a post to this discussion, reply to this email (nerddinner@discussions.codeplex.com)

To start a new discussion for this project, email nerddinner@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com