Skip to content

Not sure how thoroughly this was tested on SQL Server, but I got a lot of errors with the included tool #24499

Open
@lunny

Description

@lunny

Not sure how thoroughly this was tested on SQL Server, but I got a lot of errors with the included tool and it appears to have some serious shortcomings (VARCHAR(MAX) doesn't work, and it doesn't quote the names). This is my modified query although I am still having errors due to unique index dependencies.

SELECT 'ALTER TABLE [' + OBJECT_NAME(SC.object_id) + '] ALTER COLUMN [' + SC.name + '] NVARCHAR(' +
CASE WHEN SC.max_length = -1 THEN 'MAX' ELSE CONVERT(VARCHAR(5), SC.max_length) END
+ ')'

FROM SYS.columns SC
JOIN SYS.types ST
ON SC.system_type_id = ST.system_type_id
AND SC.user_type_id = ST.user_type_id
WHERE ST.name ='varchar'

Originally posted by @edwardforgacs in #24105 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions