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 8332611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:46:21+00:00 2026-06-09T02:46:21+00:00

I am trying to print a particular column from a table in a message

  • 0

I am trying to print a particular column from a table in a message to the user.
Here’s the table example

StateCode  |   EffectiveDate   |   ExpirationDate
---------------------------------------------
  AK       |   2011-12-31      |   2012-12-31
  AL       |   2011-12-31      |   2015-12-31

and so on for all states. What I’d like to do is select that the GETDATE() is not between the EffectiveDate and ExpirationDate and print a message to the user. The Select Statement I have works but if more than one state is returned it crashes. Any way to save a list and then print that? or another approach I can take

Heres the Select Query I am using now that works for 1 state returned

DECLARE @missingStates varChar(30)
SET @missingStates = Select StateCode FROM StateTable
   WHERE GETDATE() NOT Between StateTable.EffectiveDate AND StateTable.ExpirationDate

PRINT 'States Missing Effective Models'
PRINT @missingStates

Thanks for any Help

  • 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-09T02:46:23+00:00Added an answer on June 9, 2026 at 2:46 am

    You have to combine multiple values into a single variable:

    DECLARE @missingStates varChar(30)
    SET @missingStates = ''
    
     Select @missingStates = @missingStates + Code + ' ' FROM StateTable
       WHERE GETDATE() NOT Between StateTable.EffectiveDate AND StateTable.ExpirationDate
    
    PRINT 'States Missing Effective Models'
    PRINT @missingStates
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to print out lines from a file which match a particular
I am trying to modify the content of a particular column of a table
I am trying to print a particular text using awk if string is empty.
Im trying to print the realtime output based on user input for a search.
I'm trying to print a Hello, AOP! message whenever Guice/AOP Alliance intercepts a method
I need to print out a particular record, which is the 3d from the
I am trying to Sync a bunch of Videos I've retrieved from a particular
i am trying to acquire unix_timestamp value for a particular timestamp column. but i
I am trying to print a particular area on my webpage by using jQuery
Im trying print Excel file data on a page. To do it i used

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.