Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8864289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:12:21+00:00 2026-06-14T16:12:21+00:00

This is what I am trying to accomplish: Check if database is read-only in

  • 0

This is what I am trying to accomplish:

Check if database is read-only in first step of SQL Server Agent job. If this is the case – exit the job.

So I figured I will use Advanced Properties for Job Step and select “Quit the job reporting success” for “On failure cation:”

But how does one fail T-SQL script without using RAISERROR()? Reason I don’t want to use RAISERROR() is because one needs to be a member of sysadmin server role to use it.

I found rather ugly approach that works – selecting something from the table that doesn’t exist, script looks like this:

declare @DBIsRO int;

SET @DBIsRO= (SELECT is_read_only
FROM sys.databases
WHERE name = 'test')

IF @DBIsRO=1 
   select * from dd -- table dd doesn't exist in current database

However, this just seems like a kludge and I am looking for a ‘proper’ approach.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:12:22+00:00Added an answer on June 14, 2026 at 4:12 pm

    Reread documentation:

    Severity levels from 0 through 18 can be specified by any user.
    Severity levels from 19 through 25 can only be specified by members of
    the sysadmin …

    You can do:

    raiserror( 'Readonly',16,1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Check out this picture to see what I am trying to accomplish. Basically I
I'm trying to accomplish this but I've got no clue about getting a GWT
I'm trying to accomplish this: strcat('red ', 'yellow ', 'white ') I expected to
I am trying to accomplish this: Consider a table view with Search Bar on
I'm trying to accomplish what's being demonstrated at this site for an experiment I'm
I am trying to accomplish something similar to what was described in this thread:
I am having a little trouble trying to accomplish this. Here is the gist
I'm trying to accomplish the following using CSS: <table border=1 width=300px> <tr> <td rowspan=2>This
I'm trying to determine if there is a way to accomplish this elegantly. I
I am stuck with using Dojo to accomplish this. Basically what I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.