-- UNDERSTANDIGN SET BASED APPROACH
--set nocount off;
--select column_name from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='Products'
--Declare the Table variable
DECLARE @tmpTable TABLE
(
Number INT IDENTITY(1,1), --Auto incrementing Identity column
CultureNameU VARCHAR(300) --The string value
)
--Decalre a variable to remember the position of the current delimiter
DECLARE @CurrentDelimiterPositionVar INT
--Decalre a variable to remember the number of rows in the table
DECLARE @Count INT
--Populate the TABLE variable using some logic
INSERT INTO @tmpTable SELECT CultureName FROM CultureInfo
--Initialize the looper variable
SET @CurrentDelimiterPositionVar = 1
--Determine the number of rows in the Table
SELECT @Count=max(Number) from @tmpTable
--A variable to hold the currently selected value from the table
DECLARE @CurrentValue varchar(300);
--Loop through until all row processing is done
WHILE @CurrentDelimiterPositionVar <= @Count
BEGIN
--Load current value from the Table
SELECT @CurrentValue = CultureNameU FROM @tmpTable WHERE Number = @CurrentDelimiterPositionVar
--Process the current value
declare @replaced varchar(300)
set @replaced = replace(@CurrentValue , '-' , '_')
update CultureInfo set CultureNameU=@replaced where CultureName=@CurrentValue
print @replaced
--Increment loop counter
SET @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1;
END
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!