Click here to Skip to main content
15,890,741 members
Home / Discussions / Database
   

Database

 
QuestionJan-December chart with specific information Pin
Dave McCool24-Jun-10 22:44
Dave McCool24-Jun-10 22:44 
AnswerRe: Jan-December chart with specific information Pin
riced25-Jun-10 1:21
riced25-Jun-10 1:21 
GeneralRe: Jan-December chart with specific information Pin
Dave McCool25-Jun-10 1:39
Dave McCool25-Jun-10 1:39 
Questionsql function to calculate work hours of an employee Pin
Thanusree Duth24-Jun-10 21:03
Thanusree Duth24-Jun-10 21:03 
AnswerRe: sql function to calculate work hours of an employee Pin
thatraja24-Jun-10 23:56
professionalthatraja24-Jun-10 23:56 
QuestionQuery to get all row values as comma separated Pin
indian14324-Jun-10 9:14
indian14324-Jun-10 9:14 
AnswerRe: Query to get all row values as comma separated Pin
Mycroft Holmes24-Jun-10 11:55
professionalMycroft Holmes24-Jun-10 11:55 
QuestionHow to avoid specification of return parameters in an inline table function Pin
jophinmichael24-Jun-10 3:05
jophinmichael24-Jun-10 3:05 
Hi guys,
I am having an inlined table valued function to search the users in my site.
The search is optional ie. sometimes user will search with first name, sometimes he searches with last name, and sometimes both.
As of now I am using if-else statements to check whether first name is ''(empty),or last name is ''(empty) or both are ''(empty).

I have two questions?

1. Is there any other way, so that I can avoid these if-else statements and make it a single query?
2. If I am using a function as shown below, I have to specify all the return parameters. Is there any way I can avoid this and return the complete table(I do not want to use stored procedures)?

I'm using a freetext search,because I want to get the search results according to relevence(ranked results).


ALTER FUNCTION [dbo].[Search]
(

@FirstName Varchar(400),@LastName Varchar(400)
)
RETURNS
@SearchResults TABLE
(
-- Add the column definitions for the TABLE variable here
UserName Varchar(400),
EmailAddress Varchar(400)
)
AS
BEGIN

IF (@FirstName<>'' AND @LastName<>'')
begin
insert into @SearchResults
Select Top 100 Percent UserName,EmailAddress
From UsersFirst t
JOIN FreetextTable(UsersFirst, FirstName, @FirstName) K On t.Id = K.[Key]
JOIN UsersSecond U on t.UserId=U.Id
JOIN FreetextTable(UsersSecond, LastName, @LastName) As L On U.Id = L.[Key]
ORDER BY K.[Rank] DESC;
end
ELSE IF (@FirstName<>'')
begin
insert into @SearchResults
Select Top 100 Percent UserName,EmailAddress
From UsersFirst t
JOIN FreetextTable(UsersFirst, FirstName, @FirstName) K On t.Id = K.[Key]
JOIN UsersSecond U on t.UserId=U.Id
ORDER BY K.[Rank] DESC;
end

return
END



Thanks In Advance
jophin

QuestionLogin Fail for user 'XYZ' Pin
Sasmi_Office24-Jun-10 2:19
Sasmi_Office24-Jun-10 2:19 
QuestionRe: Login Fail for user 'XYZ' Pin
Chris Meech24-Jun-10 2:53
Chris Meech24-Jun-10 2:53 
AnswerRe: Login Fail for user 'XYZ' Pin
Sasmi_Office24-Jun-10 4:38
Sasmi_Office24-Jun-10 4:38 
GeneralRe: Login Fail for user 'XYZ' Pin
Chris Meech24-Jun-10 4:46
Chris Meech24-Jun-10 4:46 
Questionsql function to calculate work hours Pin
Athira.G.Krishnan24-Jun-10 2:11
Athira.G.Krishnan24-Jun-10 2:11 
AnswerRe: sql function to calculate work hours Pin
Scubapro24-Jun-10 4:18
Scubapro24-Jun-10 4:18 
AnswerRe: sql function to calculate work hours Pin
David Mujica24-Jun-10 6:16
David Mujica24-Jun-10 6:16 
GeneralRe: sql function to calculate work hours Pin
CitrusTech24-Jun-10 21:01
CitrusTech24-Jun-10 21:01 
QuestionGroup By 30 Minutes Pin
It_tech23-Jun-10 23:42
It_tech23-Jun-10 23:42 
AnswerRe: Group By 30 Minutes Pin
Mycroft Holmes24-Jun-10 1:04
professionalMycroft Holmes24-Jun-10 1:04 
GeneralRe: Group By 30 Minutes Pin
It_tech24-Jun-10 2:59
It_tech24-Jun-10 2:59 
AnswerRe: Group By 30 Minutes Pin
J4amieC24-Jun-10 3:31
J4amieC24-Jun-10 3:31 
GeneralRe: Group By 30 Minutes Pin
It_tech24-Jun-10 3:56
It_tech24-Jun-10 3:56 
GeneralRe: Group By 30 Minutes Pin
J4amieC24-Jun-10 6:15
J4amieC24-Jun-10 6:15 
GeneralRe: Group By 30 Minutes Pin
It_tech24-Jun-10 6:20
It_tech24-Jun-10 6:20 
GeneralRe: Group By 30 Minutes Pin
Mycroft Holmes24-Jun-10 11:49
professionalMycroft Holmes24-Jun-10 11:49 
GeneralRe: Group By 30 Minutes Pin
It_tech25-Jun-10 0:50
It_tech25-Jun-10 0:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.