DBA > Job Interview Questions > Sybase Interview Questions and Answers

How To Change varchar(m) to varchar(n) in Sybase

More DBA job interview questions and answers at http://dba.fyicenter.com/Interview-Questions/

(Continued from previous question...)

How To Change varchar(m) to varchar(n) in Sybase?

Before you start:
select max(datalength(column_name))
from affected_table

In other words, please be sure you're going into this with your head on straight.

How To Change System Catalogs

This information is Critical To The Defense Of The Free World, and you would be Well Advised To Do It Exactly As Specified:
use master
go
sp_configure "allow updates", 1
go
reconfigure with override /* System 10 and below */
go
use victim_database
go
select name, colid
from syscolumns
where id = object_id("affected_table")
go
begin tran
go
update syscolumns
set length = new_value
where id = object_id("affected_table")
and colid = value_from_above
go
update sysindexes
set maxlen = maxlen + increase/decrease?
where id=object_id("affected_table")
and indid = 0
go
/* check results... cool? Continue... else rollback tran */
commit tran
go
use master
go
sp_configure "allow updates", 0
go
reconfigure /* System 10 and below */
go

(Continued on next question...)

Other Job Interview Questions