Update Collation of all fields in database on the fly

后端 未结 8 1702
说谎
说谎 2020-12-07 21:00

We recently moved our database from our SQL Server 2005 server to our SQL Server 2008 server. Everything moved over fine, however now we are finding that we are getting col

8条回答
  •  醉梦人生
    2020-12-07 21:19

    Further to Owais Iqbal's answer rewritten the code by edosoft and put it in a loop to execute the actual T-SQL statements, you can grab the default collation from the database

    -- **************** BEGIN INPUT **********************
    USE [YourDBName]
    -- **************** END INPUT ************************
    
    -- **************** BEGIN GET DB COLLATION ***********
    DECLARE @collation NVARCHAR(128)
    SELECT @collation = collation_name
    FROM sys.databases WHERE database_id = DB_ID()
    
    PRINT 'Default database collation: ' + @collation
    PRINT ''
    -- **************** END GET DB COLLATION *************
    
    -- **************** BEGIN LOGIC **********************
    

提交回复
热议问题