Click to See Complete Forum and Search --> : How to eliminate the first character in a field


Sheryll018
October 12th, 2005, 05:36 AM
hi everyone...can i ask how to eliminate the first character in a field in SQL?

for example i have GSUPERUSER in my field named usergroup and i wanted to eliminate the letter 'G' so that the result would be 'SUPERUSER' only.

Thanks very much.

Siddhartha
October 12th, 2005, 05:41 AM
Like this -const char* pszString = "GSUPERUSER";
pszString++; // SUPERUSER This should give you an idea.

If you post your string sample, we can work on it.

Sheryll018
October 12th, 2005, 05:51 AM
in sql pls...like in a query? i tried RIGHT but i have several record in that field and i just want to eleiminate the first letter which is 'G'.

The records under usergroup field are:
GSUPERUSER
GENG SVP
GBIG BOSS
GBUYER

Thanks....pls help.

Siddhartha
October 12th, 2005, 05:54 AM
I'll direct you to the right forum...

[ redirected ]

Regards,
Siddhartha

jayender.vs
October 12th, 2005, 06:07 AM
here is the solution ... in SQL (small function )

--select print_name,dbo.fngetProvName(schedule_fk,provider_id) from providers

--select * from schadministrator
--select schedule_FK,dbo.fnGetSchDayNo(Schedule_fk,Comment_date) as dayno,comment from schadministratordaycomments
--select datediff(day,'01 Oct 2004','31 Oct 2004')

CREATE FUNCTION fnGetProvLastName(@SchFk int,@ProvID int)
RETURNS char(15)
AS
Begin
Declare @ProvName char(15)
Declare @ProvName1 char(1)
Declare @ProvName2 char(1)
Declare @ProvName3 char(13)


select @ProvName = Last_name from providers
where schedule_fk = @SchFk and Provider_ID = @provID

select @ProvName1 = left(@ProvName,1)
select @ProvName2 = substring(@ProvName,2,1)
select @ProvName3 = substring(@ProvName,3,13)

if (ascii(@ProvName1) between 65 and 90) or (ascii(@ProvName1) between 97 and 122)
begin
select @ProvName1 = @ProvName1
end
else
begin
select @ProvName1 = ''
end

if (ascii(@ProvName2) between 65 and 90) or (ascii(@ProvName2) between 97 and 122)
begin
select @ProvName2 = @ProvName2
end
else
begin
select @ProvName2 = ''
end

select @ProvName = ltrim(@ProvName1+@ProvName2+@ProvName3)
Return (@ProvName)

End


if helped dont forget to "Rate this post"