varchar可以覆盖sql_variant吗? [英] Can varchar cover for sql_variant?

查看:111
本文介绍了varchar可以覆盖sql_variant吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一些交互式SQL接口,我想知道是否可以简单地使用varchar来存储数据,并与其他数据类型进行相互转换,因此存储值不会损害我的功能(我"我试图让我的应用程序的配置将过程定义为好像变量是其选择的类型,但实际上我会将它们存储为varchars并在选择时将其转换为所需的类型.sql_variant太杂乱了,因为它无法存储文本,我希望我的应用程序尽可能通用.

有任何建议吗?

I''m trying to create some interactive SQL interface, and I was wondering whether I could simply use varchar to store data, and convert into and from other data types so storing the values wouldn''t damage my functionality (I''m trying to let the configurations of my application define procedures as if variables are of their type of choice, but actually I''m gonna store them as varchars and convert them to their desired type upon choice. sql_variant is messy, because it can''t store texts, and I want my application to be as general as possible.

Any suggestions?

推荐答案

任何内容都可以在字符串之间来回转换(是否要这样做).

您可以使用NVARCHAR(max),它不受限制并支持Unicode. [这至少需要SQL Server 2005]
Anything can be converted to and from strings (whether you would want to do that is another matter).

You can use NVARCHAR(max) which is not limited and supports Unicode. [this requires at least SQL Server 2005]


这篇关于varchar可以覆盖sql_variant吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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