Why you want to store Int Data Type to Varchar(Max), You can store Int Values uplto max 10 characters so i would like to suggest you to store into varchar(10) not in varchar(max). You can use following queries.
Declare @MyVar Int
Select @MyVar = 20000
Select Cast(@MyVar as Varchar(max) --I would not suggest but as per your question.
Select Cast(@MyVar as Varchar(10)) -- Length Should be enough to store int values.
See following suggestion from Mircrosoft.
- Use char when the sizes of the column data entries are consistent.
- Use varchar when the sizes of the column data entries vary considerably.
- Use varchar(max) when the sizes of the column data entries vary considerably, and the size might exceed 8,000 bytes.
Also visit http://msdn.microsoft.com/en-us/library/ms176089.aspx for more informations.
Failure in Life is failure to try...