Thursday, March 29, 2012

Comparing two different databases

Hi all,
Sql server 7

i have two databases best and books.Most of the tables present in best are in books except some.
i have been given a task to list out the tables and columns of which are present in best database and not in books database.

Pls suggest me the simplest and quickest way to do this.
this is very urgent.

waiting for reply.
TIA
AdilI'd just run selects from sysobjects and syscolumns, which are SQL Server's method of storing object definitions. Others on this forum will probably suggest selecting from the SCHEMA tables.|||Check LEFT OUTER JOIN in BOL, this should be very trivial (hint: ...no, t's too trivial ;) )|||hi

thnks for reply

can u tell me as to how i can select columns of a particular table using syscolumns

thansks once again|||Originally posted by aadil
hi

thnks for reply

can u tell me as to how i can select columns of a particular table using syscolumns

thansks once again

You could use linked servers. Query below will return list of tables from server1 if these are no the same column(s) on server2. Checking for object owner also is included.

select 'User table ['+su.name+'.'+so.name+'] does not have column ['+sc.name+']'
from server1.dbo.sysobjects so
join server1.dbo.syscolumns sc on sc.id=so.id
join server1.dbo.sysusers su on su.uid=so.uid
where so.xtype='U'
and exists(select 'ok' from server2.dbo.sysobjects r
join server2.dbo.sysusers sur on sur.uid=r.uid and sur.name=su.name
where xtype='U' and r.name=so.name)
and not exists(select 'ok' from server2.dbo.sysobjects sor
join server2.dbo.sysusers sul on sul.uid=sor.uid and sul.name=su.name
join server2.dbo.syscolumns scr on scr.id=sor.id
where sor.xtype='U' and sor.name=so.name and scr.name=sc.name)'

Comparing two date periods for overlapping

hi guys,

i have a booking table which has the following columns...

booking
--------------
dCheckin (format 11/9/2006 12:00:00 AM)
dCheckout (format 11/11/2006 12:00:00 AM)

when a new booking is entered, we want to make sure that the period entered does not conflict with an existing record.

not sure how to go about building the query required. any help would be greatly appreciated.

mikeDo periods that "touch" count as an overlap? Do you need to consider rooms, customers, or anything else for an overlap, or is all of the data in the table the same?

-PatP|||it does matter if they are touching eg. someone cannot checkin during a period already occupied. the other data is in another table.

m.|||ahh sorry patp. i see what you mean. touching yes it does matter. a person cannot checkin on the day someone checks out.

mike|||CREATE TABLE #patp (
id INT IDENTITY
, dCheckin DATETIME
, dCheckout DATETIME
)

INSERT INTO #patp (
dCheckin, dCheckout
) SELECT '2006-01-01', '2006-01-10'
UNION ALL SELECT '2006-01-15', '2006-01-20'
UNION ALL SELECT '2006-02-01', '2006-02-10'
UNION ALL SELECT '2006-02-10', '2006-02-15'
UNION ALL SELECT '2006-03-01', '2006-03-10'
UNION ALL SELECT '2006-03-02', '2006-03-07'
UNION ALL SELECT '2006-04-01', '2006-04-10'
UNION ALL SELECT '2006-04-08', '2006-04-13'

SELECT *
FROM #patp AS a
WHERE EXISTS (SELECT *
FROM #patp AS b
WHERE b.id != a.id -- Never compare a row with itself
AND (b.dCheckin <= a.dCheckout -- A starts before B ends
AND a.dCheckin <= b.dCheckout)) -- B ends after A starts
ORDER BY a.dCheckin

DROP TABLE #patp-PatP

comparing two datasets

Hello - I would like to perform something lika a "diff" between two datasets
in my report.
Lets say that DS1 holds all customers and DS2 holds customers owning a car.
How do I find them customers not owning a car?
DavidPerhaps you could create a 3rd data set that would be some combination of the
queries used to create the 1st and 2nd data sets?
DS1 -
select customername
from customers
DS2 -
select name
from carowners
DS3 -
select customername
from customers
where customername in (
select name
from carowners
)
just a thought... i am not sure whast your schema looks like - there may be
a simpler solution or my solution may be too simple.
--
~lb
"David" wrote:
> Hello - I would like to perform something lika a "diff" between two datasets
> in my report.
> Lets say that DS1 holds all customers and DS2 holds customers owning a car.
> How do I find them customers not owning a car?
> David
>|||Problem is that one of the datasets is tabular data from a textfile, I
cannot use SQL to query it, but otherwise your answer still helps me to
define the problem better, thx :)
Sorry for not pointing out the flat file-stuff in the first place.
David
"lonnye" <lonnye@.discussions.microsoft.com> wrote in message
news:B3B4E2AF-A516-44EC-BE2E-EF5D98EC83AD@.microsoft.com...
> Perhaps you could create a 3rd data set that would be some combination of
> the
> queries used to create the 1st and 2nd data sets?
> DS1 -
> select customername
> from customers
> DS2 -
> select name
> from carowners
> DS3 -
> select customername
> from customers
> where customername in (
> select name
> from carowners
> )
> just a thought... i am not sure whast your schema looks like - there may
> be
> a simpler solution or my solution may be too simple.
> --
> ~lb
>
> "David" wrote:
>> Hello - I would like to perform something lika a "diff" between two
>> datasets
>> in my report.
>> Lets say that DS1 holds all customers and DS2 holds customers owning a
>> car.
>> How do I find them customers not owning a car?
>> Davidsqlsql

Comparing two databases for deleted records

hi ,
there is a tool that do compare between 2 databases and display deleted records an changes in schema and data ,
it's friendlly tool with beautiful gui for users.
it is called dbMaestro.
You can find it here:
http://www.extreme.co.il
You might want to check out the Red-Gate tools SQL Compare and SQL
DataCompare. I think these tools will do what you are requesting. Here is
their website: http://www.red-gate.com/
----
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"yaniv cohen" <yanivc@.extreme.co.il> wrote in message
news:30D974F8-F7EC-4AD7-BCC7-DDE5D9146096@.microsoft.com...
> hi ,
> there is a tool that do compare between 2 databases and display deleted
records an changes in schema and data ,
> it's friendlly tool with beautiful gui for users.
> it is called dbMaestro.
> You can find it here:
> http://www.extreme.co.il
>

Comparing two databases for deleted records

How do I compare two databases to determine deleted
records."Aboki" <anonymous@.discussions.microsoft.com> wrote in message
news:13d7001c41b24$a4d4d240$a001280a@.phx
.gbl...
> How do I compare two databases to determine deleted
> records.
Select *
from dbArchive.dbo.table1 as a
left outer join
dbUpdated.dbo.table1 as u
on a.PK = u.PK
where u.pk is null
dbArchive = the old database name
dbUpdated = the one with the rows deleted
PK = whatever the Primary Key column is
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.647 / Virus Database: 414 - Release Date: 29/03/2004|||hi ,
there is a tool that do compare between 2 databases and display deleted reco
rds an changes in schema and data ,
it's friendlly tool with beautiful gui for users.
it is called dbMaestro.
You can find it here:
http://www.extreme.co.il|||You might want to check out the Red-Gate tools SQL Compare and SQL
DataCompare. I think these tools will do what you are requesting. Here is
their website: http://www.red-gate.com/
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"yaniv cohen" <yanivc@.extreme.co.il> wrote in message
news:30D974F8-F7EC-4AD7-BCC7-DDE5D9146096@.microsoft.com...
> hi ,
> there is a tool that do compare between 2 databases and display deleted
records an changes in schema and data ,
> it's friendlly tool with beautiful gui for users.
> it is called dbMaestro.
> You can find it here:
> http://www.extreme.co.il
>

Comparing two databases

Are there any tools that allow you to compare two sql server databases to
find out what is different between them (the database structure, including
tables, relationships etc)? Thanks,
- Gabe
http://www.red-gate.com/sql/summary.htm
AMB
"Gabe Matteson" wrote:

> Are there any tools that allow you to compare two sql server databases to
> find out what is different between them (the database structure, including
> tables, relationships etc)? Thanks,
> - Gabe
>
>
|||Gabe Matteson wrote:
> Are there any tools that allow you to compare two sql server
> databases to find out what is different between them (the database
> structure, including tables, relationships etc)? Thanks,
> - Gabe
There are numerous schema comparison tools available. Change Manager
from Imceda/Quest Software available at www.imceda.com.
David Gugick
Quest Software
www.imceda.com
www.quest.com
|||Seconding this one...I've been using Red-gate SQL and Data compare for 2
years...fantastic products...
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
www.DallasDBAs.com/forum - new DB forum for Dallas/Ft. Worth area DBAs.
www.experts-exchange.com - experts compete for points to answer your
questions
"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:E8C28859-7C90-4FD6-A40B-3490F7172846@.microsoft.com...[vbcol=seagreen]
> http://www.red-gate.com/sql/summary.htm
>
> AMB
> "Gabe Matteson" wrote:
|||Thanks!
"Gabe Matteson" <gmatteson@.inquery.biz.nospam> wrote in message
news:OdFamzndFHA.1456@.TK2MSFTNGP15.phx.gbl...
> Are there any tools that allow you to compare two sql server databases to
> find out what is different between them (the database structure, including
> tables, relationships etc)? Thanks,
> - Gabe
>
|||ErWin and ER-Studio do this as well.
Greg Jackson
PDX, Oregon
|||I agree. SQL Compare from Red Gate is brilliant.
"Kevin3NF" wrote:

> Seconding this one...I've been using Red-gate SQL and Data compare for 2
> years...fantastic products...
> --
> Kevin Hill
> President
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
> www.DallasDBAs.com/forum - new DB forum for Dallas/Ft. Worth area DBAs.
> www.experts-exchange.com - experts compete for points to answer your
> questions
>
> "Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
> news:E8C28859-7C90-4FD6-A40B-3490F7172846@.microsoft.com...
>
>
|||you may want to look at a complete approach to change management, from your
favourite source control to your target database - DB Ghost
http://www.dbghost.com & the scripts produced always work - it's all in the
way they're produced.
regards,
Mark Baekdal
http://www.dbghost.com
http://www.innovartis.co.uk
+44 (0)208 241 1762
Build, Comparison and Synchronization from Source Control = Database change
management for SQL Server
"Gabe Matteson" wrote:

> Are there any tools that allow you to compare two sql server databases to
> find out what is different between them (the database structure, including
> tables, relationships etc)? Thanks,
> - Gabe
>
>
|||I use red-gate
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Gabe Matteson" <gmatteson@.inquery.biz.nospam> wrote in message
news:OdFamzndFHA.1456@.TK2MSFTNGP15.phx.gbl...
> Are there any tools that allow you to compare two sql server databases to
> find out what is different between them (the database structure, including
> tables, relationships etc)? Thanks,
> - Gabe
>
|||when red-gate fails (script out put has errors), DB Ghost succeeds which is
why most of our customers used to be red-gate customers.
free for MVP's, educational and non-profit organizations.
regards,
Mark Baekdal
http://www.dbghost.com
http://www.innovartis.co.uk
+44 (0)208 241 1762
Build, Comparison and Synchronization from Source Control = Database change
management for SQL Server
"Wayne Snyder" wrote:

> I use red-gate
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Gabe Matteson" <gmatteson@.inquery.biz.nospam> wrote in message
> news:OdFamzndFHA.1456@.TK2MSFTNGP15.phx.gbl...
>
>

Comparing two databases

Is there a way to compare the strored procedure,views and UDF's between two
databases to see if there are any differences. I use one database for
developement and the other is online. I would like to be able to run a
structural comparison between the two to make sure i didn't forget to script
a function or stored procedure after making modifications. I normally just
script all objects from developement to online after mods but I would like t
o
know for certain they are both the same sometimes. Also I would like to read
up on best practices for tracking developement so if you know of any good
reading that would help me. I use MS Access project as a front end and SQL
2000 as the Be. Thanks> Is there a way to compare the strored procedure,views and UDF's between
> two
> databases to see if there are any differences. I use one database for
> developement and the other is online. I would like to be able to run a
> structural comparison between the two to make sure i didn't forget to
> script
> a function or stored procedure after making modifications.
SQL Compare 4.0
http://www.red-gate.com/|||"AkAlan" <AkAlan@.discussions.microsoft.com> wrote in message
news:3A5AF648-8D41-441A-BA91-0EF14B5C09A0@.microsoft.com...
> Is there a way to compare the strored procedure,views and UDF's between tw
o
> databases to see if there are any differences. I use one database for
We use SQL Delta. Does wonders for our spare time! (maintaining/updating app
rox. 25 DB
installations)
http://www.sqldelta.com|||You should be checking your development and production scripts into some
type of source version control system. For example, Visual Source Safe has
an option to compare two projects and list files that are different, and it
has a feature for comparing two versions of a script side by side with
differences highlighted.
Also, you can script the databases to seperate folders and use a tool like
WinMerge to perform the comparisons:
http://groups.google.com/group/micr...br />
46abfa76
Rather than scripting all objects from development to production in bulk,
you need to identify specific objects that have changed and deploy them
individually. There are a number of reasons, but for one, you run the risk
of accidentally running a script that drops / recreates a table thus
resulting in data loss.
"AkAlan" <AkAlan@.discussions.microsoft.com> wrote in message
news:3A5AF648-8D41-441A-BA91-0EF14B5C09A0@.microsoft.com...
> Is there a way to compare the strored procedure,views and UDF's between
> two
> databases to see if there are any differences. I use one database for
> developement and the other is online. I would like to be able to run a
> structural comparison between the two to make sure i didn't forget to
> script
> a function or stored procedure after making modifications. I normally just
> script all objects from developement to online after mods but I would like
> to
> know for certain they are both the same sometimes. Also I would like to
> read
> up on best practices for tracking developement so if you know of any good
> reading that would help me. I use MS Access project as a front end and SQL
> 2000 as the Be. Thanks