[SQL Server] NOT IN based on two fields |
Posted: 21 Mar 2013 10:56 AM PDT Please help me to not use this silly concatenation method. I want to select all from the first table when the combination of two fields is not in the second.What;s the accepted way to do this?DECLARE @Test1 TABLE (Field1 varchar(1), Field2 int)INSERT INTO @Test1SELECT 'A',1 UNION SELECT 'B',2 UNIONSELECT 'C',3 DECLARE @Test2 TABLE (Field1 varchar(1), Field2 int)INSERT INTO @Test2SELECT 'B',2 UNIONSELECT 'C',3 SELECT * FROM @Test1WHERE Field1 + CONVERT(varchar(1),Field2) NOT IN ( SELECT Field1 + CONVERT(varchar(1),Field2) FROM @Test2 ) |
Posted: 21 Mar 2013 03:07 AM PDT I setup database email and get this Message[260] Unable to start mail session (reason: System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnectionFactory' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.Confi) |
You are subscribed to email updates from SQLServerCentral / SQL Server 2008 / SQL Server Newbies To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No comments:
Post a Comment