This may be very elementary for others but I am happy to find a solution on my problem on finding the equivalent of .NET's IsNullOrEmpty with a twist on T-SQL. It's with a twist because I am hoping to find a similar solution that IsNull function is doing: The T-SQL select isnull (columnName,...
I was asked by a friend of mine on how to create a trigger that would trace the changes that a user did to a table. So i checked my bookmarks and give him this link http://www.nigelrivett.net/SQLTriggers/Triggers_2_Creating_Audit_Trails.html Hope to Get some of your opinions or maybe improvements on...
Finally i'm back after a month of crazyness due to my webhost not performing up to its promise of 99.9% uptime. Enough with the rant and on with the article, today i'm going to talk about how to list databases in a SQL Server by just using T-SQL and then showing you how to truncate the logs on...
Posted to
Keith Rull
by
keithrull
on
01-22-2008
Filed under:
Filed under: SQL, T-SQL, sp_MSforeachtable, Truncate Table, DBCC, sysdatabases, sys.sysdatabases, Truncate Database Logs, SHRINKDATABASE, sp_msForEachDB, sp_databaases, sp_helpdb
Previously jokiz bloged about this one , I'd like to add further. The same issue cropped up again in the forums although not the exactly the same as jokiz's experience, this one could really give you hours of head scratching. Previously I was amazed that dynamic ORDER was possible with T-SQL without...
During my last post try to query the actual size of the logfile, and today i'm going to share a script i found months ago at the microsoft site. I cant find the original link.... Notes: Be sure that you have a backup of your database so that if something goes wrong you have something to get back into...
Didn't you know that the following statement is now valid for Sql Server 2005 as criteria for a column with bit data type? SELECT * FROM Orders WHERE Processed = 'true' The engine is now intelligent enough to implicitly convert it to SELECT * FROM Orders WHERE Processed = 1 More readable, imo. Too bad...
I have been dependent on the pad functions since the clipper days as it helped alot on formatting fixed length ids(invoice no., receipt no., etc.) Although I think the only purpose of formatting a number to fixed length precedeed by (usually) a zero is that it looks good on reports(i.e. 1234 -> 001234...
Here are some samples on how to use cursors in SQL to do updates and deletes on records. Nothing fancy, just pure t-sql code. :) Updating of Records Sample [code language="T-SQL"] --EXAMPLE ONE SET NOCOUNT ON Declare @AccountNumber varchar(20) DECLARE AccountNumbers CURSOR FOR ( select AccountNumber...
The Basics In VB I just love optional parameters, it's a shame that C# doesn't have that feature(instead of overloading methods of different parameters.) In T-Sql we can simulate this optional parameters in our stored procedures by using default values: PROC dbo.pr_GetInvoiceList (@PeriodMonth INT =...
This is an interesting piece of sql, the function accepts a string and removes HTML elements that is inside the string. This is genereally useful when you have data that has embedded HTML content on it. The function was written by Robert Davis . /****** Object: User Defined Function dbo.fnStripTags Script...