Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASE - Changing from CHAR to VARCHAR

Status
Not open for further replies.

Nordlund

Programmer
Jul 17, 2001
458
SE
Hi.

I've got a problem.
My database is full of CHAR fields. I want to convert them into VARCHAR and RTRIM them all.... This is what i've done... But it doesn't work....
(The RTRIM is done manually, and the example below shows only one table)

Can it be done this way, or?

-- Allow config in sys tables
sp_configure 'allow updates',1
GO

-- Update syscolumns to change from CHAR to VARCHAR in ALL usertables
UPDATE syscolumns SET usertype = 2
WHERE id in (SELECT id FROM sysobjects WHERE type = "U")
AND usertype = 1
GO

-- Disallow config in sys tables
sp_configure 'allow updates',0
GO

-- Trim the Trailing spaces for every VARCHAR field in the table(s) one by one.
UPDATE Table
SET Field1 = RTRIM(Field1),
Field2 = RTRIM(Field2),
Field3 = RTRIM(Field3)
GO


//Nordlund
 
Did it in another way. Problem solved.

//Nordlund
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top