mass alter table fields - script help



Hello,
I need to alter fields in all my tables of a given database, and I
would to do this via a t-sql script.
Example, I want to change all fields called SESSION_ID to char(6). The
field is usually varchar(10), but the data is always 6 characters in
length. I have serveral fields that are fixed length that I want to
move from varchar to char.

I believe I can find all the tables where the field exists using
select * from INFORMATION_SCHEMA.columns where column_name =
'SESSION_Id'
but I dont know how to take this into an ALTER TABLE , ALTER COLUMN
that can be automated
TIA
Rob

.



Relevant Pages

  • Re: Returning from an included script while inside a function ?
    ... I am fixing someone elses work, and it's a mess. ... switch statement. ... If I alter the main file - I alter ... database calls is scattered all over a mess of 'ifthen we ...
    (comp.lang.php)
  • Re: Restoring database with different COLLATION
    ... > How I can modify the COLLATION of the database after restoring it? ... as SQL Server 2000 supports different collations and sort orders for each ... ALTER DATABASE db_name ... ALTER COLUMN VARCHAR ...
    (microsoft.public.sqlserver.msde)
  • Re: password file on rac
    ... > instance to change the password file otherwise it wouldn't change. ... Database Password and Role Management in Real Application Clusters ... Application Clusters database to authenticate user access to the database. ... Changing the Password--If you alter the password for an existing user, ...
    (comp.databases.oracle.server)
  • Re: Need to reconfigure SQL Server to be Case-Insensitive
    ... You will want to perform ALTER DATABASE and ALTER TABLE statements. ... You can change the collation of a column by using the ALTER TABLE statement: ... applied to all columns, user-defined data types, variables, and parameters ...
    (microsoft.public.sqlserver.server)
  • SQL Server confused about primary keys. So am I.
    ... We are generating a script to convert a client's database to Sql ... ALTER TABLE dbo.Categories ADD ... CONSTRAINT PK_Categories PRIMARY KEY CLUSTERED ...
    (microsoft.public.sqlserver.server)