Category Archives: SQL

Date Subtraction or Difference

Sometimes you need to know the differences between two dates in days months years whatever. SQL SERVER select datediff(day,date1, date2) as days_diff, datediff(month,date1, date2) as months_diff… Can also do year, quarter, week, hour, minute, and second dateparts. Dates can be … Continue reading

Posted in Code, Coldfusion, Javascript, JQuery, Snippets, SQL | Tagged | Leave a comment

SQL using case to Identify blanks vs NULLs

I had a strange issue driving me nuts today. I had data with null values and could use isNull to capture most of them and assign a new value to the field. However about 10 records would not accept the … Continue reading

Posted in Code, Snippets, SQL | Tagged , , , | Leave a comment

SQL Numbering a table in sequence without IDENTITY

This is for renumbering of the rows in a table with out IDENTITY. — add a rowid to the table ALTER TABLE #table_name ADD rowid int null — set the rowid vales to zero UPDATE #table_name SET rowid = 0 … Continue reading

Posted in Code, Snippets, SQL | Leave a comment

SQL – Synchronizing identity field between two tables

One thing that DBAs often have difficulty with is moving data from one database to another database. This may be to synchronize a development environment with databases or tables on other servers with the same data values. Fortunately MSSQL provides … Continue reading

Posted in Code, Snippets, SQL | Leave a comment

CFSelect Multiple and ListQualify

If you need a multiple selection list and need to display its values dynamically from a query you can do this in one line of code within your form. <cfquery name=”getstatus” datasource=”myDSN”> select All as status from orderstable UNION ALL … Continue reading

Posted in Code, Coldfusion, Snippets, SQL | Leave a comment