CharIndex Reverse - find occurrence starting from end of string in TSQL
This is a quick note on finding the last occurrence of a string in a longer string. This has to be in Transact SQL for a SQL Server instance only and not filtered by other code.
Knowledge base / Since 1999
Practical Databases tutorials, troubleshooting notes and implementation guides from real projects.
Advanced search75 entries / Databases
Clear filters
This is a quick note on finding the last occurrence of a string in a longer string. This has to be in Transact SQL for a SQL Server instance only and not filtered by other code.
So this is a quick article on how to delete from multiple tables in a mySQL database where we use some JOIN statements.
In view of the fact that this error pops up in so many systems I take over, I have often gone down the wrong path following the red herring as it were when in fact the answer to this is very common.
Along with my DataJumble function and DataTumble procedure which also help scramble database tables sent to suppliers/developers, this is a function which simply finds random characters and inserts these. I would recommend using the DataTumble script over this one as this leaves data very difficult to work with: Before...
This is a stored procedure I've nabbed from some consultants from my day job. It shuffles the records and matching data values: Before: ID Name DateOfBirth --------- ------------ ----------- 1 John Smith 1988-06-24 2 Fred Bloggs 1972-11-17 3 Another User 1964-02-18 After: ID Name DateOfBirth...
We have a specific timetabling system for academic institutions and all our staff/students follow academic week numbers as opposed to calendar week numbers.
We have a datawarehouse and we want to be able to count all the records in any table of the database that match on a particular warehouse load. This is a column value where the column is called "WarehouseLoadKey" and the value we want to search on is "3" (the 3rd incremental load). How? The below stored procedure can b...
Yes you could just run a SELECT DISTINCT query along with collation to make it case-sensitive and/or accent-sensitive but using this stored procedure means I only specify the table and then the columns. How?
This is a quick note to show you how to convert a given comma delimited string into a database table: Given: "Title,Forenames,Surname" Return: ID Value ------ ---------------- 1 Title 2 Forenames 3 Surname Note the below example omits the ID column and just leaves VALUE.
Working principle
This site exists as a practical knowledge base built from real-world experience across systems, platforms, and technologies since 1999. Much of the content documents solutions, edge cases, and working patterns that were learned through investigation where documentation was incomplete or absent, and is shared to reduce the same friction for others.
Protected notes
Log in for protected notes and any private client projects assigned to your account.