需要暂时将 Text 字段转换为 Varchar,以便我可以传递给存储过程 [英] Need to convert Text field to Varchar temporarily so that I can pass to a stored procedure
问题描述
我使用的是 SQL 2000 数据库.
I am using a SQL 2000 database.
我正在使用一个无法更改表类型或存储过程的数据库.我需要调用的存储过程之一需要文本"参数.我可以访问文本字段,但我无法弄清楚谁将其存储在变量中或以任何其他方式将其传递给存储过程?
I am working with a database in which I cannot change the types on the tables, or the stored procedures. One of the stored procedures I need to call expects a parameter of 'text'. I can get to the text field, but I am unable to figure out who to store that in a variable or any other way to pass it into the stored procedure?
如果我尝试创建一个文本变量,SQL 不会让我 - 如果我将其转换为 varchar,我只能从文本字段中获取第一个字符.
If I try and create a text variable, SQL won't let me - if I convert it to varchar I only get the first character from the text field.
解决这个问题的任何技巧都非常感谢!谢谢!
Any tricks to get around this much appreciated! Thank you!
推荐答案
声明类型为varchar(8000)
declare @v varchar(8000)
SET @v = (SELECT CAST(textcol as varchar(8000)) FROM yourtable WHERE ....)
显然它可能仍然被截断,但不是 1 个字符.
Obviously it might still be truncated but not at 1 character.
这篇关于需要暂时将 Text 字段转换为 Varchar,以便我可以传递给存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!