i'm trying to generate update statement for over 90 tables using the code below:
Declare @cmd VARCHAR(8000)
Select @cmd = COALESCE(@cmd,'') +
'
UPDATE ' + TABLE_NAME + ' SET ' + Column_Name + ' = ''000000000''' + '''
WHERE ' + Column_Name + ' = ''000000001''' + '''
'
From INFORMATION_SCHEMA.COLUMNS
Where TABLE_NAME not in (SELECT TABLE_NAME
From INFORMATION_SCHEMA.VIEWS)
and
(Column_Name like 'SSN%'
OR Column_Name LIKE 'ssn%'
OR Column_Name LIKE 'ssn%'
OR Column_Name LIKE '%_ssn%'
OR Column_Name LIKE '_ocsecno'
OR Column_Name LIKE 'Ssn%');
Select @cmd
The code works but SQL server 2000 is able to generate update statements for only 45 tables out of 91 tables. it truncates the SQL string at the 45th table. Does any knows how to solve this issue?
If you're just trying to generate the update statements you can insert the updates into a temp table.