Jump to content


Check out our Community Blogs

Barnsite

Member Since 22 Oct 2012
Offline Last Active Jan 19 2017 07:45 AM
*****

Blog Entries

Barnsite's Blog > Remove Characters in String T-SQL with No Loop Part 2

Posted 09 May 2016

Okay, expanding on what I did yesterday.I Built a table, called ExclusionList with one field, ExcludedTextE.g.Then created a function:CREATE FUNCTION [dbo].[udf_clean_string] ( @string VARCHAR(100) ) RETURNS VARCHAR(100)ASBEGIN SELECT @string = REPLACE(@string,ExcludedText,'')FROM ExclusionListRETURN @stringYou can then use like this:SELECT d...


Barnsite's Blog > Remove Characters in String T-SQL with No Loop

Posted 09 May 2016

Ok, I’ve seen many ways to do this using loops, but nothing in plain T-SQLLet’s say we have a string that may contain illegal characters, in my case it was project identifiers that needed to be used as file names for exporting. However, many had / or * in the names.One thing I hate in T-SQL is loops, so having only found looping ways...


Barnsite's Blog > Add child items to ToolStripMenuItem using C# – C Sharp

Posted 22 January 2013

I wanted to be able to populate menu items from a database, i.e. I had a Print Document top level menu item and I wanted to be able to populate the children from the database dynamically with each available document.
The theory was this:
1. Use the MouseHover event for the main menu item
2. When the user hovers over the item, get the list of...


Barnsite's Blog > Shuffle an Array in C#

Posted 15 January 2013

As part of a basic guessing game I wanted to be able to shuffle an array of n chars into a random order.
The method I decided to use was the following.
Create a loop to iterate n times (where n is the number of elements in the array).  Randomly select one array element and add this to a new array.  Replace the removed item with the last item in...


Barnsite's Blog > Loading Data into a DataReader and Looping Through Records OLEDB / C#

Posted 24 December 2012

Just a quick example of loading data into a data reader using C#.  My data source is MS SQL Server in this case, although you would just need the correct OLEDB connection string to use any other data source.

//database connection string & SQL Statement to return SERVICE_LEVEL_ID and DEFINITION from a table called property.SERVICE_LEVEL
string...