SqlServer 2012 will be the last version Sqlserver using OLEDB. Future version of MS Sqlserver will not use OLEDB. Instead Microsoft is asking everyone to back to ODBC!!
http://blogs.msdn.com/b/sqlnativeclient/archive/2011/08/29/microsoft-is-aligning-with-odbc-for-native-relational-data-access.aspx
Showing posts with label mssql. Show all posts
Showing posts with label mssql. Show all posts
Friday, 11 May 2012
Saturday, 4 February 2012
Change the precision of all decimal columns in every table in the database
Found a script on the net to change decimal column precision for MSSQL database. Can be modified to change other data type.
Change the precision of all decimal columns in every table in the database
Get the columns from information_schema based on type and scale, then alter them to have the desired scale.
declare @col sysname
declare @tbl sysname
declare @sql nvarchar(256)
declare crsFix cursor for
select table_name, Column_name from information_schema.columns
where data_type = 'decimal' and Numeric_Scale = 3
open crsFix
fetch next from crsFix into @tbl, @col
while(@@Fetch_Status = 0)
Begin
set @sql = 'Alter table [' + @tbl + '] alter column [' + @col + '] decimal(38,2) '
print @sql
exec sp_executesql @sql
fetch next from crsFix into @tbl, @col
End
close crsFix
deallocate crsFix
Change the precision of all decimal columns in every table in the database
Get the columns from information_schema based on type and scale, then alter them to have the desired scale.
declare @col sysname
declare @tbl sysname
declare @sql nvarchar(256)
declare crsFix cursor for
select table_name, Column_name from information_schema.columns
where data_type = 'decimal' and Numeric_Scale = 3
open crsFix
fetch next from crsFix into @tbl, @col
while(@@Fetch_Status = 0)
Begin
set @sql = 'Alter table [' + @tbl + '] alter column [' + @col + '] decimal(38,2) '
print @sql
exec sp_executesql @sql
fetch next from crsFix into @tbl, @col
End
close crsFix
deallocate crsFix
Subscribe to:
Posts (Atom)