SQL

Oracle-like ROWNUM in MySQL

Oracle-like ROWNUM in MySQL

It needs sometimes to exactly mimic Oracle's ROWNUM where is no possibility to initiate a counter in previous statement by

SET @rownum:=0

;.

It is still possible in a single SQL.

SELECT @rownum:=@rownum+1 rownum, t.*FROM (SELECT @rownum:=0) r, mytable t;

archived from Mark Malakanov

Search Triggers, Stored Procs, and Functions

Code that will search Triggers, Stored Procs, and Functions in MS SQL Server

Search through text of Stored Procedure

Search across the text of all stored procedures for a particular string.

Long character fields from database weird in PHP

When you are returning longer text, like from a varchar(MAX) or such you get weird characters at the end.

How to test for SQL Injection Vulnerabilities

This article gives instructions on what to look for and how to determine which pages are vulnerable

Search and Replace All Tables

Search and replace all occurances of a string in all tables in a database. From http://vyaskn.tripod.com/ --To replace all occurences of 'America' with 'USA': EXEC SearchAndReplace 'America', 'USA' GO

Search All Tables

Search all text fields across all tables in a database.  Taken from http://vyaskn.tripod.com/ --To search all columns of all tables in Pubs database for the keyword "Computer" EXEC SearchAllTables 'Computer' GO

Order characters numerically

It may be simple, but this SQL will order items numerically (1,2,3,10,20) instead of alpha (1,10,2,20,3).

SQL Permissions Script

Generate a Script to Grant Permissions on all items to WebUser group

Update Date Trigger

Here's a sample of some code to update a date field in MS SQL Server using a trigger.

Syndicate content