Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 comapre 2 table output within SP

Author  Topic 

ajmaly
Starting Member

11 Posts

Posted - 2010-07-29 : 11:37:08
Hello,
Please help me writing a stored procedure with below situation,

Table A output,

AJMAL
TAMANNA
TINKU

Table B output,

AJMAL
TAMANNA
TINKU1


If Table A and Table B each row value match with each other, then return "YES", else "NO"


ajmal

X002548
Not Just a Number

15586 Posts

Posted - 2010-07-29 : 12:24:53
[code]

CREATE TABLE #TableA (col1 varchar(25))
CREATE TABLE #TableB (col1 varchar(25))
GO

INSERT INTO #TableA (col1)
SELECT 'AJMAL' UNION ALL
SELECT 'TAMANNA' UNION ALL
SELECT 'TINKU ' UNION ALL
SELECT 'Brett'

INSERT INTO #TableB (col1)
SELECT 'AJMAL' UNION ALL
SELECT 'TAMANNA' UNION ALL
SELECT 'TINKU ' UNION ALL
SELECT 'kaiser'
GO

SELECT a.Col1, b.Col1, CASE WHEN a.Col1 = b.Col1 THEN 'Yes' ELSE 'No' END AS ColCompare
FROM #TableA a
FULL JOIN #TableB b
ON a.Col1 = b.Col1
GO

DROP TABLE #TableA, #TableB
GO



[/code]


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -