Tag Archives: MSSQL

MSSQL – Select rows which are created within a specific period

Assume the table has a column called CREATED_DATE which stores the creation date. The following SQL make use of the DATEADD() function to select records which are created within the recent 10 days.

SELECT
  *
FROM
  <YOUR TABLE>
WHERE
  CREATED_DATE > DATEADD(day, -10, getdate())

 

We can use different unit in the datepart (The first argument in DATEADD()) as stated in the 2nd reference link below.

Done =)

Reference:

Python – Connect to MSSQL server using pymssql package

1. Install the pymssql package.

pip install pymssql

 

2. Create the your .py file.
test_mssql.py

import pymssql
conn = pymssql.connect(host='<host>', user='<username>', password='<password>', database='<dbname>')
cur = conn.cursor()

cur.execute('SELECT CONVERT(date, CURRENT_TIMESTAMP)')
row = cur.fetchone()
while row:
  print "CURRENT_TIMESTAMP=%s" % (row[0])
  row = cur.fetchone()

conn.close()

Continue reading Python – Connect to MSSQL server using pymssql package

Maven – Add Java classpath to manifest for runtime

Previously we have talked about how to package a .jar artifact with dependencies included.

 

An alternative solution is to put your dependencies in the src/main/resources folder and they will be copied to the target folder together with the packaged .jar file. Then we can add the class paths to these dependencies in the Manifest with the help of the maven-jar-plugin.

The following project is a real life example which i use it to test the connection between the JBoss server and the MSSQL server.
Continue reading Maven – Add Java classpath to manifest for runtime