This user defined function is based on a function posted at this very useful site: http://www.sql-server-helpe... I have modified it slightly to handle spaces within the input string; by first replacing any existing spaces with ‘¬’ (this seems to be a suitably obscure character that is never likely to occur in the input string). CREATE FUNCTION RemoveLeadingZerosFromVarChar ( -- Add the parameters for the function here @inputStr varchar(max) ) RETURNS varchar(max) ......
I pretty new to LINQ, and I’m keen to get more experience using it, so whenever an opportunity arises I like to try writing LINQ queries. I needed to write a method to extract a comma separated list of numbers from a config file, and return this as List<int>. I was looking at ways to do this using LINQ, but hit a problem. I wanted my LINQ query to filter out any values in the CSV string that could not be parsed as an int, without causing an exception. Using int.TryParse() seemed like a possible ......
Just some code to get the time part only from a DateTime field (is SQL Server 2000 or 2005), with the date set to a reference date declare @timetest datetime declare @refdate datetime set @timetest = getdate() set @refdate = '30 Dec 1899 00:00:00' select @timetest , @refdate , dateadd(day, datediff(day, @refdate , @timetest), @refdate ) -- date part only , dateadd(day, datediff(day, @refdate , @timetest) * -1, @timetest) -- time part only, with reference date Instead of @refdate, you could use 0 ......