Solved

SQL Update sys_logins table

Posted on 2013-11-21
1
749 Views
Last Modified: 2013-11-26
Is there a way for me to update the sys.sql_logins table?  I would like to turn on password policy and expiration.  However, I do not want to do it one by one.  I would like to be able to do a mass update with user that does not have this on.  Any ideas?

Update sys.sql_logins
set is_policy_checked = 1,
      is_expiration_checked = 1
where is_policy_Checked = 1 or is_expiration_checked = 1

Getting the following error.

Ad hoc updates to system catalogs are not allowed.
0
Comment
Question by:holemania
1 Comment
 
LVL 22

Accepted Solution

by:
Steve Wales earned 500 total points
Comment Utility
You aren't allowed to directly update the system tables.

Run this script, sending output to text, instead of grid:

select 'ALTER LOGIN ['+name+'] WITH CHECK_EXPIRATION=ON, CHECK_POLICY=ON'
from sys.sql_logins
where is_policy_Checked = 1 or is_expiration_checked = 1

Open in new window


Check your output, remove or modify any you don't need, copy that into a query window and run it.

Will do exactly the thing you want done without the direct update of the system catalog tables.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now