Rachid
Rachid

Reputation: 67

how to put 2 parameters in 1 column?

ALTER PROCEDURE [dbo].[SprInvoerGemeente]
    -- Add the parameters for the stored procedure here
    @postcode varchar(4),
    @naam_gemeente varchar(105),
    --@postcode_gemeente varchar(105)

AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    insert into postcode (postcode, naam_gemeente, postcode_gemeente) 
    values(@postcode ,@naam_gemeente,@postcode ""  @naam_gemeente)
END

in the values section i try to put the 2 parameters (@postcode, @naam_gemeente) in 1 column, can somebody help me with the syntax please???

Upvotes: 0

Views: 58

Answers (3)

Oded
Oded

Reputation: 499012

You need to concatenate them into a single value:

values(@postcode ,@naam_gemeente,@postcode + ' ' + @naam_gemeente)

Upvotes: 2

Neil Knight
Neil Knight

Reputation: 48547

In your values you need to add a + to concatenate the two columns together:

insert into postcode (postcode, naam_gemeente, postcode_gemeente)     
     values (@postcode, @naam_gemeente,@postcode + " " + @naam_gemeente)

Upvotes: 1

manji
manji

Reputation: 47978

String concatenation operator +:

insert into postcode (postcode, naam_gemeente, postcode_gemeente) 
    values(@postcode ,@naam_gemeente,@postcode + " " + @naam_gemeente)

Upvotes: 2

Related Questions