Finding lowercase value in a table

,

This script is userful in CaseSensitive environment. This will detect a values from a table column which are lower case.

---Make sure to replace following items with appropriate values:
-----@myColumnValue -- this variable holds value for the column of your interest
-----myColumnName   -- this is the column name
-----myTableName    -- this is the table name

  set nocount on

  declare @Position         integer,
          @myColumnValue varchar(50),
          @AllCaps          char(1)

  set @Position = 1
  set @AllCaps = 'Y'

  declare CheckColumn cursor for
    select distinct myColumnName from myTableName

  open CheckColumn

  fetch CheckColumn into @myColumnValue

  While @@fetch_status = 0
    begin
      while @position <= len(@myColumnValue)
        begin
          if ASCII(SUBSTRING(@myColumnValue, @position, 1)) between 97 and 122
            begin
		 set @AllCaps = 'N'
            end
          set @position = @position + 1
	end
	if @ALLCaps = 'N'
		print @myColumnValue
	set @ALLCaps = 'Y'
      set @position = 1
      fetch CheckColumn into @myColumnValue
    end

  deallocate CheckColumn

Rate

Share

Share

Rate