CREATE PROCEDURE UpdateCustomer
(
@CustomerID BIGINT
,@Name VARCHAR(40)
,@Address1 VARCHAR(20)
,@Address2 VARCHAR(20)
,@District VARCHAR(20)
,@State VARCHAR(20)
,@Country VARCHAR(20)
,@ZIPPIN VARCHAR(20)
,@Website VARCHAR(20)
,@email VARCHAR(20)
,@Telephone VARCHAR(12)
,@ContactPerson VARCHAR(20)
,@Mobile VARCHAR(12)
,@Reference_Name VARCHAR(20)
,@Naration VARCHAR(50)
)
AS
DECLARE @FIRSTNAME VARCHAR(20);
DECLARE @LASTNAME VARCHAR(20);
SELECT @FIRSTNAME=SELECT Item from dbo.SplitString(@Name,' ')where ItemIndex=0
SELECT @LASTNAME=SELECT Item from dbo.SplitString(@Name, ' ')where ItemIndex=1
UPDATE customers SET CustomerName=@FIRSTNAME,CustomerLName=@LASTNAME,Address1=@Address1,Address2=@Address2,District=@District,State=@State,Country=@Country,ZIPPIN=@ZIPPIN,Website=@Website,email=@email,Telephone=@Telephone,ContactPerson=@ContactPerson,Mobile=@Mobile,Reference_Name=@Reference_Name,Naration=@Naration WHERE CustomerID=@CustomerID
While gridbing i contactenate the first name and lastname as name but while i going for update i have to split the name in to last name and first name for that i used split function
SELECT Item from dbo.SplitString(@Name, ' ')where ItemIndex=0
but when i assaigning into arguments @FirstName it showing the error
SELECT @FIRSTNAME=SELECT Item from dbo.SplitString(@Name, ' ')where ItemIndex=0
any body have idea
i need to split the name parameter based on space and assaign in to last name and first name.
any body have any idea.