MS SQL Server: Case Sensitive Search

Sometimes you need to search your database case-sensitive. But: Microsoft SQL Server is usually configured to be case-INsensitive. But there’s no need to reconfigure the whole database, here are my 2 favorites to lookup data: cast column-value and searchterm to...

SQL Basics: Search in nText columns

Anybody ever tried to search in ntext or text fields on MS SQL Server? Common experience is to fail. Solution: cast your search-term to text type, and try again. Example, using EA-Database: SELECT * FROM t_xref x WHERE x.Description LIKE...

SQL Server Management Studio Express

SQL Server Management Studio In some cases the user might install the SQL Server Express Edition, before a “real” SQL Server (Developer Edition). This can result in a basic version of Management Studio. Keep in mind, that with SSMSE (e = Express), you...

Sql QueryBuilder

  Im Rahmen eines OCF basierten Projektes brauchten wir die Möglichkeit komplexe Sql Abfragen abbilden zu können. Eine QueryBuilder musste her, dabei sollte die Anwendung aber möglichst einfach sein. Auf der Codeproject Seite “SelectQueryBuilder: Building complex...

MS SQL Server: How to create Insert Scripts

There are a lot of scripts out there promising to create insert scripts. You pass in the name of the table, and the scripts create an insert statement for each record contained. Only problem they have: the more columns there are, the greater the chance of lines being...

SQL Server: Update Cursor

How to use an Update Cursor on MS SQL Server. Requirements: If the update-table does not have a Primary Key, the cursor is read-only. So I advise to create at least a temporary Primary Key, and delete it afterwards. Usage: DECLARE curs as CURSOR FOR SELECT * FROM...

SQL Abfragen – das Mirakel

Im Folgenden habe ich zwei Varianten einer sich ziemlich ändelnden SQL Abfrage: SELECT Top 1 Employees.Country, Employees.LastName, Employees.FirstName, Orders.ShippedDate, Orders.OrderID, “Order Subtotals”.Subtotal AS SaleAmount FROM Employees INNER JOIN...