Category Archives: SQL

Test Using EXISTS Before Inserting

Here is a sample stored procedure that prevents duplicate inserts with the same value by first performing a test using SQL Server’s EXISTS statement. IF OBJECT_ID(‘prcTagNameInsert’) IS NOT NULL DROP PROCEDURE prcTagNameInsert GO CREATE PROCEDURE prcTagNameInsert @tagName VARCHAR(50) AS IF … Continue reading

Posted in SQL | Tagged | Comments Off

SQL Injection – Case Study

Well I got nailed today. My site INeedCoffee.com which is written using Classic ASP fell victim to a SQL Injection attack. The damage was limited to just one column in a table of nine rows. Textbook SQL Injection Attack Almost … Continue reading

Posted in Classic ASP, SQL | Tagged , , | Comments Off

Outer Joins Against A Date Range

This article is written for SQL Server, which supports user-defined functions and OUTER JOINS.  All examples come from the Northwind database which is part of the default installation of SQL Server. In SQL an OUTER JOIN is where you want … Continue reading

Posted in SQL | Tagged , | 2 Comments