有没有办法绕过 SQL Server 中的 8k 行长度限制? [英] Is there a way around the 8k row length limit in SQL Server?

查看:48
本文介绍了有没有办法绕过 SQL Server 中的 8k 行长度限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我知道通常使用大量宽列是一个坏主意,但这是我所限制的格式.

First off, I know that in general having large numbers of wide columns is a bad idea, but this is the format I'm constrained to.

我有一个应用程序,可以在操作它们并在数据库中插入/更新值之前将 CSV 文件导入到临时表中.临时表是动态创建的,并具有可变数量的 NVARCHAR 列(文件导入到其中),以及两个用作行 ID 的 INT 列.

I have an application that imports CSV files into a staging table before manipulating them and inserting/updating values in the database. The staging table is created on the fly and has a variable number of NVARCHAR colums into which the file is imported, plus two INT columns used as row IDs.

我必须导入的一个特定文件大约有 450 列宽.在大型 NVARCHAR 列中使用 24 字节指针时,根据我的计算,这加起来约为 10k,并且出现错误 无法创建大小为 11166 的行,该行大于允许的最大行大小 8060.

One particular file I have to import is about 450 columns wide. With the 24 byte pointer used in a large NVARCHAR column, this adds up to around 10k by my calculations, and I get the error Cannot create a row of size 11166 which is greater than the allowable maximum row size of 8060.

有没有办法解决这个问题,或者我唯一的选择是修改导入器以拆分导入或从文件中删除列?

Is there a way around this or are my only choices modifying the importer to split the import or removing columns from the file?

推荐答案

如果您使用的是 SQL Server 2005、2008 或 2012,您应该能够使用大于 8,000 个字符的 NVARCHAR(max) 或 NTEXT.MAX 会给你 2^31 - 1 个字符:

If you are using SQL Server 2005, 2008 or 2012, you should be able to use NVARCHAR(max) or NTEXT which would be larger than 8,000 characters. MAX will give you 2^31 - 1 characters:

http://msdn.microsoft.com/en-us/library/ms186939(v=sql.90).aspx

这篇关于有没有办法绕过 SQL Server 中的 8k 行长度限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆