M
M
Max Trophy2016-04-24 20:40:06
SQL Server
Max Trophy, 2016-04-24 20:40:06

Where is the error in variable assignment in sql stored procedure?

CREATE PROCEDURE mysp1

  @m int,
  @w int

AS

DECLARE  @par1 int,  @par2 int;
SET @par1 = select [поле] from [таблица1] WHERE .... ;
SET @par2 = select [поле] from [таблица2] WHERE .... ;

BEGIN

INSERT INTO 
   таблица (поле1, поле2) 
   values ( @par1,   @par2) -- в эту таблицу и эти поля вставка

END
GO

Swears at
Incorrect syntax near the keyword 'select'.
What could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-04-24
@kapitoly

You misspelled getting the value of a variable. Pay attention to parentheses
or you can write
select @par1 =[поле] from [таблица1] WHERE .... ;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question