Zip – the easy way

Recently I had a reason to zip a folder on a regular basis (as in every night).  I discovered a great program called 7-zip.  This thing works AND has a command line interface and supports really groovy things like volumes.

Let’s say you need to zip all your SQL backups nightly but for obvious reasons you need the files to me no more than a certain size (my cloud drive only allows 2gig files).  Create a DOS batch file with the following code (replacing the paths with your paths) and schedule it to run each night.


del /Q D:\Backup\zip\*.*

c:\"program files"\7-zip\7z a -tzip -v700m d:\backup\zip\sql.zip d:\backup\sql\*.bak -aoa

It takes all the files in d:\backup\zip and deletes them. Then it zips everything in d:\backup\sql with the extension .bak into zip files with volume sizes of 700mb (which will, by the way, fit on a cd). How cool is that?

SQL and Today

sometimes it is handy to be able to use today’s date in T-SQL.  Sure, you have getdate() but it has minutes and seconds and stuff.  What if you  just want today?  Try this:
CREATE view dbo.v_today as
select convert(varchar(5),MONTH(getdate())) + '/' + convert(varchar(5),DAY(GETDATE())) + '/' + convert(varchar(5),YEAR(getdate()))
as Today

How do you use it?


select * from orders where orderdate >= ( select today from v_today);
select * from orders where orderdate < ( select today from v_today);

Yeah – I know it’s simple but so am I and it works.

 

What is a Toddism?

Me.  I develop custom business software.  Imagine, if you will, a corporate database with lots of thingies and doofers.  You need some more but really don’t want to replace the thingies you have.  I write custom thingies that may connect to your corporate database.  They may me brand new and require some database design. Whether you need SQL, ASP, PHP, .NET or some combination I can help.

Whatever the need, I can do the design and implementation.