Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 Check the value of all character fields in a Sybase Db

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-11-16 : 09:43:52
Edwin writes "I want to search all character fields of all tables of my Sybase database for a certain value and replace it by another value.

I select all the information I need with the following query:
SELECT O.name as dbTABLE,
C.name AS dbFIELD,
T.name AS TYPE
FROM syscolumns C ,
sysobjects O,
systypes T
WHERE C.id = O.id
AND C.usertype = T.usertype
AND O.type = "U"

Then i declare the local variables, step trough the resultset by using a cursor and i try to update the fields dynamically:

if (@dbfield_type = "char" or @dbfield_type = "varchar")
Update @dbtable_name
set @dbfield_name = "xxx"
where @dbfield_name = "yyy"

But this results in the following error:
Server Message: Number 102
Incorrect syntax near '@dbtable_name'.

Is there another way to accomplish this (except from writing lots of update statements)?"
   

- Advertisement -