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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T06:24:43+00:00 2026-05-19T06:24:43+00:00

How can I make the following sql statement part of the SET in my

  • 0

How can I make the following sql statement part of the “SET” in my query? I want to pull out a list in a column and have my “SET” run against that. That way my “SET” isn’t just one variable but rather a list to run against. Make sence?

DECLARE @Item as char(32)
declare @result varchar(max);
SET @Item = '034100-3JK'; 

I want to use something like the following to have it query against instead of the 034100-3JK:

select distinct
        a.t_sitm as StartItem
from 
        ttibom010101 as a 
        INNER JOIN ttiitm001101 as b on a.t_sitm = b.t_item 
where 
        b.t_ctyp != 'TOP'
        and b.t_ctyp != 'SUB'
  • 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-05-19T06:24:44+00:00Added an answer on May 19, 2026 at 6:24 am

    EDITED: Based on asker’s comments

    I noticed that you are explicitly writing out the item code (or ID, whatever you want to call it). If you have a static list of codes that cannot be easily retrieved from your database, you can do something like this:

    DECLARE @Items TABLE
    (
      item varchar(10)
    )
    INSERT INTO @Items
    VALUES ('034007-3CL'),
    ('next_code'),
    ('next_next_code')
    

    Alternatively, if that list of codes can be grabbed easily:

    DECLARE @Items TABLE
    (
      item varchar(10)
    )
    INSERT INTO @Items
    SELECT a.items
    FROM mytable AS a
    WHERE a.column = condition
    

    Then you can use the variable like a normal table:

    select 
       a.t_sitm as StartItem
       ,a.t_mitm
       ,a.t_sitm
       ,b.t_ctyp
       ,a.t_qana
    from 
       ttibom010101 as a 
       INNER JOIN ttiitm001101 as b on a.t_sitm = b.t_item 
       INNER JOIN @items as c on a.t_sitm = c.item
    where 
       b.t_ctyp != 'TOP'
       and b.t_ctyp != 'SUB'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Who can help me make the following query work... Both tables have the fields
How can I make the following SQL a Linq query: SELECT * FROM ORDERS
In sql, I can make an if statement like the following If MY_STATE in
How do I make the following T-SQL statement legal? I can copy the subquery
Can someone tell me how I can make the following output? I have a
The following code prints out 10 . How can I make it print out
I'm trying to get the following SQL statement to work: UPDATE myschema.tableA update_tableA SET
I have the following sql statement - it's trying to find all the zipcodes
How can I make a nested select statment with LLBLGen? I have the following
I have the following SQL query that runs fairly well, however it seems to

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.