Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Change data type on all char(36) columns in db
Message
De
04/09/2013 22:05:59
 
 
À
04/09/2013 21:42:57
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01582234
Message ID:
01582239
Vues:
36
Thanks. I was thinking ( much more fuzzily ) along those lines. A cursor table, column representing all those that need to be changed, then a scriptwriter

Of course since this is a one off, once I had a table it might be fun to try to creat the script with a set based approach. (did crazier stuff than that at Dow Jones to build reporting on what my SSIS was doing)

starting here :
DECLARE @guids TABLE
(
tbl VARCHAR(100),
col VARCHAR(100)

)

INSERT INTO @guids
  select 
  tables.name,
          col.name 
          --column_id ,
          --system_type_id ,
          --max_length ,
          --precision
          from sys.columns col
  JOIN sys.tables 
  ON col.object_id = tables.OBJECT_ID
    where  system_type_id = 175 AND max_length = 36 
  ORDER BY tables.name, column_id
  
  
  
>I'm literally thinking as I'm typing (dangerous combination).
>
>If you queried sys.columns....
>
>select * from sys.columns where max_length = 36 and system_type_id = 175
>
>I "think" that would give you the columns. Now, you'd have to take the object_ids and join to sys.tables to get the table names.
>
>It would seem to me that any loop to construct a full script would use that at the beginning.
>
>Again, just a partial idea, but maybe that can help...(I'd be tempted to write a short .NET program to iterate through the rows and generate a t-sql script)


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform