Loading ...
Sorry, an error occurred while loading the content.
 

not able to attach the mdf file

Expand Messages
  • Arindam
    Hi All,   i am getting the follwoing error after chaning the mdf file location .. can u please tell me what would be the solution ?     TITLE: Microsoft SQL
    Message 1 of 6 , Dec 6, 2010
      Hi All,
       
      i am getting the follwoing error after chaning the mdf file location .. can u please tell me what would be the solution ?
       

       



      TITLE: Microsoft SQL Server Management Studio Express
      ------------------------------
      Attach database failed for Server 'ETG1\SQLEXPRESS'.  (Microsoft.SqlServer.Express.Smo)
      For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.2047.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476
      ------------------------------
      ADDITIONAL INFORMATION:
      An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)
      ------------------------------
      Unable to open the physical file "G:\Projects\ETG.DB\HRRPMS.mdf". Operating system error 5: "5(error not found)". (Microsoft SQL Server, Error: 5120)
      For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.4053&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476
      ------------------------------
      BUTTONS:
      OK
      ------------------------------




      [Non-text portions of this message have been removed]
    • Joe Fawcett
      That can often be permissions based, Are you running the management studio as administrator (right click on shortcut to open)? Joe ... [Non-text portions of
      Message 2 of 6 , Dec 7, 2010
        That can often be permissions based, Are you running the management studio
        as administrator (right click on shortcut to open)?

        Joe

        On 6 December 2010 15:58, Arindam <e_arindam@...> wrote:

        >
        >
        > Hi All,
        >
        > i am getting the follwoing error after chaning the mdf file location .. can
        > u please tell me what would be the solution ?
        >
        >
        >
        >
        > TITLE: Microsoft SQL Server Management Studio Express
        > ------------------------------
        > Attach database failed for Server 'ETG1\SQLEXPRESS'.
        > (Microsoft.SqlServer.Express.Smo)
        > For help, click:
        > http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.2047.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476
        > ------------------------------
        > ADDITIONAL INFORMATION:
        > An exception occurred while executing a Transact-SQL statement or batch.
        > (Microsoft.SqlServer.Express.ConnectionInfo)
        > ------------------------------
        > Unable to open the physical file "G:\Projects\ETG.DB\HRRPMS.mdf". Operating
        > system error 5: "5(error not found)". (Microsoft SQL Server, Error: 5120)
        > For help, click:
        > http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.4053&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476
        > ------------------------------
        > BUTTONS:
        > OK
        > ------------------------------
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >


        [Non-text portions of this message have been removed]
      • Noman Aftab
        Hi, is it possible to infer primary key column name from table name in SQL Server using sysobjects and syscolumn tables? Assuming there is only column in a
        Message 3 of 6 , Dec 9, 2010
          Hi,
          is it possible to infer primary key column name from table name in SQL Server
          using sysobjects and syscolumn tables?
          Assuming there is only column in a primary key. I am using SQL Server 2005.
          Best Wishes,
          Noman Aftab


          http://www.corpus.quran.com/wordbyword.jsp
          http://www.jalandhari.qsh.eu



          [Non-text portions of this message have been removed]
        • Paul Livengood
          Try this SELECTTable_Name =OBJECT_NAME(c.Object_id),In_Key =CASEWHENkeys.Column_Name ISNOTNULLTHEN Yes ELSE No END,Column_Name =c.name
          Message 4 of 6 , Dec 9, 2010
            Try this

            SELECTTable_Name =OBJECT_NAME(c.Object_id),In_Key =CASEWHENkeys.Column_Name
            ISNOTNULLTHEN'Yes'ELSE'No'END,Column_Name =c.name
            ,Type_Name=UPPER(t.name+CASEWHENt.name IN('VARCHAR','NVARCHAR')ANDc.Max_Length
            =-1 THEN'(MAX)'WHENt.name IN('NCHAR','NVARCHAR')THEN'('+RTRIM(c.Max_Length
            /2)+')'WHENt.name IN('CHAR','VARCHAR')THEN'('+RTRIM(c.Max_Length)+')'WHENt.name
            IN('NUMERIC','DECIMAL')THEN'('+RTRIM(c.precision)+','+RTRIM(c.scale)+')'ELSE''END+CASEc.is_identityWHEN1
            THEN' -- IDENTITY'ELSE''END),Allows_Nulls =CASEc.is_nullableWHEN1
            THEN'Yes'ELSE'No'END,Foreign_Key =COALESCE(fkeys.Ref_Table_Name
            +'.'+fkeys.Ref_Column_Name,'')FROMsys.columnscINNERJOINsys.typest
            ONc.system_type_id =t.system_type_idANDt.name !='SYSNAME'INNERJOINsys.tablestb
            ONc.object_id=tb.object_idLEFTOUTERJOIN(SELECTTable_Name
            =OBJECT_NAME(t.object_id),Column_Name =c.nameFROMsys.index_columnsic
            WITH(NOLOCK)INNERJOINsys.indexesi WITH(NOLOCK)ONic.index_id
            =i.index_idANDi.object_id=ic.object_idINNERJOINsys.tablest
            WITH(NOLOCK)ONi.object_id=t.object_idINNERJOINsys.key_constraintsk
            WITH(NOLOCK)ONk.name =i.nameANDk.type ='PK'INNERJOINsys.columnsc
            WITH(NOLOCK)ONc.Object_id=t.object_idANDc.column_id =ic.column_id)keys
            ONkeys.Column_Name =c.NameANDkeys.Table_Name
            =tb.NameLEFTOUTERJOIN(SELECTTable_Name
            =OBJECT_NAME(k.Parent_Object_ID),Column_Name =c1.name ,Ref_Table_Name
            =OBJECT_NAME(k.Referenced_Object_ID),Ref_Column_Name
            =c2.nameFROMsys.foreign_keysk WITH(NOLOCK)INNERJOINsys.foreign_key_columnskc
            WITH(NOLOCK)ONk.object_id=kc.constraint_object_idINNERJOINsys.columnsc1
            WITH(NOLOCK)ONc1.object_id=kc.parent_object_idANDkc.parent_column_id
            =c1.column_idINNERJOINsys.columnsc2
            WITH(NOLOCK)ONc2.object_id=kc.referenced_object_idANDkc.referenced_column_id
            =c2.column_id)fkeys ONfkeys.Column_Name =c.NameANDfkeys.Table_Name
            =tb.NameORDERBYOBJECT_NAME(c.object_id),c.column_id ;




            ________________________________
            From: Noman Aftab <noman17pk@...>
            To: SQLQueriesNoCode@yahoogroups.com
            Sent: Thu, December 9, 2010 11:52:02 AM
            Subject: [SQLQueriesNoCode] Infer PK column name from table name

             
            Hi,
            is it possible to infer primary key column name from table name in SQL Server
            using sysobjects and syscolumn tables?
            Assuming there is only column in a primary key. I am using SQL Server 2005.
            Best Wishes,
            Noman Aftab

            http://www.corpus.quran.com/wordbyword.jsp
            http://www.jalandhari.qsh.eu

            [Non-text portions of this message have been removed]




            [Non-text portions of this message have been removed]
          • Noman Aftab
            Thanks Paul, quite a huge text, but worth it. My main interest was in the following sub-query: SELECT Table_Name =OBJECT_NAME(t.object_id),Column_Name =c.name
            Message 5 of 6 , Dec 9, 2010
              Thanks Paul,
              quite a huge text, but worth it.

              My main interest was in the following sub-query:


              SELECT Table_Name
              =OBJECT_NAME(t.object_id),Column_Name =c.name FROM sys.index_columns ic
              WITH(NOLOCK)INNER JOIN sys.indexes i WITH(NOLOCK)ON ic.index_id
              =i.index_id AND i.object_id=ic.object_id INNER JOIN sys.tables t
              WITH(NOLOCK)ON i.object_id=t.object_id INNER JOIN sys.key_constraints k
              WITH(NOLOCK)ON k.name =i.name AND k.type ='PK'INNER JOIN sys.columns c
              WITH(NOLOCK) ON c.Object_id=t.object_id AND c.column_id =ic.column_id

              referred as "keys" in your query.

              Thanks again.
              Best Wishes,
              Noman Aftab


              http://www.corpus.quran.com/wordbyword.jsp
              http://www.jalandhari.qsh.eu





              ________________________________
              From: Paul Livengood <p_livengood@...>
              To: SQLQueriesNoCode@yahoogroups.com
              Sent: Fri, 10 December, 2010 2:30:36 AM
              Subject: Re: [SQLQueriesNoCode] Infer PK column name from table name


              Try this

              SELECTTable_Name =OBJECT_NAME(c.Object_id),In_Key =CASEWHENkeys.Column_Name
              ISNOTNULLTHEN'Yes'ELSE'No'END,Column_Name =c.name
              ,Type_Name=UPPER(t.name+CASEWHENt.name IN('VARCHAR','NVARCHAR')ANDc.Max_Length
              =-1 THEN'(MAX)'WHENt.name IN('NCHAR','NVARCHAR')THEN'('+RTRIM(c.Max_Length
              /2)+')'WHENt.name IN('CHAR','VARCHAR')THEN'('+RTRIM(c.Max_Length)+')'WHENt.name
              IN('NUMERIC','DECIMAL')THEN'('+RTRIM(c.precision)+','+RTRIM(c.scale)+')'ELSE''END+CASEc.is_identityWHEN1


              THEN' -- IDENTITY'ELSE''END),Allows_Nulls =CASEc.is_nullableWHEN1
              THEN'Yes'ELSE'No'END,Foreign_Key =COALESCE(fkeys.Ref_Table_Name
              +'.'+fkeys.Ref_Column_Name,'')FROMsys.columnscINNERJOINsys.typest
              ONc.system_type_id =t.system_type_idANDt.name !='SYSNAME'INNERJOINsys.tablestb
              ONc.object_id=tb.object_idLEFTOUTERJOIN(SELECTTable_Name
              =OBJECT_NAME(t.object_id),Column_Name =c.nameFROMsys.index_columnsic
              WITH(NOLOCK)INNERJOINsys.indexesi WITH(NOLOCK)ONic.index_id
              =i.index_idANDi.object_id=ic.object_idINNERJOINsys.tablest
              WITH(NOLOCK)ONi.object_id=t.object_idINNERJOINsys.key_constraintsk
              WITH(NOLOCK)ONk.name =i.nameANDk.type ='PK'INNERJOINsys.columnsc
              WITH(NOLOCK)ONc.Object_id=t.object_idANDc.column_id =ic.column_id)keys
              ONkeys.Column_Name =c.NameANDkeys.Table_Name
              =tb.NameLEFTOUTERJOIN(SELECTTable_Name
              =OBJECT_NAME(k.Parent_Object_ID),Column_Name =c1.name ,Ref_Table_Name
              =OBJECT_NAME(k.Referenced_Object_ID),Ref_Column_Name
              =c2.nameFROMsys.foreign_keysk WITH(NOLOCK)INNERJOINsys.foreign_key_columnskc
              WITH(NOLOCK)ONk.object_id=kc.constraint_object_idINNERJOINsys.columnsc1
              WITH(NOLOCK)ONc1.object_id=kc.parent_object_idANDkc.parent_column_id
              =c1.column_idINNERJOINsys.columnsc2
              WITH(NOLOCK)ONc2.object_id=kc.referenced_object_idANDkc.referenced_column_id
              =c2.column_id)fkeys ONfkeys.Column_Name =c.NameANDfkeys.Table_Name
              =tb.NameORDERBYOBJECT_NAME(c.object_id),c.column_id ;

              ________________________________
              From: Noman Aftab <noman17pk@...>
              To: SQLQueriesNoCode@yahoogroups.com
              Sent: Thu, December 9, 2010 11:52:02 AM
              Subject: [SQLQueriesNoCode] Infer PK column name from table name


              Hi,
              is it possible to infer primary key column name from table name in SQL Server
              using sysobjects and syscolumn tables?
              Assuming there is only column in a primary key. I am using SQL Server 2005.
              Best Wishes,
              Noman Aftab

              http://www.corpus.quran.com/wordbyword.jsp
              http://www.jalandhari.qsh.eu

              [Non-text portions of this message have been removed]

              [Non-text portions of this message have been removed]
            • Shadab Mustafa
              I hope this works fine for your requirement. SELECT i.name AS IndexName, OBJECT_NAME(ic.OBJECT_ID) AS TableName, COL_NAME(ic.OBJECT_ID,ic.column_id) AS
              Message 6 of 6 , Dec 9, 2010
                I hope this works fine for your requirement.

                SELECT i.name AS IndexName,
                OBJECT_NAME(ic.OBJECT_ID) AS TableName,
                COL_NAME(ic.OBJECT_ID,ic.column_id) AS ColumnName
                FROM sys.indexes AS i
                INNER JOIN sys.index_columns AS ic
                ON i.OBJECT_ID = ic.OBJECT_ID
                AND i.index_id = ic.index_id
                WHERE i.is_primary_key = 1

                Regards,
                Shadab Mustafa
                Sr. Software Engineer
                shadab.mustafa@...: +92-21-567 5240 – 42 (709)
                : +92-21-567 5244
                : +92-321-207 9443
                http://www.avanzasolutions.com




                ________________________________
                From: Noman Aftab <noman17pk@...>
                To: SQLQueriesNoCode@yahoogroups.com
                Sent: Thu, December 9, 2010 11:52:02 PM
                Subject: [SQLQueriesNoCode] Infer PK column name from table name


                Hi,
                is it possible to infer primary key column name from table name in SQL Server
                using sysobjects and syscolumn tables?
                Assuming there is only column in a primary key. I am using SQL Server 2005.
                Best Wishes,
                Noman Aftab

                http://www.corpus.quran.com/wordbyword.jsp
                http://www.jalandhari.qsh.eu

                [Non-text portions of this message have been removed]







                [Non-text portions of this message have been removed]
              Your message has been successfully submitted and would be delivered to recipients shortly.