Re: Change datatype on all table (HELP, HELP, rush)
From: KT (ktdev_at_hotmail.com)
Date: 05/18/04
- Next message: Eric Sabine: "Re: Multiple Newbie Questions (2nd attempt)"
- Previous message: Aaron Bertrand - MVP: "Re: sql functions"
- In reply to: Keith Kratochvil: "Re: Change datatype on all table (HELP, HELP, rush)"
- Next in thread: Keith Kratochvil: "Re: Change datatype on all table (HELP, HELP, rush)"
- Reply: Keith Kratochvil: "Re: Change datatype on all table (HELP, HELP, rush)"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 18 May 2004 13:30:11 -0500
Thanks. Works great.
"Keith Kratochvil" <sqlguy.back2u@comcast.net> wrote in message
news:Or$3Z5PPEHA.1612@TK2MSFTNGP11.phx.gbl...
You will want to test this before running it on a production machine to make
sure that you do not loose any data...
/*this creates scripts that you will need to run*/
SELECT 'ALTER TABLE ' + table_name +
' ALTER COLUMN ' + COLUMN_NAME + ' varchar ' +
' (' + LTRIM(STR(CHARACTER_MAXIMUM_LENGTH)) + ')' +
char(13) + char(10) + 'GO'
FROM information_schema.columns WHERE DATA_TYPE IN ('nvarchar')
-- Keith "KT" <ktdev@hotmail.com> wrote in message news:O0A7M1PPEHA.4008@TK2MSFTNGP09.phx.gbl... > I need a way to change a datatype from nvarchar to varchar on all tables > within a database. Any help appreciated. > > Thanks > >
- Next message: Eric Sabine: "Re: Multiple Newbie Questions (2nd attempt)"
- Previous message: Aaron Bertrand - MVP: "Re: sql functions"
- In reply to: Keith Kratochvil: "Re: Change datatype on all table (HELP, HELP, rush)"
- Next in thread: Keith Kratochvil: "Re: Change datatype on all table (HELP, HELP, rush)"
- Reply: Keith Kratochvil: "Re: Change datatype on all table (HELP, HELP, rush)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|