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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:30:38+00:00 2026-05-16T04:30:38+00:00

Please consider the following scripts. Create Table: IF OBJECT_ID(‘Colortable’) IS NOT NULL DROP TABLE

  • 0

Please consider the following scripts.

Create Table:

IF OBJECT_ID('Colortable') IS NOT NULL
  DROP TABLE ColorTable

CREATE TABLE Colortable (Color VARCHAR(32))
GO

Insert some values:

SET  NOCOUNT ON

INSERT Colortable
  SELECT 'red'

INSERT Colortable
  SELECT 'orange'

INSERT Colortable
  SELECT 'blue'

INSERT Colortable
  SELECT 'green'
GO

Create my Variable (which will become a paramter in SSRS) automatically:

DECLARE @colors VARCHAR(1024)

SELECT @colors =
         COALESCE(
           @colors + '''' + ',' + '''', '') +
         Color
FROM Colortable

When I use “Select @colors” I get the following:

'red','orange','blue','green'

However, my queries do not work as expected.

SELECT *
FROM colortable
WHERE Color IN ('red', 'orange', 'blue', 'green') -- Returns 4 rows. 


SELECT *
FROM colortable
WHERE Color IN (@colors) -- Returns 0 Rows

Can anyone tell me why? I am trying to generate a string of values so that this script will work in SSRS and SSMS (or whatever tool I am using).

  • 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-16T04:30:39+00:00Added an answer on May 16, 2026 at 4:30 am

    i think you can use sp_executesql may work for you

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

Sidebar

Ask A Question

Stats

  • Questions 498k
  • Answers 498k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer See section "6.26.1 Value Conversions" in the Scala Language Specification… May 16, 2026 at 12:25 pm
  • Editorial Team
    Editorial Team added an answer Yes I believe this is consistent behaviour because that instance… May 16, 2026 at 12:25 pm
  • Editorial Team
    Editorial Team added an answer Browsers started supporting it. Also, ICO files are an old… May 16, 2026 at 12:25 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Please consider the following code and the explanation from this Mozilla tutorial Using web
Please consider following code: 1. uint16 a = 0x0001; if(a < 0x0002) { //
Please consider the following: <td style=width: 500px;> <div style=width: 400px;>SomeContent</div> </td> For some reason,
Consider the following PowerShell script: function Alpha { # write-output 'Uncomment this line and
What are the best tools/programming-techniques for following a complicated nesting of symlinks and completely
I've recently been playing with allot of JavaScript and started to consider that I
Consider I modify the way files are stored in a system, where every file
I have a WPF Datagrid binded with list of interface objects. Consider, ClsEmployee class
I want to meassure the throughput of a link using Windows build-in FTP tool
I have two files and the content is as follows: alt text http://img144.imageshack.us/img144/4423/screencapture2b.png alt

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.