Thursday, March 21, 2013

[SQL Server] NOT IN based on two fields

[SQL Server] NOT IN based on two fields


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 )

Database email

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)

No comments:

Post a Comment

Search This Blog