Hi
I have 4 tables with the same attribute/column name.
T1
Name Age Town
A 22 Berlin
B 18 Hamburg
C 30 New York
T2
Name Age Town
A 22 Berlin
D 25 Atlanta
F 21 Accra
T3
Name Age Town
E 45 Madrid
B 18 Hamburg
C 30 New York
T4
Name Age Town
Z 17 Zurich
E 45 Madrid
S 28 Potsdam
I want to create a sp PROC to display the difference (*new entry ) two columns whenever a user chooses a table dynamically.
(*new entry ) = T2 :T1 what’s new in T2 compared to T1
T4:T2, T3:T3 (dynamically)
Here my sql statement but it only chooses the predefined tables.
CREATE PROC spNewEntrance
(
@ NewEntrance1 AS NVARCHAR (255),
@ NewEntrance2 AS NVARCHAR (255)
)
AS
BEGIN
SET NOCOUNT OFF;
SELECT [Age] AS Age, [Town] AS City
FROM [dbo].[T2]
EXCEPT
SELECT [Age] AS Age, [Town] AS City
FROM [dbo].[T1]
END
GO
EXEC spNewEntrance @ NewEntrance1 = '', @ NewEntrance2 = ''
Can somebody please help me? And frustrated?