且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

T-SQL 中的变量

更新时间:2023-02-03 19:39:21

现在,诚然,我不是很清楚你在问什么.但听起来像这样应该可以工作:

Now, admittedly, I'm not totally clear on what you're asking. But it sounds like something like this should work:

SELECT CONVERT(NUMERIC(18,1), SUBSTRING([Values], CHARINDEX('x', [Values]) + 1, LEN([Values]))) / 2.54,
       CONVERT(NUMERIC(18,1), SUBSTRING([Values], 1, CHARINDEX('x', [Values]) - 1)) / 2.54
FROM myTable

这应该和您正在做的事情一样,但没有任何变量(在您的使用中,这些变量本质上是一维的).

That should just do the same thing as you're doing, but without any of the variables (which are, in your usage, inherently one-dimensional).