Upgrade Image&ntext to varbinarymax&nvarchar(max)
CREATE PROCEDURE SP_EXEC_WITH_LOG(@I_TICKETNO VARCHAR(10),@I_SQLSTR nvarchar(max))
AS
BEGIN
DECLARE @QUOTATION_TRANSFER_STR nvarchar(max);
SET @QUOTATION_TRANSFER_STR = REPLACE(@I_SQLSTR,'''','''''');
BEGIN TRY
EXEC SP_EXECUTESQL @I_SQLSTR;
EXEC GPUPGRADE_LOGGING @I_TICKETNO,@QUOTATION_TRANSFER_STR,'SUCCESS',0
END TRY
BEGIN CATCH
declare @message varchar(2000);
select @message = ERROR_MESSAGE();
EXEC GPUPGRADE_LOGGING @I_TICKETNO,@QUOTATION_TRANSFER_STR,@message,1
END CATCH
END
GO
CREATE PROCEDURE UPDATE_IMAGE_TO_VARBINARYMAX
AS
BEGIN
declare @vstr nvarchar(1000);
declare @vtabname nvarchar(100);
declare @vSchemaName nvarchar(100);
declare @vcolumnName nvarchar(100);
declare c_table cursor scroll for select TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where DATA_TYPE='image' and (table_schema='gpglobal' or table_schema like 'gpcomp%');
declare c_view cursor scroll for select TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where DATA_TYPE='image' and table_schema ='dbo';
declare c_small_table cursor scroll for
select TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS
where DATA_TYPE='varbinary'
and CHARACTER_MAXIMUM_LENGTH=-1
and (table_schema='gpglobal' or table_schema like 'gpcomp%')
and TABLE_NAME not like '%_arch';
open c_table;
fetch first from c_table into @vSchemaName,@vtabname,@vcolumnName;
while @@fetch_status = 0
begin
set @vstr = '';
set @vstr = N'ALTER TABLE '+@vSchemaName+'.'+@vtabname+' ALTER COLUMN '+@vcolumnName+' VARBINARY(MAX)';
print @vstr;
exec SP_EXECUTESQL @vstr;
fetch next from c_table into @vSchemaName,@vtabname,@vcolumnName;
end;
close c_table;
deallocate c_table;
set @vSchemaName = '';
set @vtabname = '';
set @vcolumnName = '';
open c_view;
fetch first from c_view into @vSchemaName,@vtabname,@vcolumnName;
while @@fetch_status = 0
begin
set @vstr = '';
set @vstr = N'DROP VIEW ['+ @vSchemaName+'].['+@vtabname +']';
print @vstr;
exec SP_EXECUTESQL @vstr;
set @vstr = '';
set @vstr = N'CREATE VIEW ['+ @vSchemaName+'].['+@vtabname +'] AS SELECT * FROM GPGLOBAL.'+@vtabname ;
print @vstr;
exec SP_EXECUTESQL @vstr;
fetch next from c_view into @vSchemaName,@vtabname,@vcolumnName;
end;
close c_view;
deallocate c_view;
set @vSchemaName = '';
set @vtabname = '';
set @vcolumnName = '';
open c_small_table;
fetch first from c_small_table into @vSchemaName,@vtabname,@vcolumnName;
while @@fetch_status = 0
begin
set @vstr = '';
set @vstr = N'UPDATE '+@vSchemaName+'.'+@vtabname+' SET '+@vcolumnName+' = '+@vcolumnName;
print @vstr;
exec SP_EXECUTESQL @vstr;
set @vstr = N'ALTER INDEX ALL ON ' +@vSchemaName+'.'+@vtabname+ ' reorganize WITH (LOB_COMPACTION=ON)';
print @vstr;
exec SP_EXECUTESQL @vstr;
fetch next from c_small_table into @vSchemaName,@vtabname,@vcolumnName;
end;
close c_small_table;
deallocate c_small_table;
END
GO
CREATE PROCEDURE UPDATE_NTEXT_TO_VARCHARMAX
AS
BEGIN
declare @vstr nvarchar(1000);
declare @vtabname nvarchar(100);
declare @vSchemaName nvarchar(100);
declare @vcolumnName nvarchar(100);
declare c_table cursor scroll for select TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where DATA_TYPE='ntext' and (table_schema='gpglobal' or table_schema like 'gpcomp%');
declare c_view cursor scroll for select TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where DATA_TYPE='ntext' and table_schema ='dbo';
declare c_small_table cursor scroll for
select TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS
where DATA_TYPE='nvarchar'
and CHARACTER_MAXIMUM_LENGTH=-1
and (table_schema='gpglobal' or table_schema like 'gpcomp%')
and TABLE_NAME not like '%_arch'
and TABLE_NAME not in(
'GPRECL'
,'GPPROB'
,'GPCRDLOGS'
,'GPCUSTBLOB'
,'GPRECLLOG'
,'GPACTV'
);
open c_table;
fetch first from c_table into @vSchemaName,@vtabname,@vcolumnName;
while @@fetch_status = 0
begin
set @vstr = '';
set @vstr = N'ALTER TABLE '+@vSchemaName+'.'+@vtabname+' ALTER COLUMN '+@vcolumnName+' NVARCHAR(MAX)';
print @vstr;
exec SP_EXECUTESQL @vstr;
fetch next from c_table into @vSchemaName,@vtabname,@vcolumnName;
end;
close c_table;
deallocate c_table;
set @vSchemaName = '';
set @vtabname = '';
set @vcolumnName = '';
open c_view;
fetch first from c_view into @vSchemaName,@vtabname,@vcolumnName;
while @@fetch_status = 0
begin
set @vstr = '';
set @vstr = N'DROP VIEW ['+ @vSchemaName+'].['+@vtabname +']';
print @vstr;
exec SP_EXECUTESQL @vstr;
set @vstr = '';
set @vstr = N'CREATE VIEW ['+ @vSchemaName+'].['+@vtabname +'] AS SELECT * FROM GPGLOBAL.'+@vtabname ;
print @vstr;
exec SP_EXECUTESQL @vstr;
fetch next from c_view into @vSchemaName,@vtabname,@vcolumnName;
end;
close c_view;
deallocate c_view;
set @vSchemaName = '';
set @vtabname = '';
set @vcolumnName = '';
open c_small_table;
fetch first from c_small_table into @vSchemaName,@vtabname,@vcolumnName;
while @@fetch_status = 0
begin
set @vstr = '';
set @vstr = N'UPDATE '+@vSchemaName+'.'+@vtabname+' SET '+@vcolumnName+' = '+@vcolumnName;
print @vstr;
exec SP_EXECUTESQL @vstr;
set @vstr = N'ALTER INDEX ALL ON ' +@vSchemaName+'.'+@vtabname+ ' reorganize WITH (LOB_COMPACTION=ON)';
print @vstr;
exec SP_EXECUTESQL @vstr;
fetch next from c_small_table into @vSchemaName,@vtabname,@vcolumnName;
end;
close c_small_table;
deallocate c_small_table;
END
GO
exec UPDATE_IMAGE_TO_VARBINARYMAX;
GO
exec UPDATE_NTEXT_TO_VARCHARMAX;
GO
drop PROCEDURE UPDATE_IMAGE_TO_VARBINARYMAX;
go
drop PROCEDURE UPDATE_NTEXT_TO_VARCHARMAX;
GO
SELECT * FROM gpmainuser.UPGRADE_LOG;
GO
select * from INFORMATION_SCHEMA.COLUMNS where DATA_TYPE='nvarchar' and TABLE_SCHEMA='GPcomp1'
UPDATE gpcomp1.GARECEIPT_ARCH SET FEED_DATA = FEED_DATA;
select TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME
from INFORMATION_SCHEMA.COLUMNS i , sys.index_columns idx
where DATA_TYPE='ntext' and (table_schema='gpglobal' or table_schema like 'gpcomp%');
select s.name,o.name,I.name,c.name,t.name
from
sys.columns c,
sys.index_columns ic ,
sys.indexes i ,
sys.objects o,
sys.schemas s,
sys.types t
where i.object_id = ic.object_id
and i.index_id = ic.index_id
and i.object_id = o.object_id
and s.schema_id = o.schema_id
and ic.column_id =c.column_id
and t.system_type_id = c.system_type_id
and (s.name ='gpglobal' or s.name like 'gpcomp%')
and o.name ='GPRECL'
and c.name = 'REMARKS'
and t.name = 'ntext'
select distinct s.name,o.name,i.name,c.name,t.name
from
sys.columns c,
sys.index_columns ic ,
sys.indexes i ,
sys.objects o,
sys.schemas s,
sys.types t
where i.object_id = ic.object_id
and i.index_id = ic.index_id
and i.object_id = o.object_id
and s.schema_id = o.schema_id
and ic.column_id = c.column_id
and ic.object_id = c.object_id
and t.system_type_id = c.system_type_id
and (s.name ='gpglobal' or s.name like 'gpcomp%')
and o.name ='GPCRDLOGS'
and t.name = 'ntext'
select * from sys.indexes
select * from sys.index_columns
select * from sys.columns
select * from sys.objects where name ='GPCRDLOGS'
select * from sys.schemas
select * from sysindexes
select * from sys.types
select * from sys.data_spaces;
select * from sysindexes
select object_name(id) tablename,
8*reserved/1024 reservedMB,
rtrim(8*dpages/1024)+'Mb' used,
8*(reserved-dpages)/1024 unused,
8*dpages/1024-rows/1024*minlen/1024 free,rows,*
from sysindexes
where indid=1 AND object_name(id)='GPCRDLOGS'
order by reserved desc
exec sp_spaceused N'GPCOMP1.GPCRDLOGS'
exec sp_refreshview N'gpcomp1.aa'
http://connect.microsoft.com/SQLServer/feedback/details/669621/sp-refreshview-fails-for-views-that-were-created-without-explicitly-qualifying-their-schema-name
http://mitchelsellers.com/blogs/2007/07/27/determing-sql-server-table-size.aspx
http://therightstuff.de/CommentView,guid,df930155-f60f-4f56-ab33-f1352ff091a1.aspx
http://msdn.microsoft.com/en-us/library/hh245121.aspx
http://technet.microsoft.com/zh-cn/library/ms162833.aspx
http://technet.microsoft.com/zh-cn/library/ms162808%28v=sql.105%29.aspx
http://technet.microsoft.com/zh-cn/library/ms162843.aspx
http://technet.microsoft.com/zh-cn/library/ms180944.aspx
http://technet.microsoft.com/en-us/library/ms188603%28v=sql.105%29.aspx
http://blogs.msdn.com/b/sqlserverfaq/archive/2008/10/14/sql-server-can-perform-slow-after-changing-the-cost-threshold-for-parallelism.aspx
http://sqlblog.com/blogs/jonathan_kehayias/archive/2010/01/19/tuning-cost-threshold-of-parallelism-from-the-plan-cache.aspx
http://www.mssqlcity.com/Articles/Undoc/SQL2000UndocSP.htm
http://my.oschina.net/tangyu/blog/79120
http://sqlmag.com/t-sql/varbinarymax-tames-blob
http://www.poorren.com/sqlserver-2005-varcharmax-nvarcharmax-varbinarymax/
http://blog.csdn.net/xianshengsun/article/details/7657654
http://blog.csdn.net/xianshengsun/article/details/7657551
Determing SQL Server Table Size
Upgrade Image&ntext to varbinarymax&nvarchar(max)的更多相关文章
- SQL 2005中char、nchar、varchar、ntext and nvarchar(max)的区别
原文地址 MS SQL大值数据类型varchar(max).nvarchar(max).varbinary(max) 在MS SQL2005及以上的版本中,加入大值数据类型(varchar(max). ...
- nvarchar(MAX) 、ntext的差别
今天在做一个项目时,程序成功向数据库插入一条数据, 插入的是一篇比较大的文章,而且还有很多样式. Id是int型,Content用的是 ntext类型的 但是当我在手动改数据库Id时出现错误: 错误源 ...
- sql中nvarchar(max)长度测试
nvarchar(max)长度测试:在使用convert强制类型转化之后 文本长度可以突破8000的上限.并且nvarchar(max)的最大长度可达到2^31以下为验证SQL: Declare @A ...
- MS SQL大值数据类型varchar(max)、nvarchar(max)、varbinary(max)
在MS SQL2005及以上的版本中,加入大值数据类型(varchar(max).nvarchar(max).varbinary(max) ).大值数据类型最多可以存储2^30-1个字节的数据. 这几 ...
- Sql server中的 nvarchar(max) 到底有多大?(转载)
问题: SQL server中的nvarchar(max)最大的长度是4000个字吗? 如果字段的内容超过4000个字时用什么类型呢?text 还是binary?他们的最大长度是多少?比如字段放的是长 ...
- 关于varchar(max), nvarchar(max)和varbinary(max)
在MS SQL2005及以上的版本中,加入大值数据类型(varchar(max).nvarchar(max).varbinary(max) ).大值数据类型最多可以存储2^30-1个字节的数据.这几个 ...
- SQL Server中VARCHAR(MAX)和NVARCHAR(MAX)使用时要注意的问题(转载)
在Microsoft SQLServer2005及以上的版本中,对于varchar(n).nvarchar(n)和varbinary(n)有了max的扩展.可以使用如:varchar(max).nva ...
- sql中NVARCHAR(MAX) 性能和占空间分析 varchar(n),nvarchar(n) 长度性能及所占空间分析
varchar(n),nvarchar(n) 中的n怎么解释: nvarchar(n)最多能存n个字符,不区分中英文. varchar(n)最多能存n个字节,一个中文是两个字节. 所占空间: nvar ...
- --查询nvarchar(max)的表和字段
--查询nvarchar(max)的表和字段 select 'insert into #tempTabelInfo select '''+d.name+''', '''+a.name+''', max ...
随机推荐
- java:正则移出html元素
package com.loongtao.general.crawler.slave; import java.util.regex.Matcher; import java.util.regex.P ...
- Nhibernate Case SUM
SELECT ID END) as nbRowWithValueOf2, END) as nbRowWithValueOf3 FROM Foo GROUP BY ID queryover = quer ...
- jQuery 写的插件图片上下切换幻灯效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- mysql5.6安装
mysql5.6安装 #卸载原有的mysqlyum remove mysql*ls /etc/my.cnf*mv /etc/my.cnf* /tmp/ #安装依赖包yum install make c ...
- Html - 瀑布流
瀑布流,又称瀑布流式布局.是比较流行的一种网站页面布局,视觉表现为参差不齐的多栏布局,随着页面滚动条向下滚动,这种布局还会不断加载数据块并附加至当前尾部.最早采用此布局的网站是Pinterest,逐渐 ...
- IOS第五天(1:取消按钮的监听和设置代理textField字数限制)
***********取消按钮的监听和设置代理textField字数限制 UITextFieldDelegate #import "HMViewController.h" @int ...
- 移动端 :meta标签1万个作用
meta标签 <meta charset="utf-8"> <meta http-equiv="Content-Type" content=& ...
- Hrbustoj 1429 二分+计算几何
http://www.bubuko.com/infodetail-1121744.html 在这个上面学习了方法 如果要判断巨量的点 就应该使用二分法 思路是先从a[1] a[n] a[2]来判断是否 ...
- [ZZ] Cache
http://blog.sina.com.cn/s/blog_6472c4cc0102duzr.html 处理器微架构访问Cache的方法与访问主存储器有类似之处.主存储器使用地址编码方式,微架构可以 ...
- JS页面跳转 神器! window.href window.open
window.open 打开页面, 网址为新的网址 window.href 为打开本网址的链接, 为网站URL+传入的URL