Linux Cloud Technologies 2013

  Build the cloud on Linux!  This year looks very promising for Linux when it comes to building your private cloud using open source technologies.  Finally, Linux-based software and application

Read More
Linux Cloud Technologies 2013

SQL Server insert with sub queries

by on July 9, 2013 at 1:51 pm

Extremely awesome SQL query I wrote.

use my_db


ltrim(rtrim(str(b.my_id)))+ltrim(rtrim(str(b.date))) pid_date,
p.column1+p.column2 ssdd,
COUNT (*) Amount,
select COUNT(*) from amounts b1
where b1.flags = '1'
and b1.my_id = b.my_id
and b1.date = b.date
) Deleted,
select SUM(m.count1)
from mail_counts m
where m.my_id = b.my_id
and m.date = b.date
) Counts

 from amounts b

inner join pusers p
on b.my_id = p.my_id

where (b.date < '20130701' and b.date >= '20120101')
and not exists (
select *
FROM dbo.my_archive mt
where mt.pid_date = ltrim(rtrim(str(b.my_id)))+ltrim(rtrim(str(b.date)))
and p.column1 != 'TS'

group by b.date, b.my_id, p.first_name, p.last_name, p.column1+p.column2

in Uncategorized


Connect to SQL Server with Python

by on July 5, 2013 at 2:23 pm

Recently I was tasked to rewrite some Perl cgi scripts.  My time is valuable to me, so I rewrote them in Python!  One of the functions of the cgi scripts was to connect to a Microsoft SQL Server 2008 r2 instance.  A quick glance at the perl scripts showed me we were using ODBC to connect to SQL Server.  After a few hours of reading online, I settled upon what I believe is the best method, using pyodbc.

pyodbc is an open source library for python, available at https://code.google.com/p/pyodbc/  Installation is pretty straight forward, but I will outline the steps here and help you connect to SQL Server as well.


in How-To, Red Hat

, , , ,

Ad goes here