Monday, October 31, 2016

SQL to Excel - Cleanup tabs, new lines, ect...

DECLARE @CrLf CHAR(2);
SET @CrLf = CHAR(13) + CHAR(10); -- CarriageReturn + LineFeed

SELECT [PROB_TYPE]
  ,[CONTACTNAME]
      ,[TECHNITION]
      ,[NUMBER]
  --,[DESCRIPTION]
  ,REPLACE(REPLACE(SUBSTRING([DESCRIPTION],1,DATALENGTH([DESCRIPTION])),@CrLf,'-'), CHAR(9), '') AS [DESCRIPTION]
      ,[OPENED]
      ,[CLOSED]
      ,[CLOSINGREMARKS]
      ,[STATUS]
      ,[ENTERED_BY]
      ,[CONT_PHONE]
      ,[CONT_ADDRESS]
      ,[CONT_EMAIL]
      ,[TAG_NO]
      ,[SERIAL_NO]
      ,[MODEL]
      ,[PRIORITY]
      ,[SHOW]
      ,[CODE]
      ,[CLOSEID]
      ,[EMERGENCY_CHANGE]
      ,[ENTERED_ID]
      ,[HRS_EST]
      ,[HRS_ACTUAL]
  FROM [problems]
  where status not in ('closed')
 order by prob_type

Thursday, May 26, 2016

MS SQL Tables to C# objects

I am putting this here so I don't have to search for it later.


http://stackoverflow.com/questions/5873170/generate-class-from-database-table

Tuesday, April 19, 2016

SQLITE NHibernate DateTime2

While working on a project I was using a MsSQL 2012 database for my persistence layer but wanted to use a SQLITE in memory database for my unit/integration testing.  As part of my mapping setup I used an NHibernate Version column which used DateTime2:

NHibernate Mapping Code:

Unforntuently SQLITE doesn't support DateTime2. After searching around and not finding a good solution, I ended up extending SQLiteDialect class to map it to TEXT per the following link:   http://stackoverflow.com/a/16597386/2544235

SQLiteDialect Code:

Phoenix

I am resurrecting this tech blog for notes related to Azure Logic Apps with SAP.