复制代码 代码如下:
SELECT * FROM Orders
WHERE OrderGUID IN('BC71D821-9E25-47DA-BF5E-009822A3FC1D','F2212304-51D4-42C9-AD35-5586A822258E')
复制代码 代码如下:
SELECT * FROM Orders
WHERE OrderGUID IN('BC71D821-9E25-47DA-BF5E-009822A3FC1D,F2212304-51D4-42C9-AD35-5586A822258E')
复制代码 代码如下:
DECLARE @IDs VARCHAR(4000)
SET @IDs='BC71D821-9E25-47DA-BF5E-009822A3FC1D,F2212304-51D4-42C9-AD35-5586A822258E'
DECLARE @temp TABLE(str VARCHAR(50))
INSERT INTO @temp
SELECT * FROM dbo.Split(@IDs,',')
SELECT * FROM Orders WHERE OrderGUID IN (SELECT str FROM @temp)
复制代码 代码如下:
CREATE FUNCTION Split
(
@SourceSql varchar(8000),
@StrSeprate varchar(10)
)
RETURNS @temp TABLE(F1 VARCHAR(100))
AS
BEGIN
DECLARE @i INT
SET @SourceSql=rtrim(ltrim(@SourceSql))
SET @i=charindex(@StrSeprate,@SourceSql)
WHILE @i>=1
BEGIN
INSERT @temp VALUES(left(@SourceSql,@i-1))
SET @SourceSql=substring(@SourceSql,@i+1,len(@SourceSql)-@i)
SET @i=charindex(@StrSeprate,@SourceSql)
END
IF @SourceSql<>''
INSERT @temp VALUES(@SourceSql)
RETURN
END
复制代码 代码如下:
SELECT * FROM Orders
WHERE 'BC71D821-9E25-47DA-BF5E-009822A3FC1D,F2212304-51D4-42C9-AD35-5586A822258E'
LIKE '%'+convert(VARCHAR(40),OrderGUID)+'%'
新闻热点
疑难解答