SQL 字符串相加

USE ZJYX --图片插入 DROP PROC SHOP_PIC_INSERT
GO
CREATE PROCEDURE SHOP_PIC_INSERT
--@SHOPID INT,--名店编号
@ACCOUNT VARCHAR(50),--会员账号
@PNAME VARCHAR(100)--图片名称
AS
DECLARE @SHOPID INT
SET @SHOPID=(SELECT SHOPID FROM SHOP WHERE ACCOUNT=@ACCOUNT)
INSERT INTO SHOP_PIC
(
   SHOPID ,
   ACCOUNT ,
   PNAME
)
VALUES
(
   @SHOPID ,
   @ACCOUNT ,
     --@PNAME
   ISNULL(CAST(@SHOPID AS VARCHAR),'')+'-'+ISNULL(CAST(@PNAME AS VARCHAR),'')
)

 

--isnull(@S,''): 如果@S是空,则用''代替,因为null+字符串 = null

 

你可能感兴趣的:(sql)