|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Update query using uppercase
Hi,
I have a table where the values in the Description field are all upper case. I found a script that will change all the words to UPPERCASE in the first character then LOWERCASE for the remaining until the next space is found. It will also repeat this for all words in the field. The part I need help with is having this repeat through the entire table. Heres the code and thanks - troy declare @input varchar(20) declare @position int set @input = (SELECT Description FROM tbl_ItemMast where wallysku ='10071') set @position = 1 SET @input = Upper(substring(@input,1,1))+ LOWER(substring(@input,2,len(@input)-1)) WHILE @position < DATALENGTH(@input) Begin set @position = charindex(' ',@input,@position+1) if @position = 0 goto done SET @input = REPLACE(@input,substring(@input,@position,2),Upper(substring(@input,@position,2))) End DONE: PRINT @input |
|
#2
|
|||
|
|||
|
i am not really sure (and havent come across this type of programming yet)
but cant you do something like: while not end of table do this; |
|
#3
|
|||
|
|||
|
I'll point you in the right direction,
Use information from syscolumns and sysobjects to cursor through every column in a table. You can find very nice examples here in this forum, of how these and other system tables are used in interesting and helpful ways. Sysobjects holds information on all tables, stored procedures, functions, and even primary and foreign keys. Syscolumns references sysobjects and has all column information for your tables. You can use this information to build a dynamic update statement and then run it for each column in your tables. |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Update query using uppercase |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|