在SQL Server 2005中检索以图像形式存储为字符串的数据(Retrieving data stored as image as string in SQL Server 2005)

我需要检索存储为SQL Server中图像数据的xml文件。

我正在使用这个查询 -

select convert(varchar, convert(binary, zd.validcontent)) from zonedata zd join contentitem ci on zd.itemid = ci.itemid where id = @dpathid

我得到的文本,但但结果只返回一小部分的XML文件 -

<?xml version="1.0" encoding="

请帮忙。 谢谢。

I need to retrieve an xml file stored as image data in SQL Server.

I am using this query -

select convert(varchar, convert(binary, zd.validcontent)) from zonedata zd join contentitem ci on zd.itemid = ci.itemid where id = @dpathid

I get text but but the result returns only a small portion of the xml file -

<?xml version="1.0" encoding="

Please help. Thanks.

最满意答案

char和varchar :

char [( n )]

varchar [( n | max )]

当在数据定义或变量声明语句中未指定n时,默认长度为1.当使用CAST和CONVERT函数时未指定n时,缺省长度为30。

因此,请指定一个合适的长度(例如,@ Devart的答案中所示的max ,或者任何更合适的值)

char and varchar:

char [ ( n ) ]

varchar [ ( n | max ) ]

When n is not specified in a data definition or variable declaration statement, the default length is 1. When n is not specified when using the CAST and CONVERT functions, the default length is 30.

So, please specify a suitable length (e.g. max as shown in @Devart's answer, or any more appropriate value)

在SQL Server 2005中检索以图像形式存储为字符串的数据(Retrieving data stored as image as string in SQL Server 2005)

我需要检索存储为SQL Server中图像数据的xml文件。

我正在使用这个查询 -

select convert(varchar, convert(binary, zd.validcontent)) from zonedata zd join contentitem ci on zd.itemid = ci.itemid where id = @dpathid

我得到的文本,但但结果只返回一小部分的XML文件 -

<?xml version="1.0" encoding="

请帮忙。 谢谢。

I need to retrieve an xml file stored as image data in SQL Server.

I am using this query -

select convert(varchar, convert(binary, zd.validcontent)) from zonedata zd join contentitem ci on zd.itemid = ci.itemid where id = @dpathid

I get text but but the result returns only a small portion of the xml file -

<?xml version="1.0" encoding="

Please help. Thanks.

最满意答案

char和varchar :

char [( n )]

varchar [( n | max )]

当在数据定义或变量声明语句中未指定n时,默认长度为1.当使用CAST和CONVERT函数时未指定n时,缺省长度为30。

因此,请指定一个合适的长度(例如,@ Devart的答案中所示的max ,或者任何更合适的值)

char and varchar:

char [ ( n ) ]

varchar [ ( n | max ) ]

When n is not specified in a data definition or variable declaration statement, the default length is 1. When n is not specified when using the CAST and CONVERT functions, the default length is 30.

So, please specify a suitable length (e.g. max as shown in @Devart's answer, or any more appropriate value)