Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 query problem
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 10/10/2005 :  07:07:11  Show Profile  Reply with Quote
suppose there are two tables emp and amp1
having fields as
table emp
empname empno dessig
sanjeeb 111 manager
rajeeb 112 engineer
table emp1
empname empno
sanjeeb 111
rajeeb 112
rohit 345
now my query is how i'll select
q1>get me the rows available in emp and not in emp1
q2>get me the rows available in emp1 and not in emp
q3>get me the columns available in emp but not in emp1
q4>get me the columns available in emp1 but not in emp

Premature Yak Congratulator

22864 Posts

Posted - 10/10/2005 :  07:25:30  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
1 Select * from emp T where not exists(Select * from emp1 where empname=T.empname)
2 Exchage table names from 1
3 select Column_name from information_schema.columns T where table_name ='emp'
and not exists(select * from information_schema.columns where table_name='emp1' and column_name=T.Column_name)
4 Exchage table names from 3

Refer these for basics of SQL queries


Failing to plan is Planning to fail
Go to Top of Page

Flowing Fount of Yak Knowledge

2916 Posts

Posted - 10/10/2005 :  08:35:11  Show Profile  Reply with Quote
Hmmm....some marks for persistance!
None....for originality.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000