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

  • Home
  • SEARCH
  • 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 8872489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:14:02+00:00 2026-06-14T18:14:02+00:00

How can I declare int array in SQL Server? After fill it, I would

  • 0

How can I declare int array in SQL Server?

After fill it, I would like to use it in IN statement to check, how can I change my code?

declare @mode int =1 
declare @acceptedFormTypeIds table (id int)

case @mode
    when 1 then
        insert into @acceptedFormTypeIds(id) values (1, 2, 3, 4)
    when 2 then 
        insert into @acceptedFormTypeIds(id) values (1, 3)
    when 3 then 
        insert into @acceptedFormTypeIds(id) values (2, 4)
    else
        insert into @acceptedFormTypeIds(id) values (1, 2, 3, 4)
end

...

WHERE
    tFRM.SendDate between @datefrom and @dateto
    and tFRM.TemplateId IN @acceptedFormTypeIds.id
  • 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-14T18:14:03+00:00Added an answer on June 14, 2026 at 6:14 pm

    In databases, don’t ever think of arrays. Think of sets, or tables.

    The structure of the insert statement should be

    insert into @acceptedFormTypeIds(id) values (1), (2), (3), (4)
    

    You can use if

    if @mode=2
    begin
       insert into @acceptedFormTypeIds(id) values (1), (3)
    end
    else
    begin
        if @mode=3
        begin
           insert into @acceptedFormTypeIds(id) values (2), (4)
        end
        else
        begin
           insert into @acceptedFormTypeIds(id) values (1), (2), (3), (4)
        end
    end
    

    However, it may be worth having a FormTypeModeAccepted table depending on your usage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in C I can simply declare an array like this: int array[500]; to declare
How can i declare an array like this one: int array[1000000]; as a static
I would like to get a two dimensional int array arr that I can
Can I declare an int array, then initialize it with chars? I'm trying to
I need to declare 3d array variable but can't. int[][][] ary = new int[5][2][];
In C++, I can create a array like... int* a = new int[10]; in
I have this sql statement: DECLARE @option_id INT; SELECT DISTINCT product_options.option_id INTO @option_id FROM
In PHP I remember I can do something like substr(string,start,length) now I declare int
I am trying to declare a dynamic int array like below: int n; int
In C#, I can declare an array variable like this object[] Parameters; and initialize

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.