Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004

    Question Unanswered: Need Help For Conversion

    Hello All,

    I am in the process of converting my database's columns from char/varchar/text to nchar/nvarchar/ntext.Most of the columns have foreign keys/indexes defined on them.I need to get this done programmatically.Any scripts or help would be invaluable.


  2. #2
    Join Date
    Apr 2003
    Washington DC area

    Smile Need Help For Conversion

    Create a new table!!!!!!!!

  3. #3
    Join Date
    Feb 2004
    San Antonio, TX
    those columns are an implicit conversion
    you can create a new table as stated above or you could modify the column
    in an alter table statement.

    you do however realize that unicode is a space hog and if not neccessary should be avoided.

  4. #4
    Join Date
    May 2004

    Need Help With Conversion

    Hello there,
    I used the following cmds:

    DECLARE @mstmt nvarchar(4000)
    SET @mstmt=''
    SELECT @mstmt=@mstmt+'ALTER TABLE [' + TABLE_NAME +
    '] ALTER COLUMN [' + COLUMN_NAME + ']' +
    CASE WHEN DATA_TYPE = 'char' THEN ' nchar ' WHEN DATA_TYPE = 'varchar' THEN ' nvarchar ' ELSE ' ntext ' END +
    char(13) + char(10) FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE IN ('varchar', 'char', 'text')
    PRINT @mstmt
    EXEC (@mstmt)

    This script works perfectly in displaying the result in the query analyzer, but when i see the 'design table' in Enterprise manager for the tables which have been altered, the columns are still the same old types.In other words,the query is not implemented in the database.Also for ntext, the column size displayed is huge = 2147483647.
    Please help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts