Garima Bansal

Garima Bansal

  • 1.1k
  • 671
  • 38.8k

Concat a string with an Id in sql

Mar 8 2023 6:56 AM

This is my T-Sql

CREATE TABLE [dbo].[Details](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](max) NULL,
    [SId] [int] NULL,
    [PId] [int] NULL,
    [Detail] [nvarchar](max) NULL,
    [Documents] [int] NULL,
    [Mobile_No] [int] NULL,
    [IsActive] [bit] NULL,
    [Status] [nvarchar](max) NULL,
 CONSTRAINT [PK_dbo.GrievanceDetails] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

I want to take the Id and concat it with the word Agri

For example if my Id is 1 then it should br 1Agri

 

How can i do this?


Answers (7)