Substring From The Left?!?
May 21, 2008
Hi,
we are using Moss 2007 and in one of our lists we add a hyperlink.
when we display this field into a report it is showed as: hyperlinkurl, name
for example: http://www.site.com,testsite
What we want to is that the piece after the , is displayed as a value and the string before the , is used as hyperlink.
Now we have tested a few things like:
=Trim(Right(Fields!Variant_Locatie.Value, Len(Fields!Variant_Locatie.Value) - InStr(Fields!Variant_Locatie.Value, ", ")))
and this give's us the string part AFTER the , so that part is correct!
but I can't find out how to do the same thing but then for using everything BEFORE the ,
...
anyone got an idea? just changing Right with Left give's us (for example): http://thisisa
instead of http://thisisatest.com (he's counting the number of characters from the right to the , and then displays the characters starting from the left but only the number of characters he counted previously) ...
urgent plz!
View 3 Replies
ADVERTISEMENT
Jun 9, 2007
Having a whale of a time, having tried almost every approach, except obviously the right one.
I have employee_no which is character size 10. It is right-justified for some reason. I'm using SUBSTRING to peel off the last five digits (it's going to a flat file where only 5 chars are allowed).
Now I just need to Left Justify the return string. What should I add
to this statement
substring(employees.employee_no,6,8)
My return is this:
A97 1Joe
A97 3Bruce
A97 4Scott
Many thanks in advance, you guys are amazing.
lisa
View 5 Replies
View Related
Oct 18, 2007
Hi,
I've tried the following query in SQL SERVER 2005, SQL Express and MACCESS.
select * from Table1 where drid in (SELECT DrID FROM Table2 WHERE (substring(PostalCode,1,3) IN ('B0E','B1P','B2H','B2Y','B3A','B3M','B4A','B4H','E1A','E1C','E1N','G0A', …)) and (substring(Telephone,1,3) IN ('204','250','306','403','416','418','450','506','514','519','604','613','705','780','807','819','902','905')))
The query is using two table. The first one Table1 is a table with user info. The second table Table2 has the info concerning a survey.
The Table1 containt approx. 6000 row and Table2 containt only 210 rows
The table structure from the different environment(MACCESS, SQL SERVER 2005, Sql Server Express 2005) are the same. The Table1 containt the field "PostalCode" and "Telephone".
When I execute this query on MACCESS and in SQL Server 2005 the result are approximately the same(Less than half second). But there a performance issue in Sql Express 2005. The query take an execution time between 7 and 9 secondes.
When I add a condition using a field from tblResponsePQ2Part1 ex: QA=1
like in the following query :
select * from Table1 where drid in (SELECT DrID FROM Table2
WHERE (QA = 1 substring(PostalCode,1,3) IN ('B0E','B1P','B2H','B2Y','B3A','B3M','B4A','B4H','E1A','E1C','E1N','G0A', …)) and (substring(Telephone,1,3) IN ('204','250','306','403','416','418','450','506','514','519','604','613','705','780','807','819','902','905')))
the query take an execution time of ~15 secondes!!!!
This issue only happen in Sql Server Express, on the others cases(mean MSAccess, Sql Server) the execution time is less than half second.
It’s weird because, Sql Express 2005 is supposed to be more performant
than MACCESS, and have the same performance than Sql Server Professional Edition. Please Help Me!!!!
Anyone have an idea why?
Mathieu Desbiens
View 1 Replies
View Related
Oct 10, 2007
I have an application providing me with multiple headers which I havemergerd into one big header (below), this header my not always be thesame but I need to be able to extract a periodstart and periodend fromit. The periodstart will always be the third substring from the end(or 3rd from right) and the periodend will always be the firstsubstring from the end (or 1st from the right).How can I extract the periodstart and periodend?E.g:- Header'Jensen Alpha TR UKN GBP BM: Caut Mgd BM (50% FTAllSh 50% ML £ BroadMkt) RF DEF:RFI 3Y 31/08/2004 To 31/08/2007'I currently have the sql: convert(Datetime,(dbo.FDHGetWord(@FullHeader, 20)) ,103) but this only works in thisinstance, I need to use someting like the RIGHT function or REVERSEfunction but I can't get the sql right.Can someone please help!????
View 1 Replies
View Related
Dec 1, 2015
is it possible to identify which value is causing me the above error message and how to resolve it,These are for British postcodes.
create table #tmp (postcode varchar(200) NULL)
insert into #tmp values ('NULL')
insert into #tmp values ('-')
insert into #tmp values ('.')
insert into #tmp values ('0L6 7TP')
insert into #tmp values ('AB10 1WP')
insert into #tmp values ('AB51 5HH')
[code]...
This is the main query
select postcode,LEFT([Postcode], CHARINDEX(' ',[Postcode]) - 1)
from #tmp
order by Postcode
drop table #tmp
View 4 Replies
View Related
Oct 28, 2015
I have a table PLACE with a character column CODE
[Code] [nchar](4) NULL
I need to left pad the column with 0 if it is less than 4 characters long and extract the first 2 characters on the left into a new column COUNTY_CODE.
How can I do that in transact SQL?
I tried:
   Â
SELECT Â RIGHT(RTRIM('0000'+ISNULL([Code],'')),4) Â Â Â
  FROM [Place]
  WHERE [Place Code]='B' and [Code]='627'
And I got 0627. And how do I extract the first 2 characters?
View 10 Replies
View Related
Oct 24, 2013
How to remove space left to right and right to left
If I give limit >60 for first 60 character; limit 60< second 60 character
Result would be check if space at 60 character if yes remove and go the 59 character check then space remove and 58 character check if there is charater then display
As well as after 60 character to till 120 for right space
View 5 Replies
View Related
Apr 16, 2008
Anyone know why using
SELECT *
FROM a LEFT OUTER JOIN b
ON a.id = b.id
instead of
SELECT *
FROM a LEFT JOIN b
ON a.id = b.id
generates a different execution plan?
My query is more complex, but when I change "LEFT OUTER JOIN" to "LEFT JOIN" I get a different execution plan, which is absolutely baffling me! Especially considering everything I know and was able to research essentially said the "OUTER" is implied in "LEFT JOIN".
Any enlightenment is very appreciated.
Thanks
View 5 Replies
View Related
Jan 25, 2015
-- Why is the left table in a LEFT JOIN limited by the where clause on the right table?eg
DECLARE @LeftTable TABLE (LeftID INT NOT NULL IDENTITY(1, 1), LeftValue INT NULL)
INSERT @LeftTable (LeftValue)
VALUES (111)
INSERT @LeftTable (LeftValue)
VALUES (222)
[code]....
View 2 Replies
View Related
Dec 20, 2006
hello
for MS SQL 2000, i cannot get it
i am having names like AB_12 I want to get all rows with left part similar , AB im that case
SELECT id, name
FROM Users
WHERE LEFT(name, CHARINDEX('_', name) - 1) AS name IN
(
SELECT LEFT(name, CHARINDEX('_', name) - 1) AS ns
FROM Users
GROUP BY LEFT(name, CHARINDEX('_', name) - 1)
HAVING (COUNT(*) > 1)
)
does not work
is there any way to use a variable ?
declare @nm nvarchar
set @nm = SELECT LEFT(name, CHARINDEX('_', name) - 1) AS ns
FROM Users
thank you for helping
View 4 Replies
View Related
Sep 1, 2005
Hi All,
Im having a problem with a statement i cannot seem to get 2 left joins working at the same time 1 works fine but when i try the second join i get this error:-
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'children_tutorial.school_id=schools.idx LEFT JOIN regions ON children_tutorial.region_id=region.idx'.
My SQL statment is as follows :-
SELECT children_tutorial.*,schools.schoolname,regions.rname FROM children_tutorial LEFT JOIN schools ON children_tutorial.school_id=schools.idx LEFT JOIN regions ON children_tutorial.region_id=region.idx
I am using an Access database i have tried all sorts to get it working and its driving me mad!! any help would be really appreciated.
View 2 Replies
View Related
Apr 7, 2008
Is there any difference between left join and left outer join in sql server 2000?please reply with example if any?
Thanks in advance
View 13 Replies
View Related
May 14, 2008
Hi,
Whats the diference between a left join and a left outer Join
View 5 Replies
View Related
Jul 5, 2001
Hi all,
I have just started using SQL7 and quite dumb at it.
Here is my problem
i have tables ip_address and ip_subnets. both contains more than 20,000 records. Though ideally each subnet should correspond to only one ip address it is not so due to SMS inventory and remote clients configurations etc.
As an example If my ip address is 141.151.128.78 I need to select only 141.151.128.64 ( or atleast 141.151.128.*)as the valid subnet. In other words I need to compare upto 3rd octet and only if it matches with ip address then declare that as the valid subnet.
Pls note that ip addresses vary for each machine though there will 4 octets, I can't use character positions as the nos in each octet might vary from 1-255.
Any help would be greatly appreciated
Pasted here under is the query script I am playing around with charcter poistions which are not working in my favor. Just added to explain my problems in more clearer way
select distinct system_data.name0, System_IP_Address_ARR.ip_addresses0, System_IP_subnets_Arr.ip_subnets0, system_disc.client0 from system_Data, System_IP_Address_ARR, system_ip_subnets_arr, system_disc where system_data.machineid = System_IP_Address_ARR.itemkey and system_data.machineid = system_ip_subnets_arr.itemkey and system_data.machineid = system_disc.itemkey and system_disc.client0 = 1 and substring(System_IP_Address_ARR.ip_addresses0,1,10 ) = substring(System_IP_subnets_ARR.ip_subnets0,1,10) and substring(System_IP_Address_ARR.ip_addresses0,10,1 ) = '.' and System_IP_subnets_ARR.ip_subnets0 not in ('11%.%.%.%','12%.%.%.%', '10%.%.%.%' , '10.%.%.%' , '1.%.%.%') order by System_DATA.name0
Arun
View 2 Replies
View Related
Nov 5, 2001
Hey you sql programming guru's
I need help seperating a name from first name and last name
The field is like this,
last name, first name
example Doe, John
I need to seperate the last name from the , to the first character
and the last name from the , to the last character.
I think I have to use a substring but not sure how tell it to stop and
start when it gets to the comma.
Can someone please help me.
Thanks,
Dianne
View 1 Replies
View Related
Aug 8, 2001
Need to do something like SUBSSTRING in Access, any ideas?
View 1 Replies
View Related
Oct 4, 2004
Hi
Can anyone show me how to do the following:
I have this snippet of data
ids
-----------------------------------
1582270|1582277
1582270|1582277|1582286
1582270
I want to return the id (the id may not always have the same number of numbers) after the last pipe (|) delimter.
So i want a rs like this :
ids
-----------------------------------
1582277
1582286
1582270
Thanks in advance
View 9 Replies
View Related
Feb 4, 2005
Hi,
please help me in developing query to satisfy this...
i have table called test and the table data looks like this.
col1
123.abc
1.ab
12.cba
the query needs to return all rows data after . the result set should return this
abc
ab
cba
appreciate your help..
thanks
sskris
View 1 Replies
View Related
Feb 3, 2004
I have a field that contaings 15 characters. I want to just pull the first 6. So anything that matches these 6 will be returned.
View 10 Replies
View Related
Apr 8, 2004
We have entries like below in a table. I need a query by which I can get the CustomerName from the below entries.
ACustomerName
ACustomerNameCredit
ACustomerNameDebit
Thanks!
View 14 Replies
View Related
Jun 2, 2004
I an trying gto devide this one field that contains city state and zip into 3 seperate columns. The Column right now looks like this:
Coulumn1
-------------------------------
SOUTH EL MONTE CA91733617
BOSSIER LA71172
GARDENA CA90249107
MILWAUKEE WI53216
PARIS IL61944
DUQUOIN IL62832
REDWOOD FALLS MN56283
AUBURN ME04210
I tryed this:
use cimpro1
select substring(cust_shipto_addr_l3, 1, 19) as 'City',
substring(cust_shipto_addr_l3, 20, 21) as 'State',
substring (cust_shipto_addr_l3, 22, 31) as 'Zip'
from opcshto
For some reason, when I run the query I get this for State:
State
-------------------------
CA91733617
LA71172
CA90249107
WI53216
IL61944
IL62832
MN56283
ME04210
When I use the substring to only pull characters 20 and 21 it pulls everything startign at 20. I just want it to select character position 20 ans 21 for the state. As far as the substring for City and Zip, everything comes out fine. Its just State that I am having trouble with.
Any help is appreciated.
View 7 Replies
View Related
Sep 13, 2006
iam trying to write a string function which will give me the id part of a mail id
but iam geting the string along with @ and when iam trying to remove the last char (@) iam getting error
query:
select substring(leadassignedtombemail,1,(CHARINDEX('@', leadassignedtombemail)))
from lead_details -----> Gives me id along with @
select substring(leadassignedtombemail,1,(CHARINDEX('@', leadassignedtombemail) - 1))
from lead_details ------------>gives me error "Invalid length parameter passed to the substring function."
But
select (CHARINDEX('@', leadassignedtombemail) - 1) from lead_details
works and gives me the length of id without counting @
where did i go wrong
View 2 Replies
View Related
Dec 1, 2006
i am trying to get the last name of the customer, but my db has the names stored as (first,middle, last) order in a single field. i am using the statment:
,RIGHT(ActCustName,LEN(ActCustName) - CHARINDEX(' ',ActCustName) ) AS LAST
but it only works if the customer does not have a middle name, otherwise it returs the middle+last as the last name. what should i do/ any ideas??? here is my code
select ActPrjMgr
,ActEmpId
,ActEmpName
,ActCustName
,RIGHT(ActCustName,LEN(ActCustName) - CHARINDEX(' ',ActCustName) ) AS LAST
,ActPrjCode
,left(ActPrjType,2) as Status
,ActEmpTaskCode
,left(ActBillingPeriod,11)as ppedate
,left(ActivityDate,11) as actdate
,ActTimevalue
from dbo.ACTIVITIES
where ActBudCat = 'labor'
and ActBillingPeriod = '11/17/2006'
and actprjcode <> ' '
and actprjcode is not null
--and ActBillingPeriod = @StartDate
order by ActPrjMgr
,ActEmpID
,ActEmpTaskCode
,ActivityDate
View 7 Replies
View Related
Mar 19, 2007
Hi All
Iam new to sql, Iam using sql 2000 and have a field datatype varchar.
An example of the string: -
CN=Leighton Morgan/OU=WR/O=Extranet
I need to write a query that will allow me to extract the following:-
Name: Leighton Morgan
Company: WR
and lastly the word Extranet
Please can you help
Many Thanks
View 9 Replies
View Related
Mar 19, 2007
Hi All
Iam new to sql, Iam using sql 2000 and have a field datatype varchar.
An example of the string: -
CN=Leighton Morgan/OU=WR/O=Extranet
I need to write a query that will allow me to extract the following:-
Name: Leighton Morgan
Company: WR
and lastly the word Extranet
Please can you help
Many Thanks
View 1 Replies
View Related
Mar 19, 2007
Hi All
Iam new to sql, Iam using sql 2000 and have a field datatype varchar.
An example of the string: -
CN=Leighton Morgan/OU=WR/O=Extranet
I need to write a query that will allow me to extract the following:-
Name: Leighton Morgan
Company: WR
and lastly the word Extranet
Please can you help
Many Thanks
View 1 Replies
View Related
Jan 25, 2006
i have a column that has "Full name" of an individual.
I want to create a new column with just the first name.
How do i populate this column with just the first name...ie it just takes the string until the space from the "full name" column.
View 5 Replies
View Related
Oct 22, 2007
can anyone help me with the following report.
Create procedure Rpt_StaffDevelopmentReport
(@cmb1 as varchar(100),
@cmb2 as varchar(100) with encryption as
Begin
--@cmb1 is the site name (s.sitename), @cmb2 is the staffname in the form €˜surname,forename€™
--@cmb2 will need to be split based on the €˜,€™ within the string
--tables needed are staffDevelopment , staffMember and Site
end
Three Tables.
Site
Columns
Siteid, sitename, address1, address2
Staffmember
Staffed, surname, forename,sex, address1, address2, siteid
Staffdevelopment
Staffed, development, personal
View 7 Replies
View Related
Feb 1, 2007
Hi
In my status table I m having field like
Actionby (COLUMN NAME)
-------------------
TravelDept
TravelDept
Approver
FinanceDept
TravelDept(xyz@yahoo.com)
I m having mail id along with TravelDept in some rows.
I want to retreive rows containing TravelDept.When i am retreving i wnat to retreive value 'TravelDept' which is having mail id also.
i have written one query,but its retreving only the value which is having mail id.
i want to retreive TravelDept value with mail id and Only TravelDept values also.
my query is:
select replace(SUBSTRING(S.Actionby,CHARINDEX('',S.Actionby,1) , CHARINDEX('(',S.Actionby,1)+0 ),')', '') from status S;
But this query retreiving only 1 row only insteadof 3 rows.
Total 3 rows having TravelDept value.I want to retreive all these 3 rows.
please help me.
Thanks.
View 2 Replies
View Related
Aug 31, 2007
I have a SQL column that contains something like this:
ORLANDO ,FL. 32803
COCOA , FL. 32922-8617
SATELLITE BCH,FL 32937-3523
TAMPA , FL. 33609-3105
EAU GALLIE ,FL. 32935
I need only the name of the city, dont need FL or the zip code, how can I do a substring statement on sql to get only that?
Thanks,
Erick
View 8 Replies
View Related
Oct 26, 2007
I'm using the GridView to display some accounting infromation. I have a project where I have a 14 character control number. I would like to have a dropdown list to select the account classification of records to be displayed. The accounting classification is the first two characters of the control number. So the dropdown list needs to show unique first two characters and the GridView will be filtered on these two characters. I have been trying to use "substring" in the ASP.NET code; not even sure you can.
Any suggestions on how to accomplish this would be greatly appreciated. See code below:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2"
DataTextField="control_num" DataValueField="control_num">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:GPCRReportsConnectionString %>"
SelectCommand="SELECT DISTINCT [substring(control_num,1,2)] FROM [Request]"></asp:SqlDataSource>
ERROR: Invalid column name 'substring(control_num,1,2)'.
View 6 Replies
View Related
Dec 11, 2007
I tried to mimic some code I found but on RequestDateTimeSUBSTRING(RequestDateTime,(charindex(':',RequestDateTime)+1),len(RequestDateTime)) AS 'Date Downloaded'I can only use SUBSTRING on char type strings.How would I get maybe only up to the first : character in the RequestDateTime?
View 2 Replies
View Related
May 6, 2008
hi frenz:
Can any one send me the code for
substring multiple cell values of same column and put it into one cell of that column.
View 3 Replies
View Related