在单个变量中用逗号设置多个值,然后从表中选择数据
DECLARE @Values varchar(1000)
SET @Values ='A,B,C'
选择 等等 从 foo
blah值,例如A,B,C,D,E。
答案 0 :(得分:0)
DECLARE @ Crossing1_Table TABLE(Crossing_No NVARCHAR(200),userid INT,GameName varchar(50), GameDate日期,CrossingQty INT,ccount int) 宣告@Id int 宣告@ cross1 varchar(MAX) 宣告@ganame varchar(50) DECLARE @gdate日期 宣告@Cqty int
DECLARE cur_emp CURSOR
STATIC FOR
SELECT CrossingValue1, UserId, GameName, TodayDate, CrossingQty
FROM Game where GameListId=@Gamename and Cast(TodayDate as DATE)=@Gamedate
OPEN cur_emp
IF @@CURSOR_ROWS > 0
BEGIN
FETCH NEXT FROM cur_emp INTO @cross1, @Id, @ganame, @gdate, @Cqty
WHILE @@Fetch_status = 0
BEGIN
INSERT INTO @Crossing1_Table
SELECT CAST(Item AS INT), @Id, @ganame, @gdate, @Cqty, 1
FROM dbo.SplitString(@cross1, ',')
FETCH NEXT FROM cur_emp INTO @cross1, @Id, @ganame, @gdate, @Cqty
END
END
CLOSE cur_emp
DEALLOCATE cur_emp