I have to concatenate int and varchar and assign that concatenate value to another varchar [Resolved]

Posted by Jenniffer under Sql Server on 4/13/2013 | Points: 10 | Views : 1175 | Status : [Member] | Replies : 1
I have to concatenate int and varchar and assign that concatenate value to another varchar....


Eg. DECLARE @Id int
DECLARE @UsId varchar(200)
DECLARE @Name varchar(200)
SET @Id = '0'
SET @Id = (select Max(@Id) from T_IAS_Application) + 1
SET @UsId = @Id +'_'+ @Name +'_'+ GETDATE() ---------------------------- i got an error here while i run the project

INSERT INTO T_IAS_Application (Id, UsId, Branch, Name)values (@Id, @UsId, @Branch, @Name)

Thanks & Regards
JENI



Responses

Posted by: Jenniffer on: 4/13/2013 [Member] Starter | Points: 25

Up
0
Down

Resolved
I Got an answer..............

DECLARE @Id int
DECLARE @UsId varchar(200)
DECLARE @Name varchar(200)
SET @Id = '0'
SET @Id = (select Max(Id) from T_IAS_Application) + 1
SET @UsId = CONVERT(VARCHAR(50),@Id)+'_' + @Name + '_' + CONVERT(VARCHAR(50),GETDATE())

INSERT INTO T_IAS_Application (Id, UsId, Branch, Name)values (@Id, @UsId, @Branch, @Name)

Thanks & Regards
JENI

Jenniffer, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response