T-SQL insert value based on identity column Is it possible to have a table with PK based on Identity columns?  

Lets say I have a table of customers, two fields are important for our case Id which is PK nvarchar(20) and SequenceId which is int identity(1,1). I want to have a stored procedure that will have(among others) a parameter @CustomerType and based on this parameter will generate the value for Id and insert a new row into the table. Something like this:

CREATE PROCEDURE createCustomer
@CustomerType int, 
@GivenName nvarchar(20), 
@Surname nvarchar(20), 
@BirthDate date = null
...
AS
BEGIN
    SET NOCOUNT ON;

    DECLARE @prefix nvarchar(1) = N'x'
    IF @CustomerType = 1
    BEGIN
        SET @prefix = N'P'
    END
...
    ELSE
    BEGIN
        SET @prefix = N'x'
    END

    INSERT INTO [dbo].[Customers]
           ([Id],
            [GivenName],[Surname],[BirthDate])
    VALUES
           (@prefix + (SequenceId + 1000000),
        @GivenName,@Surname,@BirthDate);

    SELECT INSERTED.Id AS CustomerId;
END
You never set the SequenceId to anything.  It is not possible to set the value of a column during an insert using an expression that references the value of an IDENTITY column on that same table that will be set upon that same insert operation.  If you think about it this makes sense because the row doesn't exist until you insert it, so there is no IDENTITY value at the time that the insert begins.

If what you want is to create a column that concatenates a prefix and an IDENTITY value then you should use a computed column, for example:

CREATE TABLE dbo.Customers
( Sequence   int  IDENTITY(1,1) NOT NULL
, Prefix     nchar(1) NOT NULL
, CustomerID AS Prefix + CAST(Sequence + 1000000 as nvarchar(8))
, GivenName  nvarchar(50)
... etc ... 
, CONSTRAINT UN_CustomersSequence UNIQUE (Sequence)
, CONSTRAINT PK_Customers PRIMARY KEY (CustomerID)
)


You should be able to make CustomerID in the above table your primary key if you want.  Since the Sequence value is already unique (by virtue of being IDENTITY) I would question why you want to make a compound primary key.  Are you sure that this is the design you want?