April 26, 2011 at 12:21 pm
Example:
1,2,3,16
database value
1
2
3
4
5
6
14
15
I want 16 as output
Is it possible to find out with a single select Query.
April 26, 2011 at 1:25 pm
DECLARE @test-2 VARCHAR(20);
SET @test-2 = '1,2,3,16';
DECLARE @MyTestTable TABLE (RowId INT);
INSERT INTO @MyTestTable
SELECT 1 UNION ALL
SELECT 2 UNION ALL
SELECT 3 UNION ALL
SELECT 4 UNION ALL
SELECT 5 UNION ALL
SELECT 6 UNION ALL
SELECT 14 UNION ALL
SELECT 15;
SELECT RowID = CONVERT(INT, Item)
FROM dbo.DelimitedSplit8K(@test,',') ds
EXCEPT
SELECT RowId
FROM @MyTestTable;
See the link in my signature for the latest DelimitedSplit8k function.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
April 27, 2011 at 12:16 pm
Your solution is excellent
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply