SQL Server Error 9001 and auto close on Property

Hello,
  While talking to one of my application developers, he encountered Fatal Error 9001 while connecting to the database from .NET Application. In the past , he had similar issues and he mentioned that taking the database offline and bringing it back online
fixed the problem. So we did the same this and the problem got fixed.
I asked the question why are we having this problem in first place?.I used the SQL Credentials our .NET App uses and I was able to connect to the SQL Server using those credentials and execute the stored procedure. 
Doing some online searching, sometimes, turning on Auto close property causes this problem. This particular database had that property turned on and I turned it off. I am not sure how it got turned on in the first place. By default it should be off.
My question is Whats causing this behavior ?. How can I avoid getting 9001 Errors?.
I am tying to figure out the root cause and better undestand whats going on with the server?.
I understand the pros/cons of the auto close property but it shouldn't cause 9001 error.
Your help would be much appreciated.
My SQL Server Version:
select @@version
Microsoft SQL Server 2008 (SP3) - 10.0.5500.0 (X64) 
Sep 21 2011 22:45:45 
Copyright (c) 1988-2008 Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.0 <X64> (Build 6002: Service Pack 2)
Thanks,
I90Runner

Hi,
If you refer to
Microsoft definition of error 9001 it means Log for database is not available. Hope you are using English language
select text
from sys.messages
where message_id = 9001
and language_id=1033
Now why would SQL server say log for database is not available, it would say such thing when it wont be able to communicate with log file or wont be able to communicate with disk on which log file resides. I would say this might be disk issue. Not only SAN,
disk controllers, HBA and other connections which are involved between database and storage should be checked. Please immediately consult your vendor. At first it might seem all is fine but remember I said through check. I faced this issue in cluster and it
boiled down to Storage issue SQL server was just victim.
Reg AUTOCLOSE AFAIK by default it is true for express edition not fot other editions
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
My TechNet Wiki Articles

Similar Messages

  • Put some data form the databse of SQL Server into SAP and auto general PR?

    Dear all,
            Can you tell me how I can put some data from the databse of SQL Server into SAP and auto general PR?
    Best regards,
    Merryzhang
    Edited by: merry zhang on Feb 4, 2009 9:10 AM

    Hi Zhang,
    If i have understood your question properly, I guess you wanted to create Purchase Requistion automatically right?
    Then you have lots of option simpilest one would be create a couple of Z table with all the fields that you require for header and Item.
    create a Program and use BAPI function module to create the PR by reading the values from those Z tables. after creation delete the contents from the table. Schedule this program in Background periodically like everyday or weekly once however you would like it to be. So once the table has contents in it and when the program runs it will create the PR's (Purchase Requisition).
    You can also use a workflow with the Z table. Once the Z table is filled you can trigger a workflow based on the Table change. I'm not sure like how to do it but I nkow that this process can also be used.
    Hope this might have thrown some light upon.
    Thanks,
    Prashanth

  • SQl Server Error:927 and Restoring

    i have a problem with sharepoint database in SQL 2005.
    status of tow database in sql studio mamagment are restoring...
    how can i stop that? (change status to normal)
    AND SO :
    WHEN I GET A PROPERTISE OF THOSE DATABASE THIS ERROR APEAR:
    database cannot be openned. it is  in middle of restore. microsoft SQL server Error:927

    Hi Tibor,
    I am getting same error but here database is set to standby mode(logshipped), suggestion please..
    Error:
    database cannot be openned. it is  in middle of
    restore. microsoft SQL server Error:927
    TARAK
    Hi Tarak,
    Did the restore complete? If there are no further backups to be restored then try below command
    RESTORE DATABASE <name_here> WITH RECOVERY
    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • Intermittent Error SQL Server Error 67 and 17

    Hi!  We are running Windows SQL Server 2012 Standard on Windows Server 2012.  There is a SQL Database with an Access Front End which we migrated from older versions of Access and SQL.
    The Access front end communicates with the database most of the time without a problem.  However, sometimes Access just stops  responding and then the user gets the following error:
    Connection failed:
    SQLState: '01000'
    SQL Server Error: 67
    [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen(Connect()).
    Connection Failed:
    SQLState: '08001'
    SQL Server Error: 17
    [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access is denied.
    The person who maintains the Access and the SQL Databases provided the following summary:
    The spontaneous issue affects everyone connected to the SQL Server at the same time, and manifests itself in a slow or non-existent connection.  It resolves itself in a few minutes to a few hours.  The ODBC trace did not yield any useful information
    about the problem.  We tested with up to 5 simultaneous users with no problem.  When we observed the issue of Friday, only four users were in the database, and closing these connections did not immediately resolve the issue.  There appeared
    to be no problems with the network for file system access to the server during the down time.
    Based on this information, it definitely is not an issue with MS Access, the ODBC configuration, or the database structure.  It appears to be an intermittent connectivity issue with SQL Server itself, perhaps due to configuration problems, licensing
    (as you mentioned), conflicts with other software/processes, or due to some other SQL Server process.  Unfortunately, this is outside of my expertise and we do not have dedicated SQL Server or IT resources.  
    I had another IT Person look at the issue, he found the following:
    Sally's PC  was getting SQL error.<o:p></o:p>
    Logged into her PC to look at it (logged in as Sally and as cleAdmin)<o:p></o:p>
    Looked at server name, want to verify that in the Control Panel > Adminstratrative Tools > ODBC Connections<o:p></o:p>
    There was no odbc connections under User DSN,  System DSN or Fie DSN<o:p></o:p>
    Created new System DSN connection<o:p></o:p>
    Specified server:  CLE-VM-SQL-FILE\CLESQLSERVER<o:p></o:p>
    The rest were default values<o:p></o:p>
    Clicked test and it was successful<o:p></o:p>
    Unfortunately, the problem started again soon after these changes were made.
    It was suggested there could be a hardware issue, so we have replaced the switch and made sure the drivers on the Network Adapters are current.  Plus
    we have never seen any indication of a loss of network connectivity while testing using a PING Test.
    Has anyone else experienced this issue and if so, how did you solve it?
    Patricia Kachersky

    Bump, Anyone?
    Patricia Kachersky

  • SQL Server Agent Job And Database Mail - Error formatting query, probably invalid paramters

    We have a stored procedure that we are trying to call with a SQL Server Agent Job. The stored procedure calls Database Mail. This is SQL 2008. The execute task is simply:
    USE [Production]
    GO
    EXEC [dbo].[JOB_EMAIL_SCHEDULED_REPORTS]
    GO
    When the job runs, it is erroring out immediately, with the error:
    Execute as user: NT AUTHORITY\NETWORK SERVICE. Error formatting query, probably invalid paramters [SQLSTATE 42000] (Error 22050). The step failed.
    When we go into SQL Server Manager and just execute the SQL query, it works though. Something within the SQL Server Agent job,  and Database Mail is causing problems. Any ideas? Thanks.

    Justin,
    If you use SSMS then the procedure is executed under a different user when compared to running using a SQL Server Agent Job.
    Isolate the problem by running a SQL Server agent job that sends a mail. Also check if the NT Authority\Network Service account is
    in good standing. Look at the below thread with a similar problem that had an expired account.
    http://social.msdn.microsoft.com/Forums/en/sqltools/thread/bac7ecee-a156-4313-b532-ba15813a0700
    http://SankarReddy.com/

  • SQL server 2008 restore and access error

    hi
    (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server
    I restored a backup which i was not created to a new database and if i connect above said issue is coming , if i generate script from restored DB and running without data in another new database and connecting to the same is working .. can you plz tell what
    will be the exact problem and i found one database level user is there as below in the script.
    CREATE USER [appointment_bee] WITHOUT LOGIN WITH DEFAULT_SCHEMA=[dbo]
    kindly let me know whats the problem ..
    regards,
    martin

    Hi Martin,
    As Nag said, it's hard for us to understand your issue. For the error "Could not open a connection to SQL Server".
    There could be several reasons you get these error messages. To avoid this issue, please refer to the steps that provided on the links below.
    http://www.mssqltips.com/sqlservertip/2340/resolving-could-not-open-a-connection-to-sql-server-errors/
    http://blog.sqlauthority.com/2007/04/23/sql-server-fix-error-40-could-not-open-a-connection-to-sql-server/
    If this is now what you want, please provide us more information about your issue, so that we can make further analysis.
    Regards,
    Charlie Liao
    TechNet Community Support

  • The SELECT permissions was denied on the object 'extended_properties', database 'mssqlsystemresource', schema 'sys'.(Microsoft SQL Server, Error:229

    I have a SQL Server connected intro a Windows Server 2003 Domain Active Directory, the server holds a default instance with a single Database, the SQL Server is 2005 Std Edition, and is using mix mode Authentification, then I able to create SQL Native Users
    and Invoque Windows Domain Users also.
    The Goal of this project is remove the sysadmin Server role for all the Windows Domain Users, to give then a more granular secure model but at the moment is this only way to connect at the Data Base Server.
    I already create Native SQL Servers users without any problem!, they respect Securable Setting, Server Roles, User Mapping, everything...Just when I create a Login Profile form a Domain Users and apply the same setting, I get this error...
    The SELECT permissions was denied on the object 'extended_properties', database 'mssqlsystemresource', schema 'sys'.(Microsoft SQL Server, Error:229)
    But if the user have sysadmin Server Rol he can sing over the server without any issue, I review the .sys view extended_properties and "Public" is the only Database Role placed.
    Any Idea if I need change any Setting in the Secure in SQL Master DataBase? or which is the issue witjh this matter?
    Thank in advance for your help!

    Since there are so many possibilities for what might be wrong.  Here's another possibility to look at.  I ran into something where I had set up my own roles on a database.  (For instance, "Administrator", "Manager", "DataEntry",
    "Customer", each with their own kinds of limitations)  The only ones who could use it were "Manager" role or above--because they were also set up as sysadmin because they were adding users to the database (and they were highly trusted). 
    Also, the users that were being added were Windows Domain users--using their domain credentials.  (Everyone with access to the database had to be on our domain, but not everyone on the domain had access to the database--and only a few of them had access
    to change it.)
    Anyway, this working system suddenly stopped working and I was getting error messages similar to the above.  What I ended up doing that solved it was to go through all the permissions for the "public" role in that database and add those permissions
    to all of the roles that I had created.  I know that everyone is supposed to be in the "public" role even though you can't add them (or rather, you can "add" them, but they won't "stay added").
    So, in "SQL Server Management Studio", I went into my application's database, in other words (my localized names are obscured within <> brackets): "<Computername> (SQL Server <version> - sa)"\Databases\<MyAppDB>\Security\Roles\Database
    Roles\public".  Right-click on "public" and select "Properties".  In the "Database Role Properties - public" dialog, select the "Securables" page.  Go through the list and for each element in the
    list, come up with an SQL "Grant" statement to grant exactly that permission to another role.  So, for instance, there is a scalar function "[dbo].[fn_diagramobjects]" on which the "public" role has "Execute" privilege. 
    So, I added the following line:   
    EXEC ( 'GRANT EXECUTE ON [dbo].[fn_diagramobjects] TO [' + @RoleName + '];' )
    Once I had done this for all the elements in the "Securables" list, I wrapped that up in a while loop on a cursor selecting through all the roles in my roles table.  This explicitly granted all the permissions of the "public" role to
    my database roles.  At that point, all my users were working again (even after I removed their "sysadmin" access--done as a temporary measure while I figured out what happened.)
    I'm sure there's a better (more elegant) way to do this by doing some kind of a query on the database objects and selecting on the public role, but after about half and hour of investigating, I wasn't figuring it out, so I just did it the brute-force method. 
    In case it helps someone else, here's my code.
    CREATE PROCEDURE [dbo].[GrantAccess]
    AS
    DECLARE @AppRoleName AS sysname
    DECLARE AppRoleCursor CURSOR LOCAL SCROLL_LOCKS FOR
    SELECT AppRoleName FROM [dbo].[RoleList];
    OPEN AppRoleCursor
    FETCH NEXT FROM AppRoleCursor INTO @AppRoleName
    WHILE @@FETCH_STATUS = 0
    BEGIN
    EXEC ( 'GRANT EXECUTE ON [dbo].[fn_diagramobjects] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT EXECUTE ON [dbo].[sp_alterdiagram] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT EXECUTE ON [dbo].[sp_creatediagram] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT EXECUTE ON [dbo].[sp_dropdiagram] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT EXECUTE ON [dbo].[sp_helpdiagramdefinition] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT EXECUTE ON [dbo].[sp_helpdiagrams] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT EXECUTE ON [dbo].[sp_renamediagram] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[all_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[all_objects] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[all_parameters] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[all_sql_modules] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[all_views] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[allocation_units] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[assemblies] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[assembly_files] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[assembly_modules] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[assembly_references] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[assembly_types] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[asymmetric_keys] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[certificates] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[change_tracking_tables] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[check_constraints] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[column_type_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[column_xml_schema_collection_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[computed_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[conversation_endpoints] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[conversation_groups] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[conversation_priorities] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[crypt_properties] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[data_spaces] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_audit_specification_details] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_audit_specifications] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_files] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_permissions] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_principal_aliases] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_principals] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_role_members] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[default_constraints] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[destination_data_spaces] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[event_notifications] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[events] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[extended_procedures] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[extended_properties] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[filegroups] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[foreign_key_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[foreign_keys] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_catalogs] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_index_catalog_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_index_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_index_fragments] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_indexes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_stoplists] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_stopwords] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[function_order_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[identity_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[index_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[indexes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[internal_tables] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[key_constraints] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[key_encryptions] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[message_type_xml_schema_collection_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[module_assembly_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[numbered_procedure_parameters] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[numbered_procedures] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[objects] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[parameter_type_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[parameter_xml_schema_collection_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[parameters] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[partition_functions] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[partition_parameters] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[partition_range_values] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[partition_schemes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[partitions] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[plan_guides] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[procedures] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[remote_service_bindings] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[routes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[schemas] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[service_contract_message_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[service_contract_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[service_contracts] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[service_message_types] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[service_queue_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[service_queues] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[services] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[spatial_index_tessellations] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[spatial_indexes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sql_dependencies] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sql_modules] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[stats] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[stats_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[symmetric_keys] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[synonyms] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[syscolumns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[syscomments] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysconstraints] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysdepends] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysfilegroups] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysfiles] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysforeignkeys] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysfulltextcatalogs] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysindexes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysindexkeys] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysmembers] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysobjects] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[syspermissions] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysprotects] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysreferences] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[system_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[system_objects] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[system_parameters] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[system_sql_modules] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[system_views] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[systypes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysusers] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[table_types] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[tables] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[transmission_queue] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[trigger_events] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[triggers] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[type_assembly_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[types] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[views] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_indexes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_attributes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_collections] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_component_placements] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_components] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_elements] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_facets] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_model_groups] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_namespaces] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_types] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_wildcard_namespaces] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_wildcards] TO [' + @AppRoleName + '];' )
    FETCH NEXT FROM AppRoleCursor INTO @AppRoleName
    END
    CLOSE AppRoleCursor
    RETURN 0
    GO
    Once that is in the system, I just needed to "Exec GrantAccess" to make it work.  (Of course, I have a table [RoleList] which contains a "AppRoleName" field that contains the names of the database roles.)
    So, the mystery remains: why did all my users lose their "public" role and why could I not give it back to them?  Was this part of an update to SQL Server 2008 R2?  Was it because I ran another script to delete each user and add them back
    so to refresh their connection with the domain?  Well, this solves the issue for now.
    One last warning: you probably should check the "public" role on your system before running this to make sure there isn't something missing or wrong, here.  It's always possible something is different about your system.
    Hope this helps someone else.

  • The SELECT permission was denied on the object 'extended_properties', database 'mssqlsystemresource', schema 'sys'. (Microsoft SQL Server, Error: 229)

    I have created a user and given him the owner rights for the database.  Though I can LogIn as the user, I cannot access the databases.  I am having the error mesage:
    Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
    For help, click:
    http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476
    ADDITIONAL INFORMATION:
    An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
    The SELECT permission was denied on the object 'extended_properties', database 'mssqlsystemresource', schema 'sys'. (Microsoft SQL Server, Error: 229)
    For help, click:
    http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600&EvtSrc=MSSQLServer&EvtID=229&LinkId=20476
    Sha_woop

    Since there are so many possibilities for what might be wrong.  Here's another possibility to look at.  I ran into something where I had set up my own roles on a database.  (For instance, "Administrator", "Manager", "DataEntry", "Customer",
    each with their own kinds of limitations)  The only ones who could use it were "Manager" role or above--because they were also set up as sysadmin because they were adding users to the database (and they were highly trusted).  Also, the users that
    were being added were Windows Domain users--using their domain credentials.  (Everyone with access to the database had to be on our domain, but not everyone on the domain had access to the database--and only a few of them had access to change it.)
    Anyway, this working system suddenly stopped working and I was getting error messages similar to the above.  What I ended up doing that solved it was to go through all the permissions for the "public" role in that database and add those permissions to
    all of the roles that I had created.  I know that everyone is supposed to be in the "public" role even though you can't add them (or rather, you can "add" them, but they won't "stay added").
    So, in "SQL Server Management Studio", I went into my application's database, in other words (my localized names are obscured within <> brackets): "<Computername> (SQL Server <version> - sa)"\Databases\<MyAppDB>\Security\Roles\Database
    Roles\public".  Right-click on "public" and select "Properties".  In the "Database Role Properties - public" dialog, select the "Securables" page.  Go through the list and for each element in the list, come up with an SQL "Grant" statement to
    grant exactly that permission to another role.  So, for instance, there is a scalar function "[dbo].[fn_diagramobjects]" on which the "public" role has "Execute" privilege.  So, I added the following line:
    EXEC ( 'GRANT EXECUTE ON [dbo].[fn_diagramobjects] TO [' + @RoleName + '];' )
    Once I had done this for all the elements in the "Securables" list, I wrapped that up in a while loop on a cursor selecting through all the roles in my roles table.  This explicitly granted all the permissions of the "public" role to my database roles. 
    At that point, all my users were working again (even after I removed their "sysadmin" access--done as a temporary measure while I figured out what happened.)
    I'm sure there's a better (more elegant) way to do this by doing some kind of a query on the database objects and selecting on the public role, but after about half and hour of investigating, I wasn't figuring it out, so I just did it the brute-force method. 
    In case it helps someone else, here's my code.
    CREATE PROCEDURE [dbo].[GrantAccess]
    AS
    DECLARE @AppRoleName AS sysname
    DECLARE AppRoleCursor CURSOR LOCAL SCROLL_LOCKS FOR
    SELECT AppRoleName FROM [dbo].[RoleList];
    OPEN AppRoleCursor
    FETCH NEXT FROM AppRoleCursor INTO @AppRoleName
    WHILE @@FETCH_STATUS = 0
    BEGIN
    EXEC ( 'GRANT EXECUTE ON [dbo].[fn_diagramobjects] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT EXECUTE ON [dbo].[sp_alterdiagram] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT EXECUTE ON [dbo].[sp_creatediagram] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT EXECUTE ON [dbo].[sp_dropdiagram] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT EXECUTE ON [dbo].[sp_helpdiagramdefinition] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT EXECUTE ON [dbo].[sp_helpdiagrams] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT EXECUTE ON [dbo].[sp_renamediagram] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[all_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[all_objects] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[all_parameters] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[all_sql_modules] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[all_views] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[allocation_units] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[assemblies] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[assembly_files] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[assembly_modules] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[assembly_references] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[assembly_types] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[asymmetric_keys] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[certificates] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[change_tracking_tables] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[check_constraints] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[column_type_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[column_xml_schema_collection_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[computed_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[conversation_endpoints] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[conversation_groups] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[conversation_priorities] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[crypt_properties] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[data_spaces] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_audit_specification_details] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_audit_specifications] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_files] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_permissions] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_principal_aliases] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_principals] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[database_role_members] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[default_constraints] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[destination_data_spaces] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[event_notifications] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[events] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[extended_procedures] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[extended_properties] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[filegroups] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[foreign_key_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[foreign_keys] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_catalogs] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_index_catalog_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_index_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_index_fragments] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_indexes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_stoplists] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[fulltext_stopwords] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[function_order_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[identity_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[index_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[indexes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[internal_tables] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[key_constraints] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[key_encryptions] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[message_type_xml_schema_collection_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[module_assembly_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[numbered_procedure_parameters] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[numbered_procedures] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[objects] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[parameter_type_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[parameter_xml_schema_collection_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[parameters] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[partition_functions] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[partition_parameters] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[partition_range_values] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[partition_schemes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[partitions] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[plan_guides] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[procedures] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[remote_service_bindings] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[routes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[schemas] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[service_contract_message_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[service_contract_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[service_contracts] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[service_message_types] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[service_queue_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[service_queues] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[services] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[spatial_index_tessellations] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[spatial_indexes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sql_dependencies] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sql_modules] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[stats] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[stats_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[symmetric_keys] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[synonyms] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[syscolumns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[syscomments] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysconstraints] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysdepends] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysfilegroups] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysfiles] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysforeignkeys] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysfulltextcatalogs] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysindexes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysindexkeys] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysmembers] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysobjects] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[syspermissions] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysprotects] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysreferences] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[system_columns] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[system_objects] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[system_parameters] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[system_sql_modules] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[system_views] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[systypes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[sysusers] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[table_types] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[tables] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[transmission_queue] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[trigger_events] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[triggers] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[type_assembly_usages] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[types] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[views] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_indexes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_attributes] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_collections] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_component_placements] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_components] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_elements] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_facets] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_model_groups] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_namespaces] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_types] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_wildcard_namespaces] TO [' + @AppRoleName + '];' )
    EXEC ( 'GRANT SELECT ON [sys].[xml_schema_wildcards] TO [' + @AppRoleName + '];' )
    FETCH NEXT FROM AppRoleCursor INTO @AppRoleName
    END
    CLOSE AppRoleCursor
    RETURN 0
    GO
    Once that is in the system, I just needed to "Exec GrantAccess" to make it work.  (Of course, I have a table [RoleList] which contains a "AppRoleName" field that contains the names of the database roles.)
    So, the mystery remains: why did all my users lose their "public" role and why could I not give it back to them?  Was this part of an update to SQL Server 2008 R2?  Was it because I ran another script to delete each user and add them back so to refresh
    their connection with the domain?  Well, this solves the issue for now.
    One last warning: you probably should check the "public" role on your system before running this to make sure there isn't something missing or wrong, here.  It's always possible something is different about your system.
    Hope this helps someone else.

  • Welcome to the SQL Server Disaster Recovery and Availability Forum

    (Edited 8/14/2009 to correct links - Paul)
    Hello everyone and welcome to the SQL Server Disaster Recovery and Availability forum. The goal of this Forum is to offer a gathering place for SQL Server users to discuss:
    Using backup and restore
    Using DBCC, including interpreting output from CHECKDB and related commands
    Diagnosing and recovering from hardware issues
    Planning/executing a disaster recovery and/or high-availability strategy, including choosing technologies to use
    The forum will have Microsoft experts in all these areas and so we should be able to answer any question. Hopefully everyone on the forum will contribute not only questions, but opinions and answers as well. I’m looking forward to seeing this becoming a vibrant forum.
    This post has information to help you understand what questions to post here, and where to post questions about other technologies as well as some tips to help you find answers to your questions more quickly and how to ask a good question. See you in the group!
    Paul Randal
    Lead Program Manager, SQL Storage Engine and SQL Express
    Be a good citizen of the Forum
    When an answer resolves your problem, please mark the thread as Answered. This makes it easier for others to find the solution to this problem when they search for it later. If you find a post particularly helpful, click the link indicating that it was helpful
    What to post in this forum
    It seems obvious, but this forum is for discussion and questions around disaster recovery and availability using SQL Server. When you want to discuss something that is specific to those areas, this is the place to be. There are several other forums related to specific technologies you may be interested in, so if your question falls into one of these areas where there is a better batch of experts to answer your question, we’ll just move your post to that Forum so those experts can answer. Any alerts you set up will move with the post, so you’ll still get notification. Here are a few of the other forums that you might find interesting:
    SQL Server Setup & Upgrade – This is where to ask all your setup and upgrade related questions. (http://social.msdn.microsoft.com/Forums/en-US/sqlsetupandupgrade/threads)
    Database Mirroring – This is the best place to ask Database Mirroring how-to questions. (http://social.msdn.microsoft.com/Forums/en-US/sqldatabasemirroring/threads)
    SQL Server Replication – If you’ve already decided to use Replication, check out this forum. (http://social.msdn.microsoft.com/Forums/en-US/sqlreplication/threads)
    SQL Server Database Engine – Great forum for general information about engine issues such as performance, FTS, etc. (http://social.msdn.microsoft.com/Forums/en-US/sqldatabaseengine/threads)
    How to find your answer faster
    There is a wealth of information already available to help you answer your questions. Finding an answer via a few quick searches is much quicker than posting a question and waiting for an answer. Here are some great places to start your research:
    SQL Server 2005 Books Onlinne
    Search it online at http://msdn2.microsoft.com
    Download the full version of the BOL from here
    Microsoft Support Knowledge Base:
    Search it online at http://support.microsoft.com
    Search the SQL Storage Engine PM Team Blog:
    The blog is located at https://blogs.msdn.com/sqlserverstorageengine/default.aspx
    Search other SQL Forums and Web Sites:
    MSN Search: http://www.bing.com/
    Or use your favorite search engine
    How to ask a good question
    Make sure to give all the pertinent information that people will need to answer your question. Questions like “I got an IO error, any ideas?” or “What’s the best technology for me to use?” will likely go unanswered, or at best just result in a request for more information. Here are some ideas of what to include:
    For the “I got an IO error, any ideas?” scenario:
    The exact error message. (The SQL Errorlog and Windows Event Logs can be a rich source of information. See the section on error logs below.)
    What were you doing when you got the error message?
    When did this start happening?
    Any troubleshooting you’ve already done. (e.g. “I’ve already checked all the firmware and it’s up-to-date” or "I've run SQLIOStress and everything looks OK" or "I ran DBCC CHECKDB and the output is <blah>")
    Any unusual occurrences before the error occurred (e.g. someone tripped the power switch, a disk in a RAID5 array died)
    If relevant, the output from ‘DBCC CHECKDB (yourdbname) WITH ALL_ERRORMSGS, NO_INFOMSGS’
    The SQL Server version and service pack level
    For the “What’s the best technology for me to use?” scenario:
    What exactly are you trying to do? Enable local hardware redundancy? Geo-clustering? Instance-level failover? Minimize downtime during recovery from IO errors with a single-system?
    What are the SLAs (Service Level Agreements) you must meet? (e.g. an uptime percentage requirement, a minimum data-loss in the event of a disaster requirement, a maximum downtime in the event of a disaster requirement)
    What hardware restrictions do you have? (e.g. “I’m limited to a single system” or “I have several worldwide mirror sites but the size of the pipe between them is limited to X Mbps”)
    What kind of workload does you application have? (or is it a mixture of applications consolidated on a single server, each with different SLAs) How much transaction log volume is generated?
    What kind of regular maintenance does your workload demand that you perform (e.g. “the update pattern of my main table is such that fragmentation increases in the clustered index, slowing down the most common queries so there’s a need to perform some fragmentation removal regularly”)
    Finding the Logs
    You will often find more information about an error by looking in the Error and Event logs. There are two sets of logs that are interesting:
    SQL Error Log: default location: C:\Program Files\Microsoft SQL Server\MSSQL.#\MSSQL\LOG (Note: The # changes depending on the ID number for the installed Instance. This is 1 for the first installation of SQL Server, but if you have mulitple instances, you will need to determine the ID number you’re working with. See the BOL for more information about Instance ID numbers.)
    Windows Event Log: Go to the Event Viewer in the Administrative Tools section of the Start Menu. The System event log will show details of IO subsystem problems. The Application event log will show details of SQL Server problems.

    hi,I have a question on sql database high availability. I have tried using database mirroring, where I am using sql standard edition, in this database mirroring of synchronous mode is the only option available, and it is giving problem, like sql time out errors on my applicatons since i had put in the database mirroring, as asynchronous is only available on enterprise version, is there any suggestions on this. thanks ---vijay

  • SQL Server Error when tryingt to install the CMS DB on SQL Server 2005 x64

    I am trying to install BOEXI R3 on w2k3 64-bit OS in a SQL Server 2005 x64 database, I am currently at the installation step where i Specify an exisiting CMS database. I created a System DSN and tested it, and it was successful. So when I got to the screen where I select my datasource I had to check use trusted connection because the datasource would not show up when Use DSN created by WOW64 option was checked. From there I could select the database I created. Oh yeah, I also made the application server local system account part of my DB admins group so it has full access to the database yet when I click next to connect I get a CMS Database Error: STU000226. here is what I have in my log:
    ThreadID     Message
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: findDFA_LLR:  (CmdLineDir) C:Documents and SettingsgsdadminDesktopBOEXI and BSM AnalyticsBOEXI R3 Full Version from SAPpackagedbcheck
    sqlrule.llr
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: Loading: database subsystem only
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: loading libary succeeded
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: DatabaseSubsystem::Init()
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.wireobinit.cpp:96): trace message: Creating the shared CWireObject::PropertyNameMap
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.wireobinit.cpp:118): trace message: Setting static property map
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.wireobinit.cpp:125): trace message: CWireObject::InitializeStaticPropertyMap() - reference count: 1
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: initializing subsystem succeeded
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: Loading: done loading subsystem - database subsystem only
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: DatabaseSubsystem::Connect()
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.DBConnectionManager.cpp:802): trace message: DBConnectionManager - Setting total target number of connections for pool 0 to 1.
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.SQLServerDatabase.cpp:119): trace message: SQLServer error found:  ErrorMessage( (Microsoft)[ODBC Driver Manager] Data source name not found and no default driver specified), ErrorCode(0)
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.dbutils.cpp:820): trace message: Caught DatabaseSubystem Error: BusinessObjects Enterprise CMS: Unable to connect to the CMS system database "BOEXI_CMS". Reason:  (Microsoft)[ODBC Driver Manager] Data source name not found and no default driver specified
    (Thu Apr 23 20:57:46 2009)     3024     3028     trace message: DatabaseSubsystem::Shutdown()
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.wireobinit.cpp:175): trace message: CWireObject::TerminateStaticPropertyMap() - reference count: 1
    (Thu Apr 23 20:57:46 2009)     3024     3028     (.wireobinit.cpp:182): trace message: Releasing
    static property map
    How do I get past this?

    The workaround was, I installed the SQL Server Client tools and created a System DataSource  and then had to create a user DataSource  (it is a quirk in the installer I guess) to get past this point in the installation. Now I have an even bigger problem. Everything but the CMS installed and the installer hung at the "Configuring the CMS" part. The installation finished but when I tried to log into the Central managment console I got this error:
    Error: Server GSD-RRPT-RDC:6400 not found or server may be down (FWM 01003) null
    I looked at the forums for the cause of this error and came to the conclusion that BOEXI does not support an installation on SQL Server 2005 when using Integrated Authentication to the SQL Server. See the engineers here disabled SQL Authentication for the SQL Server and  will not allow it.
    Is this true? Or is there a workaround to install the CMS using Integrated Authentication in the DataSource ?
    Thanks.

  • Cannot connect to SERVER. Login failed for user 'DOMAIN\user'. (Microsoft SQL Server, Error 18456) - SQL Server 2012 on Windows Server 2008 R2

    I've seen multiple blogs and forums with similar problems and SQL 2012 or 2008. But no solutions that work for me.
    I have installed SQL Server in mixed mode (SQL and Windows authentication). I can create new Login accounts in either mode. However, I cannot get an AD security group Login account to work. I am trying to add group 'DOMAIN\Domain Admins' or 'SERVER\Administrators'
    as a Login so that any of the domain's administrator accounts can open SQL Server Management Studio and act as an 'sa' account on this server.
    I have deleted the SQL account 'DOMAIN\Domain Admins'.
    I have restarted SQL.
    I have restarted the Win2K8r2 server.
    I have launched SSMS as Administrator from the desktop of SERVER.
    I have launched SSMS as another user (and used 'DOMAIN\user' to lauch it) from the desktop of SERVER.
    I can create a login account named 'DOMAIN\user' (who happens to be a member of the 'DOMAIN\Domain Admins' group) and give this account 'sa' security, and when I do that, this account works as expected...
    How do I add a security group as a Login account and give all members of that group the ability to be an 'sa' account?

    Hi geoperkins,
    Are you getting the following error message?
    Error: 18456, Severity: 14, State: 11
    Login failed for user <Domain\user>. Reason: Token-based server access validation failed with an infrastructure error.
    If that is the case, the issue could be due to that the Windows login has no profile or that permissions could not be checked due to UAC. Please disable UAC firstly and check if it is successful to log in SQL Server.
    Another reason could be that the domain controller could not be reached. You may need to resort to re-creating the login. Create a new group in AD, add users to the new group, then add the group to the local admin group and create login for the group in SQL
    Server.
    There is a connect item describing similar issue for your reference.
    https://connect.microsoft.com/SQLServer/feedback/details/680705/cant-login-to-sql-using-windows-authentication-when-user-is-in-a-domain-security-group
    For more details about above error, please review the following blog.
    http://sqlblogcasts.com/blogs/simons/archive/2011/02/01/solution-login-failed-for-user-x-reason-token-based-server-access-validation-failed-and-error-18456.aspx
    Thanks,
    Lydia Zhang
    Lydia Zhang
    TechNet Community Support

  • Connection failed: SQLState:'01000' SQL Server Error:67 [Microsoft]ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). Connection failed: SQLState:'08001' SQL Server Error:17 [Microsoft]ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist o

    Help,
    setup a new sql server 2012 on a windows 2012r2 server to replace old sql server 2005 on an old windows server 2003 machine.  When i test the ODBC connection locally on the server it works fine, however when i try to connect via windows 7 client machine
    i get the following error:
    Connection failed:
    SQLState:'01000'
    SQL Server Error:67
    [Microsoft]ODBC SQL Server Driver][DBNETLIB]ConnectionOpen
    (Connect()).
    Connection failed:
    SQLState:'08001'
    SQL Server Error:17
    [Microsoft]ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied
    I think it must be a permissions thing, I've turned off the firewall for now and still no difference, 've also made sure remote connection is enabled.  I can connect to the other sql server in studio manager on the new machine however, i can't go do
    the same in the old server, says:
    cannot connect to hbfsqlpro1\hbfsqlpro1
    Additonal information a network related or instance specifc error occured while establising a connection to SQL server.  The server was not found or was not accessible.  Verify that the instance name is correct and that SQL server is configured to
    allow remote connections. (provider:SQL Network Interfaces, error 26 - error locationg server/instance specified) (Microsoft SQL server)
    the instance is def correct, as that is what i use to connect locally on the new machine and what it comes up on the studio manager on the new machine.  STarting to pull my hair out somewhat, i'm sure it's something really simple! 

    Hello,
    You are trying to connect to a named instance. Make sure the SQL Server Browser service is started on the SQL Server computer.
    Make sure TCP/IP is enabled.
    http://msdn.microsoft.com/en-us/library/ms191294(v=sql.110).aspx
    Try to disable Windows Firewall or security software on both, SQL Server instance and client computer.
    Test basic connectivity too. Try to ping from the client computer to the SQL Server computer.
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Wait on the Database Engine recovery handle failed. Check the SQL server error log for potential causes in SQL Server 2012 Developer Edition

    I m using SQL Server 2012 Developer Edition. Even I tried 2012 express and enterprise edition but all
    gave same error. I browsed msdn blog. But nothing help me out.
    Below is the error log details--
    Overall summary:
      Final result:                  Failed: see details below
      Exit code (Decimal):           -2061893606
      Start time:                    2013-10-21 12:58:05
      End time:                      2013-10-21 13:52:30
      Requested action:              Install
    Setup completed with required actions for features.
    Troubleshooting information for those features:
      Next step for RS:              Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Next step for SQLEngine:       Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Next step for DQ:              Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Next step for FullText:        Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Next step for Replication:     Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
    Machine Properties:
      Machine name:                  CROY-TOSH
      Machine processor count:       4
      OS version:                    Windows 7
      OS service pack:               Service Pack 1
      OS region:                     United States
      OS language:                   English (United States)
      OS architecture:               x64
      Process architecture:          64 Bit
      OS clustered:                  No
    Product features discovered:
      Product              Instance             Instance ID                    Feature                
                     Language             Edition              Version         Clustered 
    Package properties:
      Description:                   Microsoft SQL Server 2012 Service Pack 1
      ProductName:                   SQL Server 2012
      Type:                          RTM
      Version:                       11
      SPLevel:                       0
      Installation location:         C:\Users\CRoy\Downloads\SQL Server 2012 Developer Edition (x86 and x64) - DVD (English)\x64\setup\
      Installation edition:          Developer
    Product Update Status:
      None discovered.
    User Input Settings:
      ACTION:                        Install
      ADDCURRENTUSERASSQLADMIN:      false
      AGTSVCACCOUNT:                 NT Service\SQLSERVERAGENT
      AGTSVCPASSWORD:                *****
      AGTSVCSTARTUPTYPE:             Manual
      ASBACKUPDIR:                   C:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Backup
      ASCOLLATION:                   Latin1_General_CI_AI
      ASCONFIGDIR:                   C:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Config
      ASDATADIR:                     C:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Data
      ASLOGDIR:                      C:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Log
      ASPROVIDERMSOLAP:              1
      ASSERVERMODE:                  MULTIDIMENSIONAL
      ASSVCACCOUNT:                  NT Service\MSSQLServerOLAPService
      ASSVCPASSWORD:                 <empty>
      ASSVCSTARTUPTYPE:              Automatic
      ASSYSADMINACCOUNTS:            CRoy-TOSH\CRoy
      ASTEMPDIR:                     C:\Program Files\Microsoft SQL Server\MSAS11.MSSQLSERVER\OLAP\Temp
      BROWSERSVCSTARTUPTYPE:         Disabled
      CLTCTLRNAME:                   ROY
      CLTRESULTDIR:                  C:\Program Files (x86)\Microsoft SQL Server\DReplayClient\ResultDir\
      CLTSTARTUPTYPE:                Manual
      CLTSVCACCOUNT:                 NT Service\SQL Server Distributed Replay Client
      CLTSVCPASSWORD:                <empty>
      CLTWORKINGDIR:                 C:\Program Files (x86)\Microsoft SQL Server\DReplayClient\WorkingDir\
      COMMFABRICENCRYPTION:          0
      COMMFABRICNETWORKLEVEL:        0
      COMMFABRICPORT:                0
      CONFIGURATIONFILE:             C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\20131021_125116\ConfigurationFile.ini
      CTLRSTARTUPTYPE:               Manual
      CTLRSVCACCOUNT:                NT Service\SQL Server Distributed Replay Controller
      CTLRSVCPASSWORD:               <empty>
      CTLRUSERS:                     CRoy-TOSH\CRoy
      ENABLERANU:                    false
      ENU:                           true
      ERRORREPORTING:                true
      FEATURES:                      SQLENGINE, REPLICATION, FULLTEXT, DQ, AS, RS, RS_SHP, RS_SHPWFE, DQC, BIDS, CONN, IS, BC, SDK, BOL, SSMS, ADV_SSMS, DREPLAY_CTLR, DREPLAY_CLT, SNAC_SDK, MDS
      FILESTREAMLEVEL:               2
      FILESTREAMSHARENAME:           MSSQLSERVER
      FTSVCACCOUNT:                  NT Service\MSSQLFDLauncher
      FTSVCPASSWORD:                 <empty>
      HELP:                          false
      IACCEPTSQLSERVERLICENSETERMS:  false
      INDICATEPROGRESS:              false
      INSTALLSHAREDDIR:              C:\Program Files\Microsoft SQL Server\
      INSTALLSHAREDWOWDIR:           C:\Program Files (x86)\Microsoft SQL Server\
      INSTALLSQLDATADIR:             <empty>
      INSTANCEDIR:                   C:\Program Files\Microsoft SQL Server\
      INSTANCEID:                    MSSQLSERVER
      INSTANCENAME:                  MSSQLSERVER
      ISSVCACCOUNT:                  NT Service\MsDtsServer110
      ISSVCPASSWORD:                 <empty>
      ISSVCSTARTUPTYPE:              Automatic
      MATRIXCMBRICKCOMMPORT:         0
      MATRIXCMSERVERNAME:            <empty>
      MATRIXNAME:                    <empty>
      NPENABLED:                     0
      PID:                           *****
      QUIET:                         false
      QUIETSIMPLE:                   false
      ROLE:                          <empty>
      RSINSTALLMODE:                 DefaultNativeMode
      RSSHPINSTALLMODE:              SharePointFilesOnlyMode
      RSSVCACCOUNT:                  NT Service\ReportServer
      RSSVCPASSWORD:                 <empty>
      RSSVCSTARTUPTYPE:              Automatic
      SAPWD:                         *****
      SECURITYMODE:                  SQL
      SQLBACKUPDIR:                  <empty>
      SQLCOLLATION:                  Latin1_General_CI_AI
      SQLSVCACCOUNT:                 NT Service\MSSQLSERVER
      SQLSVCPASSWORD:                *****
      SQLSVCSTARTUPTYPE:             Automatic
      SQLSYSADMINACCOUNTS:           CRoy-TOSH\CRoy
      SQLTEMPDBDIR:                  <empty>
      SQLTEMPDBLOGDIR:               <empty>
      SQLUSERDBDIR:                  <empty>
      SQLUSERDBLOGDIR:               <empty>
      SQMREPORTING:                  false
      TCPENABLED:                    0
      UIMODE:                        Normal
      UpdateEnabled:                 true
      UpdateSource:                  MU
      X86:                           false
      Configuration file:            C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\20131021_125116\ConfigurationFile.ini
    Detailed results:
      Feature:                       Management Tools - Complete
      Status:                        Passed
      Feature:                       Client Tools Connectivity
      Status:                        Passed
      Feature:                       Client Tools SDK
      Status:                        Passed
      Feature:                       Client Tools Backwards Compatibility
      Status:                        Passed
      Feature:                       Management Tools - Basic
      Status:                        Passed
      Feature:                       SQL Server Data Tools
      Status:                        Passed
      Feature:                       Reporting Services - Native
      Status:                        Failed: see logs for details
      Reason for failure:            An error occurred for a dependency of the feature causing the setup process for the feature to fail.
      Next Step:                     Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Component name:                SQL Server Database Engine Services Instance Features
      Component error code:          0x851A001A
      Error description:             Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
      Error help link:               http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.3128.0&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026
      Feature:                       Database Engine Services
      Status:                        Failed: see logs for details
      Reason for failure:            An error occurred during the setup process of the feature.
      Next Step:                     Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Component name:                SQL Server Database Engine Services Instance Features
      Component error code:          0x851A001A
      Error description:             Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
      Error help link:               http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.3128.0&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026
      Feature:                       Data Quality Services
      Status:                        Failed: see logs for details
      Reason for failure:            An error occurred for a dependency of the feature causing the setup process for the feature to fail.
      Next Step:                     Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Component name:                SQL Server Database Engine Services Instance Features
      Component error code:          0x851A001A
      Error description:             Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
      Error help link:               http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.3128.0&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026
      Feature:                       Full-Text and Semantic Extractions for Search
      Status:                        Failed: see logs for details
      Reason for failure:            An error occurred for a dependency of the feature causing the setup process for the feature to fail.
      Next Step:                     Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Component name:                SQL Server Database Engine Services Instance Features
      Component error code:          0x851A001A
      Error description:             Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
      Error help link:               http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.3128.0&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026
      Feature:                       SQL Server Replication
      Status:                        Failed: see logs for details
      Reason for failure:            An error occurred for a dependency of the feature causing the setup process for the feature to fail.
      Next Step:                     Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Component name:                SQL Server Database Engine Services Instance Features
      Component error code:          0x851A001A
      Error description:             Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
      Error help link:               http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.3128.0&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026
      Feature:                       Master Data Services
      Status:                        Passed
      Feature:                       Distributed Replay Client
      Status:                        Passed
      Feature:                       Distributed Replay Controller
      Status:                        Passed
      Feature:                       Integration Services
      Status:                        Passed
      Feature:                       Data Quality Client
      Status:                        Passed
      Feature:                       Analysis Services
      Status:                        Passed
      Feature:                       Reporting Services - SharePoint
      Status:                        Passed
      Feature:                       Reporting Services Add-in for SharePoint Products
      Status:                        Passed
      Feature:                       SQL Browser
      Status:                        Passed
      Feature:                       Documentation Components
      Status:                        Passed
      Feature:                       SQL Writer
      Status:                        Passed
      Feature:                       SQL Client Connectivity
      Status:                        Passed
      Feature:                       SQL Client Connectivity SDK
      Status:                        Passed
    Rules with failures:
    Global rules:
    Scenario specific rules:
    Rules report file:               C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\20131021_125116\SystemConfigurationCheck_Report.htm

    Hi,
    This 3rd time I followed this link. But nothing new, same error.
    Can you please tell me how to do follow, I cannt do the 1st step, how to change the local system to windows level account, vice-versa. It is shown mine as
    Server Configuration Manager(Local) 
    From here I folllowed the steps ---[I cannt insert link/image :-(]
    SQL 2008/R2 setup fails with "Wait on the database engine recovery handle failed" 
    If I right clicked on SQL Server Service, there is no option to change the account. 
    Hello,
    Thanks for your patience,did you tried stesp mentioned in below article
    http://blogs.msdn.com/b/sqljourney/archive/2012/03/16/sql-2008-r2-setup-fails-with-quot-wait-on-the-database-engine-recovery-handle-failed-quot.aspx
    To resolve it, follow these steps:-
    When the installation throws this error, click on OK and allow it to proceed. It will fail for Database Engine, but the SQL Server service should have
    been created. Check the Services console.
    If the service is present, perform the following steps:-
    1. Go to SQL Server Configuration manager, right click on the SQL Server service, and change the service account (if it is local system, give
    it a windows level account, and vice-versa). It might throw a WMI error but you will see the account getting updated anyway. If not, then use the Services console. Change the account for SQL Agent as well.
    Use this link to change sql server service account
    http://technet.microsoft.com/en-us/library/ms345578.aspx
    2. Next, try to start the service. It should come online.
    3. However, you will not be able to log in to the SQL Server
    4. Now stop the service and start it from the command prompt using -m -c -T3608 parameters.
    5. Now try logging in to the server using admin connection from sqlcmd (sqlcmd admin:<server name>\<instance name> ...)
    6. Once logged in, use the sp_addsrvrolemember '<domain\username>','sysadmin'.
    Also add the builtin/administrators to the sysadmin role
    7. Now stop the service from the command prompt and start it from SQL Server configuration manager
    You should be able to log in to the server now.
    Hope this helps someone.
    Please revert if it helps or even if it does not
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Error en Query : [SQL Server] Error de Division entre 0

    Maestros !!
    Tengo este problema:
    Al ejecutar una query me figura este error " [SQL Server] Error de Division entre 0 ". Entiendo el error, cualquier numero divido por 0 arroja este problema, mi pregunta es como lo hago para no considerar las operaciones con resultado 0. Al revisar las operaciones que esta resumiendo la funcion AVG existen operaciones con resultado 0.
    La query es la siguiente:
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 01'
    INTO #FV01 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='01'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 02'
    INTO #FV02 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='02'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 03'
    INTO #FV03 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='03'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 04'
    INTO #FV04 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='04'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 05'
    INTO #FV05 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='05'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 06'
    INTO #FV06 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='06'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 07'
    INTO #FV07 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='07'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 08'
    INTO #FV08 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='08'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 09'
    INTO #FV09 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='09'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 11'
    INTO #FV11 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='11'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 12'
    INTO #FV12 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode IN('12','12A','12B','12C')
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 14'
    INTO #FV14 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='14'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 20'
    INTO #FV20 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='20'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 221'
    INTO #FV21 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='221'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 22'
    INTO #FV22 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='22'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT T3.FirmCode, T3.FirmName, SUM(T1.Quantity) as 'Cantidades', AVG(T1.Price) as 'Precio Venta Promedio', AVG(T1.StockPrice) as 'Costo Promedio', SUM(T1.LineTotal) as 'Venta Neta', AVG((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100) as 'Margen Almacen 23'
    INTO #FV23 FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry  INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode LEFT OUTER JOIN OMRC T3 ON T3.FirmCode = T2.FirmCode
    WHERE T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]'  and ISNULL(T0.Indicator,'') <> 'NL' and T0.DocType ='I' and T1.WhsCode ='23'
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    ---SELECCION DE DATOS
    SELECT T3.FirmCode, T3.FirmName as 'Proveedor',
    (Select T201.[Margen Almacen 01] From  #FV01 T201 where T201.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 01',
    (Select T202.[Margen Almacen 02] From  #FV02 T202 where T202.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 02',
    (Select T203.[Margen Almacen 03] From  #FV03 T203 where T203.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 03',
    (Select T204.[Margen Almacen 04] From  #FV04 T204 where T204.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 04',
    (Select T205.[Margen Almacen 05] From  #FV05 T205 where T205.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 05',
    (Select T206.[Margen Almacen 06] From  #FV06 T206 where T206.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 06',
    (Select T207.[Margen Almacen 07] From  #FV07 T207 where T207.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 07',
    (Select T208.[Margen Almacen 08] From  #FV08 T208 where T208.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 08',
    (Select T209.[Margen Almacen 09] From  #FV09 T209 where T209.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 09',
    (Select T211.[Margen Almacen 11] From  #FV11 T211 where T211.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 11',
    (Select T212.[Margen Almacen 12] From  #FV12 T212 where T212.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 12',
    (Select T214.[Margen Almacen 14] From  #FV14 T214 where T214.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 14',
    (Select T220.[Margen Almacen 20] From  #FV20 T220 where T220.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 20',
    (Select T221.[Margen Almacen 221] From  #FV21 T221 where T221.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 221',
    (Select T222.[Margen Almacen 22] From  #FV22 T222 where T222.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 22',
    (Select T223.[Margen Almacen 23] From  #FV23 T223 where T223.[FirmCode] = T3.FirmCode) as 'Margen Venta Local 23'
    INTO #RESULT FROM OITM T2 LEFT OUTER JOIN OMRC T3 ON T3.FirmCode =T2.FirmCode
    GROUP BY T3.FirmCode, T3.FirmName
    ORDER BY T3.FirmName
    SELECT * FROM #RESULT where isnull([Margen Venta Local 01],0) <> 0
    or isnull([Margen Venta Local 02], 0) <> 0
    or isnull([Margen Venta Local 03], 0) <> 0
    or isnull([Margen Venta Local 04], 0) <> 0
    or isnull([Margen Venta Local 05], 0) <> 0
    or isnull([Margen Venta Local 06], 0) <> 0
    or isnull([Margen Venta Local 07], 0) <> 0
    or isnull([Margen Venta Local 08], 0) <> 0
    or isnull([Margen Venta Local 09], 0) <> 0
    or isnull([Margen Venta Local 11], 0) <> 0
    or isnull([Margen Venta Local 12], 0) <> 0
    or isnull([Margen Venta Local 14], 0) <> 0
    or isnull([Margen Venta Local 20], 0) <> 0
    or isnull([Margen Venta Local 221], 0) <> 0
    or isnull([Margen Venta Local 22], 0) <> 0
    or isnull([Margen Venta Local 23], 0) <> 0
    ---FIN
    Agradeciendo vuestra ayuda.

    Buenas Tardes Eloy
    Al revisar todas las transacciones una a una, ninguna de ellas en el campo T1.LineTotal tiene como resultado el valor 0 ya que el campo T1.LineTotal es el monto neto de la venta (sin impuestos) y este nunca es 0 ya que tenemos validaciones antes de crear el documento.
    El valor 0 aparece como resultado de esta operación ((1-((T1.Quantity*T1.StockPrice)/T1.LineTotal))*100), ya que en varios ventas se vendió al mismo precio del costo del producto debido a promociones o liquidaciones de stock, por lo tanto el resultado 0 en dicha operación es correcto.
    Cuando a estas operación le aplico la función AVG para resumir datos comienza el problema.
    Que me sugieres que realice?
    Agradeciendo tu ayuda.

  • How to fix Login failed for user ''. (Microsoft SQL Server, Error: 18456)in windows 2008?

    Hi All,
    we are facing the Login fails issue .
    how to resolve the bellow error , could you please suggested the possible ways .. ASAP
    TITLE: Connect to Server
    Cannot connect to ..
    ADDITIONAL INFORMATION:
    Login failed for user '  domain\name'. (Microsoft SQL Server, Error: 18456)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18456&LinkId=20476
    BUTTONS:
    OK
    Log Name:      Application
    Source:        MSSQLSERVER
    Date:          10/6/2011 1:56:28 PM
    Event ID:      18456
    Task Category: Logon
    Level:         Information
    Keywords:      Classic,Audit Failure
    User:          domain\name
    Computer:      
    Description:
    Login failed for user '  domain\name'. Reason: Token-based server access validation failed with an infrastructure error. Check for previous errors. [CLIENT: <local machine>]
    RAM

    I was hitting myself in the head with this problem for a couple of minutes.... Everything was fine on the DC and Domain itself.. I added the Domain admins Group Principal for which I am part of... I was getting this error  ... Long History... Short
     (Right Click and Run as Administrator took care of this for me..) UAC was the cause of the problem.
    Cannot connect to XX-DB-XX3.
    ===================================
    Login failed for user 'XXXXS\XXas'. (.Net SqlClient Data Provider)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18456&LinkId=20476
    Server Name: XX-DB-XX3
    Error Number: 18456
    Severity: 14
    State: 1
    Line Number: 65536
    Program Location:
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
       at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
       at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.SqlClient.SqlConnection.Open()
       at Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ValidateConnection(UIConnectionInfo ci, IServerType server)
       at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()

Maybe you are looking for