-
Script Help
It is suppose to search through the tables of a database for a specific
column and update that column field. Any suggestions to the script I wrote?
I'm having problems with the updating the field.
Script:
Declare @Tablename char(30), @UpdateColumn char (200)
Declare curTable Scroll Cursor For
Select tableobj.Name
From sysobjects tableobj, syscolumns col
Where tableobj.Type = 'U' and tableobj.id = col.id
and Col.Name = 'Facility'
/*For Update of Name*/
Open curTable
Fetch Next From curTable into @Tablename
While @@Fetch_Status = 0
Begin
/*Select @UpdateColumn = "Update" + @Tablename + " Set Facility ='W'"
Exec (@UpdateColumn)*/
/*EXEC ('Update' + @Tablename + 'Set Facility = W'*/
Update tableobj.Name
Set Facility ='W'
Fetch Next From curTable into @Tablename
End
Close curTable
Deallocate curTable
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|