bender007
asked on
Convert from Int to String
How do i convert a Int to a string.
I am trying to append a Integer value in a query.
SET @SQL = 'UPDATE status_table SET status' + CONVERT(varchar(10),@statu sCount) + ' = ''' + @Old_status + ''''
I am trying to append a Integer value in a query.
SET @SQL = 'UPDATE status_table SET status' + CONVERT(varchar(10),@statu
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
what is the datatype of @Old_status ? if it is int try something like this
SET @SQL = 'UPDATE status_table SET status' + CONVERT(varchar(10),@statu
@old_status is varchar and StatusCount is int
then your sql should be ok, are you getting any error?
post the error message here
post the error message here
If @Old_status is char or varchar
SET @SQL = 'UPDATE status_table SET status' + CONVERT(varchar(10),@statu sCount) + ' = ''' + ltrim(rtrim(@Old_status)) + ''''
if @Old_status is integer
SET @SQL = 'UPDATE status_table SET status' + CONVERT(varchar(10),@statu sCount) + ' = ''' + CONVERT(varchar(10),@Old_s tatus) + ''''
SET @SQL = 'UPDATE status_table SET status' + CONVERT(varchar(10),@statu
if @Old_status is integer
SET @SQL = 'UPDATE status_table SET status' + CONVERT(varchar(10),@statu
bender007,
> I am trying to append a Integer value in a query.
You can use CAST(urIntegerValue as Varchar(10))
> I am trying to append a Integer value in a query.
You can use CAST(urIntegerValue as Varchar(10))
Error:
Msg 207, Level 16, State 1, Line 1
Invalid column name 'testuser'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'testuser'.
ASKER
Error i get :
Msg 207, Level 16, State 1, Line 1
Invalid column name 'testuser'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'testuser'.
For petesakes... can you post the entire query? I bet if you search your query you will find the character sequence t, e, s, t, u, s, e, r... maybe not on line 1... but somewhere in there. From Query Analyzer's EDIT menu select FIND, type t, e, s, t, u, s, e, r and click the FIND NEXT button. This will bring you to the first occurrence... warning there may be more than one occurance. Be prepared to click the FIND NEXT button again!
Btw... if you meant to use a variable named @TestUser this error means you forgot the @ character somewhere.
Btw... if you meant to use a variable named @TestUser this error means you forgot the @ character somewhere.
but there is no 'testuser' column in your sql.
is the sql you are trying to execute is
SET @SQL = 'UPDATE status_table SET status' + CONVERT(varchar(10),@statu
or something different?
check the tables used in the error sql and make sure you have 'testuser' column in that table. or post your complete code(i think you are fixing some sp or batch sql)
are you using two ids bender007 and karthikram ?
ASKER
DECLARE @statsCount int
SET @statsCount= (Select statusCount FROM status_table WHERE UserID = @user_id)
UPDATE status_table SET status' + CONVERT(varchar(10),@statu sCount) + '= @Old_status
This is what i was using initially.
testuser is a value in the table under UserID.
Yes I posted that message from a friends ID by mistake.
Thanks
SET @statsCount= (Select statusCount FROM status_table WHERE UserID = @user_id)
UPDATE status_table SET status' + CONVERT(varchar(10),@statu
This is what i was using initially.
testuser is a value in the table under UserID.
Yes I posted that message from a friends ID by mistake.
Thanks
What was the result of using the FIND function I suggested?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SET @SQL = 'UPDATE status_table SET status' + cast(@statusCount as varchar(10)) + ' = ''' + Replace(@Old_status,'''','