sql中变量的数据类型大小 [英] Data type size of variable in sql

查看:47
本文介绍了sql中变量的数据类型大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在sql中找出数据类型的大小.例如,如果我已将变量或列声明为

How to find out the size of data type in sql. For example if i have declared a variable or column as

declare @test varchar(255)

然后我需要将变量数据类型@test 的大小显示为 255.

Then i need the size of the variable data type @test to be shown as 255.

现在,我知道如何为列获取它,有没有办法获取变量?

Now, I know how to get it for the column, is there any way for variable?

推荐答案

您可以使用 sql_variant_property.

declare @test varchar(255)
set @test = '' --Must assign a value
select sql_variant_property(@test, 'MaxLength')

这篇关于sql中变量的数据类型大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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