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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:57:27+00:00 2026-05-16T11:57:27+00:00

Ok, no idea why a multi-billion dollar company skimps on array functions for their

  • 0

Ok, no idea why a multi-billion dollar company skimps on array functions for their flagship SQL servers This is why people use MySQL Server. Ok, enough ranting. Using SQL 2005.

Let’s say i received an array via checkbox from another page using the querystring method:

intTask = request.querystring("task")

For this example, intTask = “1,3,5”

Then I used the query

SELECT user.Task FROM user WHERE (user.Task in (" & intTask & "))

This gives an error of:

Conversion failed when converting the nvarchar value '1, 2' to data type int

The array in the User.task column here = 1,2. NVARCHAR is the data type. intTask is a string. No idea why SQL is trying to convert the column to integers when its suppose to be a string comparison. I already know about the SQL injection vulnerability, that taken care of with another script for the page.

OK. Well how does one compare arrays using SQl Server 2005 ? I can’t seem to find any SQL functions that will iterate through 2 strings and compare for all matching values.

For example

intTask = 1,2

user.task = 3,5,7,2,9

Because of the 2’s, I should get a recordset because the 2’s exist in both arrays

UPDATE

Is there an SQL function that will handle two arrays and iterate through the arrays to find matching items. Something like:

intTask = “1,3,5”

user(“task”) = “3,5,2”

ARR1 = split(intTask,”,”)

ARR2 = split(user(“task”),”,”)

for i=0 to UBound(arr1)

for j=0 to UBound(arr2)

    if(arr1(i) = arr2(j)) then

       common_found = true

    end if

Next

Next

Thanks in advance

  • 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-16T11:57:27+00:00Added an answer on May 16, 2026 at 11:57 am

    The array in the User.task column here = 1,2. NVARCHAR is the data type.

    because 1,2 are 2 integers and your column is a nvarchar, use ‘1’,’2′, you might need to prefix win N

    take a look at Arrays and Lists in SQL Server 2005 and Beyond

    Here is a code example

    create table #test (id nvarchar(20))
    insert #test values('1,2')
    insert #test values('2,3')
    go
    

    works

    select * from #test
    where id in (N'1,2')
    

    will fail

    select * from #test
    where id in (1,2)
    

    Msg 245, Level 16, State 1, Line 1
    Conversion failed when converting the nvarchar value ‘1,2,3’ to data type int.

    If you are only using integers then use varchar, not nvarchar, nvarchar uses double the storage of varchar…of course if you properly normlized the Db you would not have these problems

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

Sidebar

Related Questions

any idea how if the following is possible in PHP as a single line
Any idea on how to unit test the views in ASP.NET MVC? I am
any idea which is the command for publish in msbuild corresponding to the one
Any idea how I express 'implements' in UML? I'm trying to write some actionscript
Any idea on how to check whether that list is a subset of another?
The idea is to move all of the right elements into the left and
Any idea why the following code doesn't print the amount of characters in the
Any idea how to return multiple variables from a function in ActionScript 3? Anything
Simple idea: I have two images that I want to merge, one is 500x500
Any idea how to render a PDF using iTextSharp so that it renders the

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.