The Development Blog of Gabe Shackle
Category Archives: SQL
SQL to replace URLs in common WordPress tables
Use this script when moving from one URL to another to catch the most common places where a URL is embedded:
Sort Select Results by Arbitrary Values
SELECT ColumnOne, ColumnTwo, ColumnThree FROM Table ORDER BY CASE ColumnTwo WHEN ‘miny’ 1 WHEN ‘meeny’ 2 WHEN ‘eeny’ 3 WHEN ‘moe’ 4 END, ColumnThree
Insert Select Query Results into Another Table
INSERT INTO dbo.Destination ( FieldOne ,FieldTwo ,FieldThree ,FieldFour ,FieldFive ) SELECT FieldOne ,FieldTwo ,FieldThree ,FieldFour ,FieldFive FROM dbo.Source
Data truncation error when importing to SQL from CSV/Excel
If you are importing large (greater than 8 rows) amounts of data into a SQL database via the SQL Server Import and Export Wizard you may run across this error: Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column “ColumnName” returned status value 4 and status text “Text was truncated [...]