将 DT_NTEXT 转换为 DT_Text [英] Converting DT_NTEXT to DT_Text

查看:27
本文介绍了将 DT_NTEXT 转换为 DT_Text的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我使用以下代码将日期转换为 MMDDYYYY:

So I'm converting a date to MMDDYYYY using the following code:

replace(convert(varchar(10), Absent_Date, 101), '/', '') as Absent_Date

当我在 Navicat 中运行它时,它运行良好,但是当我使用 SSIS 从存储过程导出到平面文件时,它收到以下错误消息

When I run it in Navicat it runs fine, but when I use SSIS to export from a stored procedure to a flat file it get the following error message

我从这里和其他论坛网站上阅读了大约 20 篇不同的帖子,但没有找到对我来说非常有用的帖子.我尝试使用数据转换对象,但无法正常工作.老实说,我不在乎它是什么格式,只要 SSIS 允许我导出到平面文件我有大约 20 个文本文件,其中的日期需要采用相同的格式.非常感谢任何帮助!

I have read about 20 differnt posts from here and other forum sites but haven't found one that quite works for me. I tried to use the data conversion object but I had trouble getting it to work. I honestly don't care what format it's in just as long as SSIS will let me export to a flat file I have about 20 text files with dates in them that need to be in this same format. Any help is greatly appreciated!

我使用的是 Sql Server 2008 R2

I'm on Sql Server 2008 R2

推荐答案

根据您捕获的错误,我假设来自您的源(OLE、ADO 等)的元数据表明 Absent_Date 列是 DT_NTEXT.然后解决方案是将其转化为有效"的东西.我通常将两个数据转换任务 NTEXT 应用到 TEXT,然后将该 TEXT 转换为字符串类型.如果你的数据是 unicode,那么它只是一个 NTEXT 到 WSTR 的转换,但我是一个愚蠢的美国人.

Based on the error you captured, I am assume that the metadata coming out of your source (OLE, ADO, whatever) indicates that the column Absent_Date is DT_NTEXT. The resolution then is to transform that into something that "works." I typically apply two data conversion tasks NTEXT to TEXT and then I make that TEXT into a string type. If your data is unicode, then it'd just be an NTEXT to WSTR conversion but I'm a dumb American.

在这里您可以看到我的 OLE DB 源输出的元数据表明 Absent_Date 是 NTEXT.最后一步(位桶)将显示长度为 10 的新列 STR_Absent_Date,数据类型为 DT_STR(代码页 1252)

Here you can see the metadata for the output from my OLE DB Source indicates Absent_Date is NTEXT. The final step (bit bucket) would show a new column STR_Absent_Date of length 10, data type of DT_STR (codepage 1252)

采用这种方法应该允许您将 NTEXT 数据转换为与平面文件目标兼容的内容.

Taking this approach should allow you to convert your NTEXT data into something compatible with a flat file destination.

这篇关于将 DT_NTEXT 转换为 DT_Text的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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