我有以下功能
ALTER FUNCTION [dbo].[ActualWeightDIMS]
(
-- Add the parameters for the function here
@ActualWeight int,
@Actual_Dims_Lenght int,
@Actual_Dims_Width int,
@Actual_Dims_Height int
)
RETURNS varchar(50)
AS
BEGIN
DECLARE @ActualWeightDIMS varchar(50);
--Actual Weight
IF (@ActualWeight is not null)
SET @ActualWeightDIMS = @ActualWeight;
--Actual DIMS
IF (@Actual_Dims_Lenght is not null) AND
(@Actual_Dims_Width is not null) AND (@Actual_Dims_Height is not null)
SET @ActualWeightDIMS= @Actual_Dims_Lenght + 'x' + @Actual_Dims_Width + 'x' + @Actual_Dims_Height;
RETURN(@ActualWeightDIMS);
END
Run Code Online (Sandbox Code Playgroud)
但当我尝试使用它时,我收到以下错误"将varchar值'x'转换为数据类型int时转换失败." 当我使用以下select语句时
select
BA_Adjustment_Detail.ID_Number [ID_Number],
BA_Adjustment_Detail.Submit_Date [Submit_Date],
BA_Category.Category [category],
BA_Type_Of_Request.Request …Run Code Online (Sandbox Code Playgroud) 我在SQL表中有两列,fooId(int)和fooName(varchar).
有没有办法选择它们作为一列,它们之间有空格?
select fooId + ' ' + fooName as fooEntity
from mytable
Run Code Online (Sandbox Code Playgroud)
他们是不同的类型,所以我得到一个错误.
该字段将直接在Web应用程序的控件中进行数据绑定.
SQL Server 2008
(我是一个sql初学者)