Forum Widgets
Latest Discussions
Catch 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 AltinSolvedakaraulliDec 05, 2024Brass Contributor383Views0likes13CommentsCritical Update for SQL Server 2016 MSVCRT Prerequisites KB3164398 – error 0x80070643
Critical Update for SQL Server 2016 MSVCRT Prerequisites KB3164398 – error 0x80070643? anyone have any ideas how this works with windows 10? I have this problem since June!jmsolanesSep 05, 2016Brass Contributor7.9KViews3likes9CommentsSample Always Encrypted application?
Is there a sample Microsoft web application/site for playing with and demoing Always encrypted? I've looked in the usual places. I can build my own, but would like to be internet lazy :catvery-happy: and see one that someone better at this has already done. Clarification: I am not looking for an "always encrypted application". I'm looking for pre-existing demos/sites like we have for other features. I can build my own. But I'm looking for content that may already exist for community use. Something, for instances, like a Wide World Importers or Adventureworks or Contoso. Solved7.2KViews1like9CommentsCleanup of auto created statistics
Hello everyone, during annual database checkup i found that there were a lot of auto created statistics, which weren't used. It seems that DBMS doesn't cleanup unused auto created statistic on his own. i guess i can drop them with the following query: DROP STATISTICS Schema.TableName._WA_Sys_XXXXXXXXXXXXXXXXXXXX But i am still thinking whether it is safe, about impact on the performance. Has anybody had any experience with that?SolvedKarolFerekDec 13, 2024Copper Contributor340Views0likes8CommentsLooking for SQL sessions at Microsoft Ignite?
The Microsoft Tech Community is the official online community for Microsoft Ignite! Join in conversations about sessions you're excited to attend by clicking here: https://techcommunity.microsoft.com/t5/forums/filteredbylabelpage/board-id/MicrosoftIgniteContent/label-name/sql%20server These are all of the conversations aligned to each Breakout, each Theater session that cover SQL Server. This is not an exhaustive list - there is more to come and updates are happening on MyIgnite every day up until the event. We will be embedding the final decks and recordings here once they are available.AnnaChuSep 09, 2016Silver Contributor2.2KViews0likes7CommentsSelect from sys.fn_get_audit_file without CONTROL SERVER
Hi We are pulling MS SQL Server audit records using sys.fn_get_audit_file Server Login MYUSER Not mapped to any non-system database Related DB User on database "master" is: myuser Granted CONTROL SERVER and (of course) Connect Can execute: select * from sys.fn_get_audit_file(<path>, default, default) Problem: Granting CONTROL SERVER to a user that needs to only SELECT the audit records - and doing nothing else - looks too much. So we tried: Revoke CONTROL SERVER form Server Login MYUSER On database "master", grant DB User “myuser” SELECT on sys.fn_get_audit_file Now the Server Login MYUSER cannot execute: select * from sys.fn_get_audit_file(<path>, default, default) Error Message: Msg 300, Level 14, State 1, Line 1 CONTROL SERVER permission was denied on object 'server', database 'master'. Msg 297, Level 16, State 1, Line 1 The user does not have permission to perform this action. Question: Is it possible to SELECT from sys.fn_get_audit_file without having the CONTROL SERVER ? best regards AltinSolvedakaraulliFeb 29, 2024Brass Contributor1.1KViews1like6CommentsSchedule an SSIS package
Hi team, I created multiple packages in SSIS. Source connection manager is Excel/ Oracle Database and Target connection manager is ODBC(Snowflake cloud) so we created packages and containers. Now, we want to schedule those. I tried by deploying a project in SSMS and by creating a new job. In the job, I added job steps and gave a schedule time. Every time it is getting failed due to the below error. If I use target connection manager OLE DB(SQL) I'm able to schedule the packages successfully. Date 3/22/2022 9:49:16 AM Log Job History (JOB) Step ID Server DESKTOP-2B7TI5T Job Name JOB Step Name Duration 00:00:03 Sql Severity 0 Sql Message ID 0 Operator Emailed Operator Net sent Operator Paged Retries Attempted 0 Message : The job failed. The Job was invoked by User DESKTOP-2B7TI5T\Rajeswari. The last step to run was step 1 (AR). Below are the SQL server management studio Details: SQL Server Management Studio 15.0.18358.0 SQL Server Management Objects (SMO) 16.100.44091.28 Microsoft Analysis Services Client Tools 15.0.19260.0 Microsoft Data Access Components (MDAC) 10.0.22000.1 Microsoft MSXML 3.0 6.0 Microsoft .NET Framework 4.0.30319.42000 Operating System 10.0.22000 Please guide me how to achieve this with brief steps. Thanks.chvnpradeep2492Mar 22, 2022Copper Contributor2.1KViews0likes6CommentsSQL Server Certifications
Recently, I have spoken at several user groups and/or SQL Saturday events on SQL Server Certifications. I have posted my powerpoint presentation below. But I thought I would give a quick overview. First you will need to start by earning one of the four eight MCSA cerfitications. You have the classic MCSA: SQL Server 2012/2014 certification which has been available for several years. Or, you could obtain one of the newer SQL Server 2016 MCSA certifications in either Database Development, Database Administration, or BI Development. (Four new SQL Certification introduced in Spring 2017 are listed at the bottom of this post.) I really like the new streamlined 2016 certifications because you can focus on your area of expertise and you only need two exams. With the SQL Server 2012, you needed a broader knowledge base to earn the MCSA certification. I for one had difficulty with the 70-463 exam as I do not work with Data Warehousing on a regular basis, but I had to learn that material for the exam. If you still want to demonstrate your breadth of knowledge, there is nothing to stop you from earning more than one MCSA. Once you have earned your MCSA, it is now even easier to earn you MCSE. You only need to take ONE of the exams from the electives listed in the next picture to obtain an MCSE. What is even better is that your MCSE no longer expires. However, you can re-earn the MCSE by taking an additional elective exam in subsequent years. I really like this option, because in years past I would need to study older material to renew my MCSE. Now, I can learn new skills for new exams each year while I re-earn my MCSE. UPDATE: (March 22, 2017) You can now retake an exam that you have already passed to re-earn your MCSE certification, however you must wait at least 365 days from when you passed the exam before being allowed to take the exam again. You can still earn the two older MCSE certifications (Database Developer or BI Developer) until March 31, 2017. After that only the MCSE: Data Management & Analytics will be available. Don't forget that once you pass an exam or obtain a certification, head over to the Acclaim website to pick up your shiny, new badge that you can use on social media to show your freinds, family, and co-workers. UPDATE: (April 12, 2017) Four new MCSA certifications were announced today. (Update May 23, 2017) Names of new MCSA certifications have changed.Solved19KViews4likes5CommentsDisk size considerations
Hello. Could you suggest if there are any considerations regarding disk size for database files? Are there any limitations from MS SQL? Version that we use is SQL 2014 SP1. What we need is handling 200+ SharePoint content databases of total size about 16TB. So the question is whether it will be better from the SQL perspective to have, say, 4 x 4TB logical disks instead of one 16TB disk. Or are there only hardware considerations to take into account, but not SQL-related? AlexAleksandr SapozhkovMar 28, 2017Copper Contributor7.3KViews1like4Comments
Resources
Tags
- Business Apps6 Topics
- sql server3 Topics
- Sql Enterprise1 Topic
- Question Format1 Topic
- sql 20161 Topic
- change tracking1 Topic
- ssis1 Topic
- partitioning1 Topic
- unattended1 Topic
- Feature state notification1 Topic