When I imported a table in SQL it suggested real datatype, now I would like to change all columns to double type…
Is there any script to automatically do this in SQL Managment Studio
My table is 500 columns:
`After doing` EXECUTE sp_help traS
Col Type Comp len Prec Scale Nullable TrimTrailing Fixed Collation
-------------------------------------------------------------------------------
x1 real no 4 24 NULL yes (n/a) (n/a) NULL
x2 real no 4 24 NULL yes (n/a) (n/a) NULL
x3 real no 4 24 NULL yes (n/a) (n/a) NULL
x4 real no 4 24 NULL yes (n/a) (n/a) NULL
...
x500 real no 4 24 NULL yes (n/a) (n/a) NULL
The following code will place a list of columns into a temporary table called
@cols, loop through that table, generate analter table alter columnstatement, and execute it for each column.If you need to exclude columns, you should include those in the
NOT INpredicate of the select from information_schema.columns.