SQL To Check Space Taken Up By Each Table

clive SQL, Tech Tip

This SQL for use with Microsoft SQL Server is a little better than the standard EXEC sp_MSforeachtable @command1=”EXEC sp_spaceused ‘?’” SELECT t.NAME AS TableName, (sum(a.total_pages) * 8) / 1024 as TotalSpaceMB FROM sys.tables t INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id INNER JOIN sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id INNER JOIN sys.allocation_units a ON p.partition_id …

SQL Server Queries – Stripping Extra Characters from the End of a String

clive All, Development, SQL, Tech Tip

Yesterday while implementing a particularly difficult SQL report query, I came across the following question: Given a String ‘This is a test, this is a second test’, is there an easy method (preferably without using CLR) to search and replace the string to remove the word ‘test’ but only if it occurs as the last series of characters in a …