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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:11:49+00:00 2026-06-08T09:11:49+00:00

I have an table at my SQLSERVER(2008R2) called Clients , it has ClientID and

  • 0

I have an table at my SQLSERVER(2008R2) called “Clients” , it has ClientID and Address.
I’d like to make a query/SP which does the following:

  1. Recieves a list of addresses.
  2. Deletes the records with these address.
  3. Returns a list of the addresses that can’t be deleted(row not found, etc).
  4. Returns the number of deleted rows.

My application is C#-ASP.NET based application.
I’ve thought of the following solutions:

  1. Make an SP that recieves a list of addresses, and then tries to delete them, and if it can’t delete it , to add it to some sort of array/list. – my problem with this solution is that I’m not familiar with how lists works at SQLSERVER(2008R2).

  2. Work with DataTable , select the data I need from the DB, and delete it with SqlDataAdapter, and check whats the rows which have changed via RowState.

Example of my DataBase:

Client ID    Address

111111111  'foo st. 2'

222222222  'foo bld 1'

333333333  'foo rd 22'

444444444  'foo st. 1'

Example of the input:

input list{'foo st. 2','foo bld 1','foo st 22','foo st 1'} – the last two items aren’t exist at the table above, So i would like my SP (or any other method of solution) to return:

'Deleted rows: 2' //thats not a problem
'list of the records which weren't removed: {'foo st 22','foo st 1'} //thats a problem..

Hope I made myself as clear as possible.

  • 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-08T09:11:51+00:00Added an answer on June 8, 2026 at 9:11 am

    I don’t think you can find which items aren’t deleted by a delete statement in sql. Firstly you need a way to split your string by comma’s. I’d use a table function like what’s suggested in this question

    once you have that then you need to select before you delete into a temp table, then delete the records that are there, then return the missing records:

    DECLARE @SplitString TABLE
    (
        value varchar(MAX)
    )
    
    DECLARE @MissingRecords TABLE
    (
        value varchar(MAX)
    )
    
    
    INSERT INTO @SplitString
    SELECT  part
    FROM    dbo.fSplitString('foo st 22, foo st 1', ',')
    
    
    
    SELECT  value
    FROM    @SplitString
    WHERE   value NOT IN (  SELECT Address
                            FROM TableName
                         )
    
    DELETE  FROM TableName
    WHERE   Address IN (SELECT Value FROM @SplitString)
    
    SELECT  *
    FROM    @MissingRecords
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SqlServer 2008 table which has a Primary Key (IsIdentity=Yes) and three
A Clarification, if I have a table that has the following fields.... ProductCategoryID, CategoryName,
I have a table in SQL Server called [Donations] that contains donations given by
I have this table in a SQL Server 2008 R2 instance which I have
I have a database table in Sql Server 2008 R2 which contains data stored
I have a database table (SQL Server 2008 R2 Express edition) that has a
I have a sql server 2008R2 with a database that have table with thousands
I have a positions table in SQL Server 2008R2 (definition below). In the system
need some your help with a query. I have a table Managers (ManagerId, ManagerName)
In a SQL Server 2008R2 sproc, I have the following code to calculate 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.