Match column between two tables

Shambhu Rai 1,406 Reputation points
2023-10-13T18:20:07.4133333+00:00

Hi expert wants to match data between two table or not Create table table1(col varchar (20)) Create table table2(col varchar(20)) Insert into table1 values (20) Insert into table2 values (20) Insert into table1 values ('test') Insert into table2 values ('test1') Expected output Output1 ='row 2 data missmatch' Scenario 2 Create table table1(col varchar (20)) Create table table2(col varchar(20)) Insert into table1 values (20) Insert into table2 values (20) Insert into table1 values ('test') Insert into table2 values ('test') Expected output ='output matched'

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,933 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 41,571 Reputation points
    2023-10-13T19:08:19.4766667+00:00

    Hi expert wants to match data between two table or not

    "To be or not to be".

    Your post is very unclear, the "SQL code" is hard to read and the logic for "expected output" is missing.

    Please post the missing details and remove unrelated tags.

    0 comments No comments

  2. Bruce (SqlWork.com) 58,126 Reputation points
    2023-10-13T19:58:16.6766667+00:00

    first:

    Create table table1(col bar chart (20))

    is not valid syntax

    second, your insert mix number and string for the same column. also an error.

    third, you appear to want to match on row number, but sql table rows do not have a row number, without an order by clause the order is undefined. you need to add insert order column.

    if you don't care about the order then just use left and right joins