TSQL - compare tables

Posted by Rya on Stack Overflow See other posts from Stack Overflow or by Rya
Published on 2011-06-24T07:35:57Z Indexed on 2011/06/24 8:22 UTC
Read the original article Hit count: 202

Filed under:
|
|

I want to create a stored procedure that compares the results of two queries. If the results of the 2nd table can be found in the first, print 'YES', otherwise, print 'No'.

Table 1:

SELECT dbo.Roles.RoleName, dbo.UserRoles.RoleID FROM dbo.Roles LEFT OUTER JOIN dbo.UserRoles ON dbo.Roles.RoleID = dbo.UserRoles.RoleID WHERE (dbo.Roles.PortalID = 0) AND (dbo.UserRoles.UserID = 2)

Table 2:

Declare @RowData as nvarchar(2000) Set @RowData = ( SELECT EditPermissions FROM vw_XMP_DMS_Documents where DocumentID = 2) Select Data from dbo.split(@RowData, ',')

For example.

Table 1: John Jack James

Table 2: John Sally Jane

Print 'YES'

Is this possible???

Thank you all very much.

-R

© Stack Overflow or respective owner

Related posts about tsql

Related posts about table