0

This is what i have and what I want to do is use [Value] in my select. I'm not sure what exactly to use in the select statement! Thanks!

DECLARE
TCursor CURSOR FOR
  SELECT [Value] FROM [dbo].[SPLIT] (';', @SplitVar);
OPEN TCursor ;
FETCH NEXT FROM TCursor ;

WHILE @@FETCH_STATUS = 0
 BEGIN
  SET @ETo =
         (SELECT Email
            FROM mytable
           WHERE user= TCursor );
  EXEC sp_SendAn

i'm not sure about this part SELECT Email FROM mytable WHERE user= TCursor

4

1 に答える 1

0

カーソル値を変数にフェッチします。

DECLARE @curvar VARCHAR(50)
DECLARE
TCursor CURSOR FOR
  SELECT [Value] FROM [dbo].[SPLIT] (';', @SplitVar);
OPEN TCursor ;
FETCH NEXT FROM TCursor INTO @curvar;

WHILE @@FETCH_STATUS = 0
 BEGIN
  SET @ETo =
         (SELECT Email
            FROM mytable
           WHERE user= @curvar );
  EXEC sp_SendAn

で何をするつもりなのかわからない@Eto場合は、次を使用する必要がある場合があります。

  SET @ETo = '
         (SELECT Email
            FROM mytable
           WHERE user= '+@curvar+' )'
  EXEC sp_SendAn
于 2013-08-14T20:38:00.107 に答える