Groups | Blog | Home
all groups > sql server new users > july 2006 >

sql server new users : Query help needed


Arnie Rowland
7/19/2006 2:13:32 PM
There are several ways to do this, here are a couple.

SELECT
o.Name
FROM DBNAME.dbo.sysobjects o
WHERE o.name NOT IN ( SELECT n.name
FROM DBNAME2.dbo.sysobjects
)=20


SELECT
o.Name
FROM DBNAME.dbo.sysobjects o
LEFT JOIN DBNAME2.dbo.sysobjects n
ON o.name =3D n.name
WHERE n.name IS NULL

Both of these will produce a list of objects in the first database that =
do not exist in the second database.

I hope this helps.

--=20
Arnie Rowland
Most good judgment comes from experience.=20
Most experience comes from bad judgment.=20
- Anonymous


[quoted text, click to view]
msnews.microsoft.com
7/19/2006 3:34:16 PM
Why does this query not work>

I am trying to compare fields in 2 tables and Show me only the results of
fields that are different, I thought this would work, but ... well,

select o.name
from DBNAME.dbo.sysobjects o, DBNAME2.dbo.sysobjects n
where o.name != n.name

msnews.microsoft.com
7/19/2006 4:45:06 PM
That HELPED A LOT, THANKS...
[quoted text, click to view]
There are several ways to do this, here are a couple.

SELECT
o.Name
FROM DBNAME.dbo.sysobjects o
WHERE o.name NOT IN ( SELECT n.name
FROM DBNAME2.dbo.sysobjects
)=20


SELECT
o.Name
FROM DBNAME.dbo.sysobjects o
LEFT JOIN DBNAME2.dbo.sysobjects n
ON o.name =3D n.name
WHERE n.name IS NULL

Both of these will produce a list of objects in the first database =
that do not exist in the second database.

I hope this helps.

--=20
Arnie Rowland
Most good judgment comes from experience.=20
Most experience comes from bad judgment.=20
- Anonymous


"msnews.microsoft.com" <breichenbach @ istate DOT com> wrote in =
message news:uWC51K3qGHA.4988@TK2MSFTNGP04.phx.gbl...
[quoted text, click to view]
Locky
7/31/2006 12:00:00 AM
[quoted text, click to view]

select a.name,b.name
from db1.dbo.sysobjects a full outer join db2.dbo.sysobjects b on
a.name=b.name
AddThis Social Bookmark Button