Business Apps
6 TopicsCatch Error in a SQL Server Logon Trigger
I have written a Logon trigger in a SQL Server to control logon authorization. ALTER TRIGGER [LOG_TRG_01] ON ALL SERVER WITH EXECUTE AS 'SA' FOR LOGON AS BEGIN if ORIGINAL_LOGIN() = 'sa' begin return; end; if ORIGINAL_LOGIN() = 'OMEGACAEVDEV1' begin -- not allowed to logon rollback; end; -- Insert Trail EXEC [OmegaCoreAudit].[OMEGACA].[P_ACC_UNF_TRAIL] 0, 'trail_details', 'ip', 'server', 'db', 0 ; END GO It does (as expected): OMEGACAEVDEV1 is not allowed to logon OMEGACAEVDEV2 is allowed to logon An audit event is inserted by proc P_ACC_UNF_TRAIL in a table for both users. All three above I want to stay this way ! But I need to have error handling in it, so that in case of whatever error the login is allowed to login - but keeping a record on another table named SYS_ERROR_LOG (with error details). In this trigger I have intentionally provoked an error by "select 10/0" The new trigger is: ALTER TRIGGER [LOG_TRG_02] ON ALL SERVER WITH EXECUTE AS 'SA' FOR LOGON AS BEGIN BEGIN TRY if ORIGINAL_LOGIN() = 'sa' begin return; end; --provoke error select 10/0; if ORIGINAL_LOGIN() = 'OMEGACAEVDEV1' begin -- not allowed to logon rollback; end; -- Insert Trail EXEC [OmegaCoreAudit].[OMEGACA].[P_ACC_UNF_TRAIL] 0, 'trail_details', 'ip', 'server', 'db', 0 ; END TRY BEGIN CATCH Insert into OmegaCoreAudit.OMEGACA.SYS_ERROR_LOG ([LOGIN_USER_NAME], [DB_USER_NAME], [USERHOST], [IP_ADDRESS], [OS_USER], [BG_JOB_ID], [ERROR_DATA]) values ('LOGIN_NAME', 'USER_NAME', 'USER_HOST', 'IP', NULL, NULL, 'ERROR_MESSAGE'); END CATCH END GO In the above code "if ORIGINAL_LOGIN() = 'OMEGACAEVDEV1'" represents a simplified version of a wider authorization process. Problem: CATCH is not working. Both users are not allowed to logon ("Logon failed for login '[user]' due to trigger execution") No record is written on table SYS_ERROR_LOG. I was expecting one for each user. What can I do to fix this problem? best regards AltinSolved384Views0likes13Comments百家乐客服【微QGY889889】
SQL Server 是一个关系数据库管理系统。它最初是由Microsoft Sybase 和Ashton-Tate三家公司共同开发的,于 Microsoft SQL Server Microsoft SQL Server 1988 年推出了第一个OS/2 版本。在Windows NT 推出后,Microsoft与Sybase 在SQL Server 的开发上就分道扬镳了,Microsoft 将SQL Server 移植到Windows NT系统上,专注于开发推广SQL Server 的Windows NT 版本。Sybase 则较专注于SQL Server在UNIX 操作系统上的应用。 SQL Server 2000 是Microsoft 公司推出的SQL Server 数据库管理系统,该版本继承了SQL Server 7.0 版本的优点,同时又比它增加了许多更先进的功能。具有使用方便可伸缩性好与相关软件集成程度高等优点,可跨越从运行Microsoft Windows 98 的膝上型电脑到运行Microsoft Windows 2000 的大型多处理器的服务器等多种平台使用。 SQL Server 2005 SQL Server 2005 是一个全面的数据库平台,使用集成的商业智能 (BI) 工具提供了企业级的数据管理。SQL Server 2005 数据库引擎为关系型数据和结构化数据提供了更安全可靠的存储功能,使您可以构建和管理用于业务的高可用和高性能的数据应用程序。 SQL Server 2005 数据引擎是本企业数据管理解决方案的核心。此外 SQL Server 2005 结合了分析、报表、集成和通知功能。这使您的企业可以构建和部署经济有效的 BI 解决方案,帮助您的团队通过记分卡、Dashboard、Web services 和移动设备将数据应用推向业务的各个领域。 与 Microsoft Visual Studio、Microsoft Office System 以及新的开发工具包(包括 Business Intelligence Development Studio)的紧密集成使 SQL Server 2005 与众不同。无论您是开发人员、数据库管理员、信息工作者还是决策者,SQL Server 2005 都可以为您提供创新的解决方案,帮助您从数据中更多地获益。 SQL Server 2008 SQL Server 2008是一个重大的产品版本,它推出了许多新的特性和关键的改进,使得它成为至今为止的最强大 和最全面的SQL Server版本。这篇文章详细介绍了Microsoft SQL Server 2008中的新的特性、优点和功能。 微软的这个数据平台满足这些数据爆炸和下一代数据驱动应用程序的需求,支持数据平台愿景:关键任务企业数据平台、动态开发、关系数据和商业智能。 SQL Server的愿景 许多因素致使产生了信息存储爆炸。有了新的信息类型,例如图片和视频的数字化,和从RFID标签获得的传感器信息,公司的数字信息的数量在急剧增长。遵守规范和全球化的发展要求信息存储的安全性和在任何时候都可用。同时,磁盘存储的成本显著地降低了,使得公司投资的每一美元可以存储更多的数据。用户必须快速的在大量的数据中找到相关的信息。此外,他们想在任何设备上使用这个信息,并且计划每天使用,例如Microsoft Office系统应用程序。对数据爆炸和用户期望值的增加的管理为公司制造了许多挑战。 Microsoft 数据平台愿景提供了一个解决方案来满足这些需求,这个解决方案就是公司可以使用存储和管理许多数据类型,包括XML、e-mail、时间/日历、文件、文档、地理等等,同时提供一个丰富的服务集合来与数据交互作用:搜索、查询、数据分析、报表、数据整合,和强大的同步功能。用户可以访问从创建到存档于任何设备的信息,从桌面到移动设备的信息204Views0likes0Commentssql server management studio 2017 An existing connection was forcibly closed by the remote host
hi, hope someone can help me as I have an issue with my sql server management studio 2017. Since a few days I get the message "An existing connection was forcibly closed by the remote host" and thus I cannot execute scripts anymore. The sql sms is installed on my laptop and is a 2017 version. The thing is, the db that is giving issues is a sql server 2012 version (installed on a sql server cluster) but until recently this was never a problem with the way of working. Any idea how to solve this??? Thanks in advance... M2.8KViews0likes1CommentSQL Server Professional Career Profile - Jaap Brasser
We just featured a career profile of MVP JaapBrasser who focuses on Powershell, Active Directory, SQL Server, Windows Server and many other technologies. If you're interested on his take on what a successful career in the cloud looks like, read the post in the IT Resources & Training community here: https://techcommunity.microsoft.com/t5/IT-Resources-Training/Cloud-Careers-Friday-Feature-Jaap-Brasser/m-p/54236#M841.6KViews2likes0CommentsStored Procedure with ASP.NET Web Forms Grid View for sorting table records
In one of our recent project, we have used stored procedure to sort items in an ASP.NET Web Forms Grid View. Here is how we have achieved this: https://www.linkedin.com/pulse/using-sql-stored-procedure-sort-items-database-table-kiril-iliev2.2KViews0likes0Comments