如何在 SQL 2000 中从 VARCHAR 切换到 TEXT?

发布于 2024-08-31 02:43:30 字数 187 浏览 4 评论 0原文

在将一堆字段从 VARCHAR(bignumber) 切换到 TEXT 之前,我需要考虑什么?

除了性能之外,在不久的将来,TEXT 将被弃用,而且除了看起来我需要删除并重新创建表以更改列的数据类型这一事实之外?

这是针对 SQL 2000 的——我无法执行 VARCHAR(max) 并且 VARCHAR(8000) 不够大。

What do I need to consider before I switch a bunch of fields from VARCHAR(bignumber) to TEXT?

Aside from performance, and sometime in the far future TEXT will be deprecated, and aside from the fact that it looks like I need to drop and recreate the table to alter the column's data type?

This is for SQL 2000-- I can't do VARCHAR(max) and VARCHAR(8000) isn't large enough.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

离去的眼神 2024-09-07 02:43:30

不确定是否不能只更改列的数据类型:

ALTER TABLE dbo.YourTable
  ALTER COLUMN YourColumn TEXT

这不起作用吗? (不确定这在 2000 年是否有效......)

至于要记住的事情:如果您需要进行字符串操作,则 TEXT 数据类型使用起来也更加麻烦,因为大多数(如果不是全部)常用字符串LEN、SUBSTRING 等函数对其不起作用。因此,在 T-SQL 本身中,它是处理 TEXT 列的主要 PIA...

但除此之外,我相信您应该没问题。

Not sure if you cannot just alter the column's data type:

ALTER TABLE dbo.YourTable
  ALTER COLUMN YourColumn TEXT

Doesn't that work? (not sure if that worked back on 2000.....)

As for things to remember: the TEXT data type also is a lot more cumbersome to work with if you need to do string manipulation, since most if not all the usual string functions like LEN, SUBSTRING etc. don't work on it. So in T-SQL itself, it's a major PIA to work with TEXT columns....

But other than that, you should be fine, I believe.

你的呼吸 2024-09-07 02:43:30

至少:

回到过去的 SQL Server 6.5 天,我将一些数据存储在几个 varchar(255) 列中,因为 varchar(8000) 仅在 SQL Server 7 中引入。

At least:

Back in ye olden SQL Server 6.5 days, I stored some data in several varchar(255) columns because varchar(8000) was only introduced with SQL Server 7.

断念 2024-09-07 02:43:30

许多 T-SQL 字符串函数无法处理文本 - 它们只能处理 char/varchar/nchar/nvarchar。

Many T-SQL string functions won't work with text - they only work with char/varchar/nchar/nvarchar.

情绪少女 2024-09-07 02:43:30

首先,您无法搜索字段,并且许多使用字符串操作函数的查询将不起作用。最好将字段分成两个或多个。说真的,如果这是唯一的方法,因为升级到 SQL Server 2008 Express 版本可能比坚持使用 SQL Server 2000 更好,恕我直言。事实上,分割领域也很糟糕。忘了那个吧。我不会这样做,除非我的老板拒绝升级,然后我必须选择哪些字段为 VARCHAR(MAX) 以及哪些字段要拆分,以及哪些字段可能会使用 Text 作为类型。

You cannot search the fields, for one, and many queries will not work, which use string manipulation functions. Better to split the field into two or more. Seriously, if that's the only way, because an upgrade to the Express version of SQL Server 2008 would probably be better than sticking with SQL Server 2000 at this point, IMHO. Actually, splitting the fields would just be bad too. Forget that. I would not do it, unless my boss refused to upgrade, then I'd have to pick and choose which fields to VARCHAR(MAX) and which to split up, and which may get away with Text as the type.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文