I am using VS2005 and SQL Server 2005.
I am trying to execute multiple sql statements on two sql tables, meaning which I need to do more than a single check on the two tables.
The two tables are:
Table1: UserID, Username.
Table2: UserID, Status.
The following are the checks that I need to perform, but I do not know what is the exact SQL query I need.
-
Users that exist in Table1 should exist in Table2
-
Users that exist is Table1 should not have
STATUS=DELETEin Table2 - Users that do not have
STATUS=DELETEin Table2 should exist in Table1
May I know how do I form this checks in to SQL queries and execute them in my VS Sqldatasource?
After which store the results in a variable and display them in GridView table.
Thank You very much for the help.
So you have 3 cases you want to catch:
These three scenarios are covered in the WHERE clause below in that order.
Edit: In response to the OP’s comment, here is a modified version that will insert data into
table3based on case #1. Assume thattable3is a table that has two columns,userIDandproblem.