sql server - Variables in T-SQL -
i have 1 column in table, in table there inputs 990x70, 980x50. need values left , right of 'x' calculate inches of these 2 values. code take last registered entry database. how can entries? (note: have use variables in project.)
declare @value1 numeric(18,1) declare @value2 numeric(18,1) select @value2 = substring( [values], charindex('x', [values]) + 1, len([values])) , @value1 = substring( [values], 1, charindex('x', [values]) - 1) mytable select @value1=@value1/(2.54) select @value2=@value2/(2.54) select @value1,@value2 mytable
edit: there 4 different sizes in table , same result 4 times. want results not 1.
now, admittedly, i'm not totally clear on you're asking. sounds 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 mytable
that should same thing you're doing, without of variables (which are, in usage, inherently one-dimensional).
Comments
Post a Comment