A Query Where Title Includes 'Keyword'
Apr 30, 2008
i am having a problem querying a field in a database to show all records where the title has a keyword within the title.
Select * FROM tblCourse
WHERE title =@Search
But not the full title just a keyword within the field?
Thanks
View 1 Replies
ADVERTISEMENT
Jun 19, 2008
The following query is failing when trying to apply the
MAX(field_x_order)
to the variable @max
Note the x is represented by the string variable @stri
declare @i int
declare @stri varchar(10)
declare @max int
set @i = 18
set @max = 0
while @i < 49
begin
set @i = @i + 1
set @stri = cast(@i as varchar(10))
select @max = MAX(field_ + @stri + _ORDER) FROM table_name WHERE field_ + @stri + IS NOT NULL -- error: Incorrect syntax near the keyword 'IS'.
exec ('UPDATE display_1a SET field_' + @stri + '_order = field_' + @stri + '_order ' + @max + 'WHERE field_' + @stri + ' IS NULL')
end
I have also tried:
select MAX(field_ + @stri + _ORDER) INTO @max = FROM display_1a WHERE field_ + @stri + IS NOT NULL -- error: Incorrect syntax near '@max'.
and:
select @max = ('SELECT MAX(field_' + @stri + '_ORDER) FROM display_1a WHERE field_' + @stri + ' IS NOT NULL') -- error: Conversion failed when converting the varchar value 'SELECT MAX(field_19_ORDER) FROM display_1a WHERE field_19 IS NOT NULL' to data type int.
Thanks,
Lou
Lou
View 9 Replies
View Related
Jan 9, 2004
I have a sample photo database where we have added keywords to search for photos. I wanted a way to list all of the keywords that are in the database individually. The problem is in my keyword field there are many keywords seperated by a comma.
Ex: "bull, barrel, rodeo, western, cowboy" would in the keyword field for one photo.
I wanted to select distinct all of the individual words from each keyword field in all of the records.
Can this be done? What would the query look like?
I am looking for a list like:
bull
barrel
rodeo
western
cowboy
Any suggestions?
Thanks,
Rob
View 6 Replies
View Related
Jul 27, 2005
Hi all,I have two tables:workgroups (wg_id, wg_name)workgroups_keywords (wgk_wg_id, wgk_keyword)Each workgroup has an associated list of one or more keywords.What I want do to at first was given a particular list of keywordsbring back a list of workgroups that have at least one matching keywordassociated with it.I have the following query:select distinct(wg_id), wg_namefrom workgroups, workgroups_keywordswherewgk_keyword in (#QuotedValueList(Keywords.wgk_keyword)#)andwg_id = wgk_wg_idorder by wg_nameThis works great.However, is there a way in a single query to order the returned rows bythe number of keywords that are found to be matching (in other words anorder by relevancy, the more keywords that match the more relevant thereturned row)?Thanks in advance.David
View 2 Replies
View Related
Aug 12, 2007
hey guys
i have a query that takes too long that, actually i never got it to finish excuting
the query looks like tht
select referer,count(*) from t1 where referer is not null
and referer in( select distinct(Referer_Direct) from t2 where Referer_Direct is not null )group by referer
the inner select just returns 5 rows
so when i replace the inner select with actual values like tht
select referer,count(*) from t1 where referer is not null
and referer in('val1','val2','val3','val4','val5' )group by referer
it excutes immediatly
any clues how to solve this issue
the db is running on sql server 2005 express SP2
thx in advance
View 7 Replies
View Related
Mar 31, 2004
hi
I am having trouble with the following query within my store procedure.
as you can see, i am making an union of 2 separate queries.
in the 2nd part of the union, i encounter a column in the database where the column name is the same as the keyword "desc"
is there a way which i can get around this, or is there any other way that i can sepecify the column? (excluding the possibility of using *)
CREATE PROCEDURE topcat.getTransHistory
(
@contact_id numeric(9)
)
AS
BEGIN
DECLARE @phone_no varchar(255)
set @phone_no = (select top 1 phone_num from topcat.class_contact where _id = @contact_id)
select cast(trans_new.trans_date as varchar(50)) date,
'' code,
cast(payment.date_paid as varchar(50)) datepaid,
'' "desc",
case payment.payment_type
when 'cheque' then trans_new.item_total
else ''
end pledged,
'' mail,
case payment.payment_type
when 'cheque' then ''
else trans_new.item_total
end received,
'' receipt
from topcat.class_transaction trans_new left outer join topcat.class_payment payment on trans_new._id = payment.transaction_id
where trans_new.contact_id = @contact_id
union
select cast(trans_old.date as varchar(50)) "date",
trans_old.code,
cast(trans_old.datepaid as varchar(50)) "datepaid",
trans_old.desc,
cast(trans_old.pledged as varchar(128)),
trans_old.mail,
cast(trans_old.received as varchar(128)),
trans_old.receipt
from topcat.MMTRANS$ trans_old
where phone = @phone_no
END
GO
Cheers
James :)
View 4 Replies
View Related
Jul 23, 2005
If the data type of field is "varchar",we can use "like" to query if it hassome substring.Such as "where custom.valuevariant like '%Verizon%' ", it will query out allrecords that contains string "Verizon".But how to do when data type of field custom.valuevariant is "image"?Thanks
View 2 Replies
View Related
Jun 17, 2015
CREATE TABLE BILL_DETAIL
([objid] int,[x_billable_to] varchar(19), [x_bill_quantity] int,
[x_billable_yn] int, [x_bill_rate] int, [COST_TYPE] varchar(19) )
INSERT INTO BILL_DETAIL
([objid], [x_billable_to], [x_bill_quantity], [x_billable_yn], [x_bill_rate],[COST_TYPE])
[code]...
how to get records using stuff keyword as above i want to query using where condition with where objid=1 and should frame output as Parking, Toll only 1 input parameter need to given.
View 20 Replies
View Related
Oct 16, 2006
In Query Editor I type statements like this:
"select * from ...."
Does Query Editor support a "macro" facility where I could, via keystorke, uppercase all t-sql keywords? (so it would look like SELECT * FROM...)
TIA,
barkingdog
P.S. You think I'm lazy? I knew a programmer who was so lazy that his password was one character long!
View 7 Replies
View Related
Apr 18, 2006
Hi
I would like to perform a procedure
which takes a string of numbers and searches for strings in a table which include all the
given numbers in any particular order. problem is i can only return strings
which include 'any' of the letters in the search string and not
'all'.
this is how i perform it so far:
@IncludeNumbers
VARCHAR(50)
AS
BEGIN
SELECT Phone AS [Telephone
Number]
FROM tbl_Person AS p
WHERE (p.Phone LIKE '%[' +
@IncludeNumbers + ']%')
END
(ive removed some unecessary bits but
this shows the basics)
As you can see currently it will return any phone numbers which contain any numbers given in the includeNumbers string, I would only like it to return phone numbers which contain all the numbers given in the includeNumbers string. is there any way to make it search for strings
which include 'all' numbers given?
thanks
Robert
View 7 Replies
View Related
Mar 24, 2008
Does anyone know if SSRS2008 includes KPI's such that you can include them while working in Visual Studios? I've seen some "work arounds" posted but if 2008 includes them I'll just load that up and see.
Thanks.
View 1 Replies
View Related
Mar 14, 2008
Does the SQL Server 2005 Developer Edition include both of these:
Reporting Services?
Analysis Services?
( Also -- Anyone know where I can see a list of all the differences between Dev Edition and other SQL Server editions?)
View 1 Replies
View Related
May 20, 2014
I'm using SQL Server 2012 Enterprise Edition, and i Enable CDC to started the service.
I've set up CDC on multiple tables, and I see them (under system table)
While the database backup (export file 'BAK'), and imports I do not see the tables of the CDC.
1. Condition restore / backup is full.
2. Carried out an attempt to copy the MDF & LDF files (replace them), to no avail.
How to back up data of these tables.
View 4 Replies
View Related
Jan 18, 2007
hello all,
i am trying to create a view but i keep getting the error 'View definition includes no output columns or no items in the FROM clause.'
below is the select statement that's the basis of my view. the explanation i got from the F1 help of enterprise manager was ...
View definition includes no output columns or no items in the FROM clause.
A view definition must have at least one table or table-structured object in the FROM clause, and must have at least one column in the select list. The view definition is missing one or both. Modify the view definition accordingly.
query:
select
Case_CaseId,
Logged,
CAST(DATEDIFF(minute, Logged, Waiting)/60.0 AS NUMERIC(9, 2)) AS Waiting,
CAST(DATEDIFF(minute, Logged, Investigating) /60.0 AS NUMERIC(9, 2)) AS Investigating,
CAST(DATEDIFF(minute, Logged, Rejected) /60.0 AS NUMERIC(9, 2)) AS Rejected,
CAST(DATEDIFF(minute, Logged, Resolved) /60.0 AS NUMERIC(9, 2)) AS Resolved,
CAST(DATEDIFF(minute, Logged, Solved) /60.0 AS NUMERIC(9, 2)) AS Solved,
CAST(DATEDIFF(minute, Logged, Closed) /60.0 AS NUMERIC(9, 2)) AS Closed
from
(
SELECT
Case_CaseId,
MIN(CASE WHEN case_stage = 'Logged' THEN Case_CreatedDate END) AS Logged,
MIN(CASE WHEN case_stage = 'Waiting' THEN Case_CreatedDate END) AS Waiting,
MIN(CASE WHEN case_stage = 'Investigating' THEN Case_CreatedDate END) AS Investigating,
AS Rejected, MIN(CASE WHEN case_stage = 'Resolved' THEN Case_CreatedDate END) AS Resolved,
MIN(CASE WHEN case_stage = 'Solved' THEN Case_CreatedDate END) AS Solved,
MIN(CASE WHEN case_stage = 'Closed' THEN Case_CreatedDate END) AS Closed
FROM
CaseProgress
GROUP BY Case_CaseId
) as temp
order by Case_CaseId
View 2 Replies
View Related
Nov 6, 2007
Hello!
I am wondering if some of you T-SQL pros encountered a situation when you have a parameter that can consist of multiple strings. For instance, I have a stored procedure called dbo.usp_CalculateHeadcount that accepts two parameters such as @Term, and @AcadLevel.
It works great when my parameters are two single strings; 'Fall2007', 'UG'. But let say I have one more term such as 'Fall2006' and want to pass it to a stored procedure, the problems start to appear.
So when you execute a stored procedure:
Exec dbo.usp_CalculateHeadcount 'Fall2006','Fall2007','UG'
It doesn't work because I have added an extra string and stored procedure thinks it is another parameter. Is there a way to handle problems like the one above?
Thanks for your feedback.
View 6 Replies
View Related
Jul 20, 2005
Hi, not too swift with anything other than simple SQL statements, soI'm looking for some help.Using SQL Server 2000 with this stored proc:(@varCust varchar(50))ASSET NOCOUNT ONSELECT d.WorkOrder, d.Customer, d.SerialNo, d.Assy, d.Station,d.WIdoc,d.Start, d.StartUser, d.Finish, d.FinishUserFROM tblWorkOrder w, tblDocs dWHERE w.WorkOrder IS NULL AND w.WorkOrder = d.WorkOrder ANDd.Customer = @varCustGOI'm trying to get a complete dataset so I can simply apply it as thedatasource to a datagrid in asp.net. I need to include a 'TimeSpan'column that is the difference between d.Start and d.Finish. I alsoneed it to present in hh:mm:ss format in the datagrid column. (A) isit possible to do this within the stored proc, and (B) how would "I"do that?Thanks!Kathy
View 6 Replies
View Related
Jul 13, 2006
Can I specify a collate value for a column in a table that includes all the possible languages in the world or atleast Latin 1 and Eastern European languages.
My DB Collation is set to Latin 1 and the columns in the tables are all nvarchar or ntext, but certain hungarian characters are not displayed correctly.
What do all these collation codes represent:
SQL_EBCDIC037_CP1_CS_AS
211
SQL_EBCDIC273_CP1_CS_AS
212
SQL_EBCDIC277_CP1_CS_AS
213
SQL_EBCDIC278_CP1_CS_AS
214
SQL_EBCDIC280_CP1_CS_AS
215
SQL_EBCDIC284_CP1_CS_AS
216
SQL_EBCDIC285_CP1_CS_AS
217
SQL_EBCDIC297_CP1_CS_AS
They seem generic. Is there one collation that includes all the Eastern Europen Languages and Latin 1 charset. Please let me know.
Thanks,
Manisha
View 6 Replies
View Related
Dec 10, 2012
I am trying to write a report that includes different lab values for an account number depending on the test. What I mean is if patient xyz had lab work and procedure number 1012 was ordered I need to include one line for the highest result value and one for the lowest result value. If I have procedure number 1032 I only need a line for the lowest value. I have a list of about 40 lab procedures that some require both highest and lowest, some just the lowest and some the highest. I have played around with CASE, but that hasn't worked for me.
Here is an example of what I'm getting:
Acct Number MR # AdDateDDateCode CDateCTime Result Test
E00000000000 MR00000000 0824110902111012 0830110515 4.5 WBC
E00000000000 MR00000000 0824110902111012 0831110515 4.7 WBC
E00000000000 MR00000000 0824110902111012 0827110525 5.1 WBC
E00000000000 MR00000000 0824110902111012 0826110455 5.3 WBC
E00000000000 MR00000000 0824110902111012 0828110525 5.7 WBC
E00000000000 MR00000000 0824110902111012 0829110500 5.7 WBC
E00000000000 MR00000000 0824110902111012 0901110500 6.6 WBC
E00000000000 MR00000000 0824110902111012 0825110609 6.8 WBC
E00000000000 MR00000000 0824110902111012 0824112050 9.3 WBC
E00000000000 MR00000000 0824110902111032 0830110515 10.1 HB
E00000000000 MR00000000 0824110902111032 0831110515 10.2 HB
E00000000000 MR00000000 0824110902111032 0826110957 10.2 HB
E00000000000 MR00000000 0824110902111032 0827110525 10.4 HB
E00000000000 MR00000000 0824110902111032 0826110455 10.5 HB
E00000000000 MR00000000 0824110902111032 0901110500 10.7 HB
Her is what I need:
Acct Number MR # AdDateDDateCode CDateCTimeResult Test
E00000000000 MR00000000 0824110902111012 0830110515 4.5 WBC
E00000000000 MR00000000 0824110902111012 0824112050 9.3 WBC
E00000000000 MR00000000 0824110902111032 0830110515 10.1 HB
View 7 Replies
View Related
Mar 28, 2014
In our Microsoft Dynamics Nav instance we have a Sales Header Archive table - into which copies of the Sales Header are placed, with 3 items forming the compound key:
Document Number
Version
Occurrence number
so if doc 1 is archived, then the records would be
Doc# | Version | Occurrence #
1 | 1 | 1
When a second copy is archived a new record is added:
Doc# | Version | Occurrence #
1 | 1 | 1
1 | 1 | 2
and then when maybe a 3rd version is archived a 3rd entry added
Doc# | Version | Occurrence #
1 | 1 | 1
1 | 1 | 2
1 | 2 | 2
This is for EACH document and I now need to retrieve the dataset which is the latest version of each document... but I'm drawing a blank!
If I
select [Doc#], max([Version]) as [V], max([Occurrence #]) from (table) group by [Doc#]
then I get the distinct list of docs, but I now need to use this list to select the records which match this criteria, from this table.
How do I select just these?
I thought (wrongly) that I could simply say:
Select * from Invoice Table where
Invoice.[Doc#], Invoice.[V], Invoice.[Occurrence #] in
(select [Doc#], max([Version]) as [V], max([Occurrence #]) from (table) group by [Doc#])
View 2 Replies
View Related
Sep 22, 2015
SO I have a need to to limit the members of a dimension that get included with a query to just a few. So that means specifying which ones. How do I limit the main set based on a defined list of members in one of the dimensions im using.
In the query below, I need to limit the number of dimension members being included for CommType and MetricType. I get errors if I use a list of specific members in a where clause that includes these same dimensions.
WITH
MEMBER [Measures].[YTD Actual]
AS
SUM({[DimCalendar].[Month Year].&[2015]&[1] : STRTOMEMBER('[DimCalendar].[Month Year].&[' + CSTR(YEAR(NOW())) + ']&[5]') }
, [Measures].[Actual]
[Code] ....
View 4 Replies
View Related
Apr 29, 2007
hey guys, so i have my website, everything is ok, until i have to put in a title field, along side my description. so far i have this code which searches in the description, how can i make it so i can search in the title as well
SelectCommand="SELECT [Stock_ID], [cat_id], [description], [size],
[selling_price], [qty], [picture1] FROM [tbl_stock]
WHERE ([description] LIKE '%' + @description + '%')">
Any help would be great
Cheers
Jez
View 2 Replies
View Related
Jul 3, 2006
I'm building a stored procedure to edit a row in my database but first I'm wanting to check for null values in the parameters and set them to their respective value in the row I'm attempting to edit.
Here's my code:
Code:
CREATE PROCEDURE dbo.spModifyProject
(
@ProjectID int,
@Title nvarchar(50),
@Description nvarchar(50),
@DueDate smalldatetime,
@ProjectLead nvarchar(50),
@Completed bit
)
AS
IF @Title IS Null Then
SET @Title = (SELECT Title FROM Projects WHERE [ID] = @ProjectID)
END IF
I get syntax errors in two places. The first is near Null and the second is near END. Any help you can give is appreciated.
View 2 Replies
View Related
Feb 13, 2005
I have a table that is a very general layout so I can expand upon values later in the future easily. Basically it looks like this:
Code:
ID PlayerID Ability Score
1 1 STR 18
2 1 DEX 17
3 1 CON 16
What I'm trying to do is create a stored procedure where I pass in a PlayerID and it will return a result set of
Code:
STR DEX CON
18 17 16
It doesn't appear that there's a way in SQL Server 2000 to SELECT a column AS a variable. I suppose I could go about creating a temporary table, but seems like an odd work around to get it to work. Any suggestions? Or am I just missing something obvious?
View 3 Replies
View Related
Nov 16, 2006
Hello,
I am asking this question here, because it appears that I don't get as fast a response in reporting services as I do on this forum.
I am trying to add an extra parameter in a report title called SummaryBy.Value
Here is my current code:
="BY " & UCase(Parameters!SummaryBy.Value & IIF(Parameters!SummaryBy2.Value<>"", " / " & Parameters!SummaryBy3.Value,""))
If I add the extra parameter I get an error because of the IIf. How do I get around this to display all three parameters?
Please let me leave this post here also. I need to get an answer asap.
TIA and have a great day!
Kurt
View 6 Replies
View Related
Jul 3, 2006
I'm building a stored procedure to edit a row in
my database but first I'm wanting to check for null values in the
parameters and set them to their respective value in the row I'm
attempting to edit.
Here's my code:
Code: CREATE PROCEDURE dbo.spModifyProject
(
@ProjectID int,
@Title nvarchar(50),
@Description nvarchar(50),
@DueDate smalldatetime,
@ProjectLead nvarchar(50),
@Completed bit
)
AS
IF @Title IS Null Then
SET @Title = (SELECT Title FROM Projects WHERE [ID] = @ProjectID)
END IF
I get syntax errors in two places. The first is near Null and the second is near END. Any help you can give is appreciated.
View 3 Replies
View Related
Jan 10, 2007
I'm new to these forums. If this is not the right place to post this question, please let me know where I should ask. :)
Anyway, I have a report that is grouped something like this:
Team
Location
Score
TEAM 1
#Loc#
#Total#
Home
10
Away
14
Away
8
NULL
0
NULL
0
Home
14
TEAM 2
#Loc#
#Total#
Home
10
Away
14
Home
19
NULL
0
Home
14
TEAM 3
#Loc#
#Total#
Away
7
Away
12
For each team grouping, the header columns needs to perform an action on the grouped records to determine the text.
The #Total# header is easy -- here I want a total of the points ( =Sum(Fields!Points.Value) ). No problem.
The #Loc# header is the problem. What I want to do is to count the number of "Home" values in the group (so Team 1 location reads "Home (2 of 6)", and Team 2 location reads "Home (3 of 5)"). If there are no "Home" values, I want to use the "Away" value (so Team 3 location reads "Away (2 of 2)").
Can someone tell me how I can create a custom code function that will allow me to iterate through the values of the grouped records from the group header textbox? I assume I need to be able to create a custom aggregate function of some kind, but I don't quite know where to begin.
Thanks for your help.
Joe
View 1 Replies
View Related
Sep 9, 2015
I need to create a report showing the title the first and last name of all sales representatives-This is what I have so far but am having difficulty retrieving ONLY the "Sales Representatives" Titles.
Select Firstname, Lastname, Title
From Employees
Where ???
View 6 Replies
View Related
Sep 21, 2007
Hi All,
I have created a report in SQL Server Business Intelligence Development Studio 2005. I need to add a report title above the parameters area. Is that possible?. please help me
The output should be like
_____________________________________________________________________
Report Title
_____________________________________________________________________
Report Parameters Section View Report button
_____________________________________________________________________
Report Body part.
_____________________________________________________________________
View 1 Replies
View Related
Mar 3, 2008
How do I change the report title via an expression? I have a parameter that can contain 1 of 3 values and want to change my Report Title accordingly. Can I nest the IIF statements somehow or how can I accomplish this?
View 4 Replies
View Related
Apr 23, 2007
Good day,
Is there anyway that I can have a multi-line chart title? I have even tried placing a text box over the title part of the chart that is multi-line, although this appears to work once the report is deplyed and viewed in a web browser the text box appears below the chart and the chart then has no title.
Please can you help?
View 2 Replies
View Related
May 8, 2007
Is there any way to give Title to matrix row and column groups?
I know If i have only one row i can give title in the textbox provided at the top of the Rows group area. But i have more than one row and group and more than one column group. i want to give title to all of them.
Without the title the report looks incomplete
Is there any solution for this problem?
Thanks
Rohit
View 1 Replies
View Related
Sep 21, 2007
Hi All,
I have created a report in SQL Server Business Intelligence Development Studio 2005. I need to add a report title above the parameters area. Is that possible?. please help me
The output should be like
______________________________________________________________________
Report Title
______________________________________________________________________
Report Parameters Section View Report button
_____________________________________________________________________
Report Body part.
_____________________________________________________________________
View 1 Replies
View Related
May 20, 2008
Is it possible to change the title of a chart at run-time?
View 3 Replies
View Related