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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:16:39+00:00 2026-05-14T22:16:39+00:00

I want to realize a query with the Visual Studio 2008 build in Query

  • 0

I want to realize a query with the Visual Studio 2008 build in Query Builder for a TableAdapter similar like following (MSSQL 2008):

select * from [MyDB].[dbo].[MyView] where UNIQUE_ID NOT IN ('MyUniqueID1','MyUniqueID2')

How do I have to set the Filter in my query in order to call it with the myTableAdapter.GetDataExceptUniqueIds(...) function?

I tried to set the filter to NOT IN (@ids) and called it with

string[] uniqueIds = ...;
myTableAdapter.GetDataExceptUniqueIds(String.Join("','", uniqueIds));

and with

StringBuilder sb = new StringBuilder("'");
sb.Append(String.Join("','", uniqueIds));
sb.Append("'");
return myTableAdapter.GetDataExceptUniqueIds(sb.ToString());

but both failed

  • 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-14T22:16:40+00:00Added an answer on May 14, 2026 at 10:16 pm

    You cannot use dynamic parameters in a SELECT … WHERE [NOT] IN list

    WORKAROUND:

    Create a table function, similar to the following function:

    CREATE FUNCTION dbo.ParmsToTable(@Parameters varchar(4000))
    returns @result TABLE (Value varchar(100))
    AS  
    begin
         DECLARE @pTable table
              (
              Value varchar(100)
              )
    
         DECLARE @Value varchar(100), @Pos int
    
         SET @Parameters = LTRIM(RTRIM(@Parameters))+ ','
         SET @Pos = CHARINDEX(',', @Parameters, 1)
    
         IF REPLACE(@Parameters, ',', '') <> ''
         BEGIN
              WHILE @Pos > 0
              BEGIN
                   SET @Value = LTRIM(RTRIM(LEFT(@Parameters, @Pos - 1)))
                   IF @Value <> ''
                   BEGIN
                        INSERT INTO @pTable (Value) VALUES (@Value) 
                   END
                   SET @Parameters = RIGHT(@Parameters, LEN(@Parameters) - @Pos)
                   SET @Pos = CHARINDEX(',', @Parameters, 1)
    
              END
         END    
         INSERT @result
         SELECT value
            FROM @pTable 
         RETURN
    END    
    

    and change your TableAdapter as follows:

    select * from [MyDB].[dbo].[MyView] where UNIQUE_ID NOT IN
    (select value from dbo.ParmsToTable(@p)  )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a dynamic populated treeview from mysql database in PHP. I
I want to update rows of a table in a specific order, like one
I have a query that returns one row. However, I want to invert the
I have a simple object hierarchy, and I want to query each of the
I'm following on from a previous question . The answer I accepted involves using
I want to realize a login for my site. I basically copied and pasted
I want to use a temp directory that will be unique to this build.
If all tables I want to delete from have the column gamer_id can i
for the purpose of a module that I began to realize, I want to
I want to left join two tables. My problem is that the table from

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.