我的条款是#ff0000,'#000' 。但问题是我必须将值传递给存储过程作为参数,以根据此颜色代码获取颜色名称。
这是我的存储过程
@ColorCode NVARCHAR(150)
AS
BEGIN
SET NOCOUNT ON;
SELECT *
FROM color
WHERE code IN (@ColorCode)
我想使用参数为IN
子句传递这些值。我怎么能这样做?
请建议
答案 0 :(得分:0)
试试这个
CREATE PROCEDURE Usp_split
(
@ColorCode NVARCHAR(150)
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET nocount ON;
DECLARE @SPlitDAta TABLE
(
colorcode NVARCHAR(150)
)
INSERT INTO @SPlitDAta
SELECT @ColorCode
SELECT *
FROM color
WHERE code IN (SELECT split.a.value('.', 'VARCHAR(1000)')
FROM (SELECT Cast('<S>' + Replace(colorcode, ',',
'</S><S>')
+ '</S>' AS XML) AS ColorCode
FROM @SPlitDAta) AS A
CROSS apply colorcode.nodes('/S') AS Split(a))
END