Archive for the ‘SQL’ Category

Selecting all today’s records

Dates can be difficult to work with especially when you are not interested in the time portion. So here’s a quick snippet that strips the time portion out of the equation, making it easy to get only today’s records (or any day for that matter). SELECT Column1,Column2, Datestamp FROM tblExample WHERE DATEADD(day, DATEDIFF(day, 0, GetDate()), [...]

More »

SQL 2000 Find and Replace

I needed to find and replace text in a text field in sql2000… here’s how I got it right: declare @StringToReplace varchar(1000) SET @StringToReplace = ‘baad string’ declare @NewString varchar(1000) SET @NewString = ‘new improved string’ declare @start int declare @end int SELECT @end = len(@StringToReplace)-2 declare @currentrecord int declare @ptrval BINARY(16) declare @TotalOldTextInstancesStillToBeFixed int [...]

More »