convert multiple columns as single row with appreciated data See the image below.

The first table is the actual table.

How to get the expected result in the second table using a procedure when I pass formid as parameter?

example:
exec procedure 123
Hope following expected result script help in your case, but you have prepare it for maximum number of fields.   


Test environment (1 time execution only) as per your scenario:


Create table #Temp
(formid int, FieldName varchar(50), value_ varchar (50) )
go

Insert into #Temp
values 
(101, 'FirstName', 'Name 1'),
(101, 'LastName', 'x'),
(101, 'Email', 'Name@s.com'),
(102, 'FirstName', 'Name 1'),
(102, 'Gender', 'M'),
(102, 'Mobile', '9xxxxxx'),
(103, 'DOB', '19900101')
go



Expected Result 


Declare @FormID int = 103

Select  max(Case when F_Rn = 1 Then formid end) as formid, 
        max(Case when F_Rn = 1 Then FieldName end) as Field1,
        max(Case when F_Rn = 2 Then FieldName end) as Field2,
        max(Case when F_Rn = 3 Then FieldName end) as Field3,
        max(Case when F_Rn = 4 Then FieldName end) as Field4,
        max(Case when F_Rn = 5 Then FieldName end) as Field5,
        max(Case when F_Rn = 6 Then FieldName end) as Field6
from            (
                select formid, 
                       ROW_NUMBER() OVER (Order by FieldName) as F_Rn,
                       FieldName,
                       value_
                from #Temp
                where formid = @FormID
                ) as t
go



Drop Test environment 


Drop Table #Temp
go