Showing posts with label updated. Show all posts
Showing posts with label updated. Show all posts

Tuesday, March 20, 2012

Comparing 2 files

Dear All,
Periodically, i need to copy a file from the source folder to destination
folder. the source file will be updated from time to time. Before copying
the file to destination folder, i need to compare the modified date of the
file, mean only copy the file to destination folder if the source file is
updated. How can we do this in SQL?
I will use the xp_cmdShell to copy the file. If use the xp_getfiledetails,
how can i get the information return fromt the stored procedure to check the
modified date? Or, is there any better method of doing this?
I am using SQL Server 2000.
Thanks & Best Regards,
EdwardInsert as below..and then you can compare ..
CREATE TABLE #FILE
(
name varchar(30) null,
size int null,
creationdate int null,
creationtime int null,
lastwrittendate int null,
lastwrittentime int null,
lastaccesseddate int null,
lastaccessedtime int null,
attributes int null
)
INSERT #FILE EXEC master..xp_getfiledetails @.FILE_NAME
MJKulangara
http://sqladventures.blogspot.com|||Hi
You could do the file copy and comparison using a DTS package and an ActiveX
script. See
http://www.sqldts.com/default.aspx?292
John
"Edward Low" <wc_low@.hotmail.com> wrote in message
news:eRZ8g9qLGHA.3936@.TK2MSFTNGP12.phx.gbl...
> Dear All,
> Periodically, i need to copy a file from the source folder to destination
> folder. the source file will be updated from time to time. Before copying
> the file to destination folder, i need to compare the modified date of the
> file, mean only copy the file to destination folder if the source file is
> updated. How can we do this in SQL?
> I will use the xp_cmdShell to copy the file. If use the xp_getfiledetails,
> how can i get the information return fromt the stored procedure to check
> the modified date? Or, is there any better method of doing this?
> I am using SQL Server 2000.
> Thanks & Best Regards,
>
> Edward
>

Wednesday, March 7, 2012

Compare 2 database schemas?

We're using Sql Server 2000. The one database contained tables and stored procedures which were possibly updated with some script information. Is there an application(commercial or free) or script I can use to compare the base database against this updated database to confirm there schema information is the same.Thanks

You can use the tool provide by Microsoft "Visual Studio Team Edition for Database Professionals"

This will give you Comparison Tools (Schema & Data Compare) allow comparisons & synchronization of schema and data with design/test/production databases

Have a look into the webcast at following url

http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&EventID=1032300980

This will give you a good idea

Compairing updated data base.

I do not know SQL but learning fast and furious.

I am programming an agent and working with a group of existing databases.
I would like to able to compare the database before and after an update.
The testing databases are relatively small.
I have no problem programming some compare but how do I go about it.

Should I do this in SQL duplicating the database.
I would be happy to write some SQL and dump the databases and do the compare
externally.

I would appreciate any suggestion.

AndreIf you just want to compare data between similar tables you can do so
with a JOIN:

SELECT COALESCE(A.key_col, B.key_col),
COALESCE(A.col1, B.col1), COALESCE(A.col2, B.col2), ...
FROM TableA AS A
FULL JOIN TableB AS B
ON A.key_col = B.key_col
WHERE COALESCE(A.col1,'')<>COALESCE(A.col1,'')
AND COALESCE(A.col2,'')<>COALESCE(A.col2,'')

assuming key_col is the primary key in both tables.

--
David Portas
SQL Server MVP
--|||What I would like to do is probably
1) back up the data base
2) restore it under a different name
-- run my agent
3) create a difference database ( a new database with any table which is
different)

Step 1 and 2 are easy so can be ignored
now step 3
I can create a new temporary database but how can I fill the tables in this
database using SQL

"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1111586542.235632.69940@.o13g2000cwo.googlegro ups.com...
> If you just want to compare data between similar tables you can do so
> with a JOIN:
> SELECT COALESCE(A.key_col, B.key_col),
> COALESCE(A.col1, B.col1), COALESCE(A.col2, B.col2), ...
> FROM TableA AS A
> FULL JOIN TableB AS B
> ON A.key_col = B.key_col
> WHERE COALESCE(A.col1,'')<>COALESCE(A.col1,'')
> AND COALESCE(A.col2,'')<>COALESCE(A.col2,'')
> assuming key_col is the primary key in both tables.
> --
> David Portas
> SQL Server MVP
> --|||Andre Arpin (arpin@.kingston.net) writes:
> What I would like to do is probably
> 1) back up the data base
> 2) restore it under a different name
> -- run my agent
> 3) create a difference database ( a new database with any table which is
> different)
> Step 1 and 2 are easy so can be ignored
> now step 3
> I can create a new temporary database but how can I fill the tables in
> this database using SQL

Red Gate has products for this, check out http://www.red-gate.com/.

If you would like to roll your own, you would have to write a query
like the one that David showed you for each table.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||You can easily populate a table from another in a different database:

INSERT INTO DatabaseA.dbo.TableA (col1, col2, ...)
SELECT col1, col2, ...
FROM DatabaseB.dbo.TableB
WHERE ... ?

--
David Portas
SQL Server MVP
--