Declare a Scalar Variable Stored Procedure

CREATE PROCEDURE Customer ( FName varchar(20),LName varchar(20),Birthdate datetime,Email Nvarchar(20),Houseno varchar(20),Street varchar(20),City varchar(20),Country varchar(20),Pincode int,Phno varchar(13),Mobile varchar(13),CustomerId varchar(20),Password varchar(20),ConfirmPassword varchar(20)) AS Begin Insert into Registration values (@FName,@LName,@Birthdate,@Email,@Houseno,@Street,@City,@Country, @Pincode,@Phno, @Mobile,@CustomerId,@Password,@ConfirmPassword) End 

Saving the error occurs as

Fname must be declared as Scalar variable

What is wrong with this code?

+4
source share
3 answers

You are missing the "@" sign for parameter declarations.

 create procedure Customer @FName varchar(20),@LName varchar(20) ..... 
+3
source

The variables you are trying to insert were not declared correctly. You must prefix all ads with @.

 create procedure Customer (@FName varchar(20),@LName varchar(20),@Birthdate datetime,@Email Nvarchar(20),@Houseno varchar(20),@Street varchar(20),@City varchar(20),@Country varchar(20),@Pincode int,@Phno varchar(13),@Mobile varchar(13),@CustomerId varchar(20),@Password varchar(20),@ConfirmPassword varchar(20)) AS Begin Insert into Registration values (@FName,@LName,@Birthdate,@Email,@Houseno,@Street,@City,@Country,@Pincode,@Phno, @Mobile,@CustomerId,@Password,@ConfirmPassword) End 
0
source

You must define your local variable as @local_variable, see MSDN

@local_variable Is the name of a variable. Variable names must begin with the at sign (@). Local variable names must follow the rules for

Using @, it tells sqlserver that it is a local variable. You also define @ during insertion.

As before, just add @ in front of each parameter name.

0
source

Source: https://habr.com/ru/post/1400011/


All Articles