|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Convert Int to String and add to another StringHi,
I have a SP where I grab a value from an Identity field and then I want to convert it to a String and add it to another string. Only the @lname stores in the @CustNum. From what I understand STR should change it to a string. Any help would be great. Here is the example Declare @lname varchar(10) Declare @lnameid int declare @CustNum varchar(15) INSERT INTO ClientGenerator(ClientCode) VALUES (@Lname + @Fname) SELECT @lnameid=SCOPE_IDENTITY() Set @CustNum = @lname + STR(@lnameid) Take a look at CAST,CONVERT system functions in the BOL
Show quote "Vear" <V***@discussions.microsoft.com> wrote in message news:EDEDC80E-A41E-4DA0-953C-0E4A61F198CB@microsoft.com... > Hi, > > I have a SP where I grab a value from an Identity field and then I want to > convert it to a String and add it to another string. > > Only the @lname stores in the @CustNum. From what I understand STR should > change it to a string. Any help would be great. > > Here is the example > > Declare @lname varchar(10) > Declare @lnameid int > declare @CustNum varchar(15) > > INSERT INTO ClientGenerator(ClientCode) VALUES (@Lname + @Fname) > SELECT @lnameid=SCOPE_IDENTITY() > > Set @CustNum = @lname + STR(@lnameid) Thanks, Cast worked Great!!
Show quote "Uri Dimant" wrote: > Take a look at CAST,CONVERT system functions in the BOL > > "Vear" <V***@discussions.microsoft.com> wrote in message > news:EDEDC80E-A41E-4DA0-953C-0E4A61F198CB@microsoft.com... > > Hi, > > > > I have a SP where I grab a value from an Identity field and then I want to > > convert it to a String and add it to another string. > > > > Only the @lname stores in the @CustNum. From what I understand STR should > > change it to a string. Any help would be great. > > > > Here is the example > > > > Declare @lname varchar(10) > > Declare @lnameid int > > declare @CustNum varchar(15) > > > > INSERT INTO ClientGenerator(ClientCode) VALUES (@Lname + @Fname) > > SELECT @lnameid=SCOPE_IDENTITY() > > > > Set @CustNum = @lname + STR(@lnameid) > > > |
|||||||||||||||||||||||