Click here to Skip to main content
15,899,632 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in database i have integer value how to convert value in char using substring..........


USE [Test_Inventory]
GO
/****** Object: StoredProcedure [dbo].[SPSelectDCNMForMaxRecord] Script Date: 07/02/2013 14:09:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SPSelectDCNMForMaxRecord]
@DC_NO char(10)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here

select MAX(convert (int,right(DC_NO,10))) from DCNM

it,s my store procedure..i want to convertint value to char using subastrin function in asp.net c#
Posted
Updated 2-Jul-13 0:53am
v2
Comments
Thanks7872 2-Jul-13 6:50am    
Example:

int a=3;
string value=Convert.ToString(a);

Now,value will have'3' as string not as integer.Any doubts?

C#
int i = 10002;
string a = i.ToString().Substring(0,2); // result : 10
 
Share this answer
 
in database i have integer value how to convert value in char using substring..........


First convert integer to char or string as follows:

int dbvalue=2000;
String str= dbvalue.ToString();


Then you can split your string using substring as follows:

Syntax for substring is : SubString( Start_index int, length_of_string int);

str= str.SubString(0,3);


you will get result : str=200

Happy coding...
 
Share this answer
 
v2
See the link for all substring actions
http://www.dotnetperls.com/substring[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900