Searching In Multiple Tables Using MS SQL Server 2000?
Sep 14, 2010
We have a database with a lot of information about Persons. I won't post the entire database structure because it is too big, but it looks something like this:
Person
ID
Name
Street
City
State
Country
Language
LangCode
Language
Interest
ID
LastChangedBy
LastChangedOn
LocalizedInterest
InterestID
LangCode
Description
PersonInterest
PersonID
InterestID
Now, this is just a small example. In our database, we have about 8-9 localized tables (like Interest) a Person can be linked to. A Person can have multiple Interests, a Person can have multiple Jobs, a Person can have multiple Educations, a Person can have multiple Experiences, I have to build a search function. Let's say you enter "tom" as the search term. This should give a list of all Persons with "tom" in their Name, Street, City, State, Country, in one of their Interests, in one of their Jobs, in one of their Educations, in one of their Experiences or in one of the other linked tables.
If you enter multiple words to search for (eg. "tom php"), it should give a list of all Persons with "tom" in their Name, Street, City, State, Country, in one of their Interests, in one of their Jobs, in one of their Educations, in one of their Experiences or in one of the other linked tables AND "php" in their Name, Street, City, State, Country, in one of their Interests, in one of their Jobs, in one of their Educations, in one of their Experiences or in one of the other linked tables. At the moment there are about 4,500 records in the Person table and if I do an outer join of Person with all the tables I have to search, there are about 1,300,000 records and 40-50 fields to search in.
How should I approach this problem so that performance will be acceptable? The client expects "something like Google" in terms of speed and ease of use. We're using MS SQL Server 2000 and ASP.NET 2.0. The search functionality has to be added to an existing application and changing the technology or database structure is not an option.
View 1 Replies
Similar Messages:
Aug 12, 2010
I have a couple tables that are kind of unrelated - id like to search through both of them and create a type that i can sift through later
something like this doesnt work
[Code]....
I basically want to create a list of "AnimalSearchResults" that contains all dogs and all cats that have that name Whats the best way to do something like this?
View 6 Replies
Feb 10, 2010
I am using Profile properties in my application... ASP.Net 2.0 , and SQL Server 2005 at my end... well DB production server is SQL Server 2000.. My friend said, 'aspnet_regsql A -p' won't work for SQL Server 2000... I can't check if will work or not...
View 1 Replies
Sep 16, 2010
I want to query an SQL table using some Web controls to provide the parameters for filtering the records in the table. Results are displayed in a GridView.
I have a TextBox with an ID of "keyword" where the user may enter one or more keywords. I'd like to search 2 columns for instances of these keywords.
I also have a DropDownList named "category" that lists categories contained in a "category" column of the table.
I have a dataset with a TableAdapter for the table I want to search. Got it working fine with the DropDown List but not sure how to proceed with the TextBox and keywords.
What SQL query should I use? The user may not enter anything into the textbox, they may enter one word, or multiple words.
This is where I am now:
SELECT * FROM tablename WHERE category = @category AND ??
View 7 Replies
Jul 21, 2010
moving some tables & stored procedures from SQL Server 2000, to SQL Server 2005.So far so good, but I've come across a problem with this stored procedure:
CREATE PROCEDURE [dbo].[user_insert]
@user_service_unit int,
@user_champion_1 varchar(50),
@user_champion_1_nt varchar(10),
@user_champion_2 varchar(50),
@user_champion_2_nt varchar(10),
@user_champion_3 varchar(50),
@user_champion_3_nt varchar(10),
@user_date_received datetime,
@user_requestor varchar(255),
@user_info_requested text,
@user_expiry_date datetime,
@user_10_days datetime,
@user_5_days datetime,
@user_2_days datetime
[code]...
View 3 Replies
Jul 8, 2010
I have one gridview, a dropdown list where I can search the users table or a group name table, a textbox for inputting the search and a button to search.How could I overwrite the users table that is binded in the gridview when I search through the groupname table? Using C#.
View 2 Replies
Jul 24, 2010
I am accessing rows in an SQL database table based upon the contents of the Primary key and another column. But, I cannot insert new rows in the table when the content of the new Primary key column already exists in another row. Can I define the table with a multiple column Primary key so that a unique value can be based upon the content of both columns?
View 3 Replies
Jan 30, 2011
I have four tables namely tblStudent, tblParent, tblEmployee and tblUnwantedVisitor.
tblUnwantedVisitor should get the primary key from the three tables, which is the visitor ID, tblStudent visitor ID starts from 10000, tblEmployee from 20000 and tblEmployee from 30000.
I used foreign key from one to one table only, so I don't know if my approach for the database is wrong or foreign key for multiple tables, which is somehow unlikely, is necessary.
View 14 Replies
May 21, 2010
I have two tables, Customer and CustomerPhone.
Single record in Customer can have multiple CustomerPhone records. As you see in the image below, Phone and Fax resides in CustomerPhone table whereas the rest of the fields resides in Customer table. If user want to edits a customer record, obviously i will have to update the record in Customer table and at least two records from CustomerPhone (Phone and Fax).
I could write two update statements, one Update customerPhone and the second update Customer table. Is there a better solution?
View 2 Replies
Oct 1, 2010
SELECT u.Email FROM UserProfiles p, aspnet_Membership u WHERE p.RulesCheckBox = 'True' AND u.UserId = p.UserId This gives me a list of registered member email addresses that have selected the RulesCheckBox in their profile, so I can email them with an email script. There is a relationship between the Membership table and the UserProfile table, so it finds the email addresses from the Membership table where that user has the RulesCheckBox checked in their profile (in UserProfiles table). I'm wanting to add some additional names to this list, from a different table. The purpose is so I can manually add email addresses to the additional table, so the additional email addresses will also receive the same email, even though they aren't registered members of the site. So how can I adjust that SELECT statement so this one is combined with it somehow?:
SELECT Email FROM ExtraEmails WHERE Rules = 'true'
View 4 Replies
Sep 17, 2010
I have excel file with columns EmpName,Date1,Date2,...Date7 .I want to insert EmpName into Employee table after inserting i will get EmpNo(Identity column) with that i need to insert Date1,Date2...Date7 into TimeSheet table.
My Excel structure is like this
EmpName 8/1/2010 8/2/2010 8/3/2010 8/4/2010 8/5/2010 8/6/2010 8/7/2010
Naresh 17:00-2:00 17:00-2:00 14:00-12:00 7:00-12:00 7:00-12:00 .. Off
Similarly 500 employees data
I want to insert name i.e into Emp table after inserting i will get EMpNo i.e identity column with that i should insert Date1(8/1/2010) i.e excel header to date7 into Timesheet table Date column and corresponding time into TimeIn and TimeOut.I will split the time.I just want write Stored procedure for this task.
My database tables are like this
Emp-EmpNo,EmpName,CompaignId
Timesheet-TimeID,EMpNo,Date,TimeIn,TimeOut,TotalHours
Date in Timesheet should be like this
TimeId EmpNo Date TimeIn TimeOut T otalHours
1 100 8/1/2010 17:00 2:00 9hrs
2 100 8/2/2010 17:00 2:00 9 hrs
7
I just want this logic on how to insert Date1 to date 7 as 7 rows into Timesheet table and EMpName into EMployee table.while accesing each row i need to insert Date 1 to date7 as 7 rows into Timesheet table.
View 2 Replies
Sep 8, 2010
Was wondering if someone can help me out with this multi update problem
I have a webform that populates a single table but due to certain dropdown data conditions it could also potentially populate 3 other tables
The tables information populates a gridview with amounts from accounts etc..
e.g.
Table 1
Site DataType account update
34 SS 12.50 N
Table 2
Site account
34 12.50
Say the above entry has the updated column changed to Y via the webform the amount 12.50 should disappear from the gridview. I was
a bit shortsighted and added the additional tables afterward. The information on the gridview pulls from the additional tables and since
the first table and the additional tables are not linked the data still stays the same in the gridview
I do have an Id column on both tables but unfortunately I added the rest of the tables after the first one so the Id's do not really match.
View 6 Replies
Jul 21, 2010
I have 3 tables
Restaurants
IDNameAddress
Location
ID (Foreign Key)LocationID
Food
ID (Foreign Key)FoodID
Here's what I want to do, I have two variables @FID(food ID) and @LID(LocationID). I want something like
select * from restaurant where ID in (( select ID from location where locationID = @LID) AND (select ID from Food where FoodID = @FID))
The bold part is where I'm having problems. I want it to check both the Location and Food table for a match.
I'm having a hard time putting it into words :p I hope you get what I mean
View 2 Replies
Dec 23, 2010
Just looking through database design and wondering what would be the better option. I have customers, who all have orders, pickings, deliveries and invoices. Now an invoice can't exist without a delivery, a delivery can't exist without a picking and a picking can't exist without an order. So I could set the tables up in a linear fashion. e.g.
Customer -> Orders -> Picking -> Delivery -> Invoice
then in Orders, there would be an ID field, with a customerID field and in Picking, there would be an ID field, with an orderID field and in Delivery, there would be an ID field, with pickingID and in Invoice, there would be an deliveryID field. Linking them altogether, again, in a 'linear' fashion.
The problem is if I want to get, say, all the invoices for a specific customer, my query would be something like
[Code]....
My other option would be to have in a customerID column in each of the tables meaning a much easier query
[Code]....
View 3 Replies
Sep 6, 2010
Originally "LoadDate" column (see below scripts) was there both in tables DIM_Table_1 and DIM_Table_2
According to change in requirement, LoadDate in both the tables to be chnged to LOAD_DATE. It has to be done through script
EXEC sp_rename 'dbo.DIM_Table_1.LoadDate',
'LOAD_DATE', 'COLUMN' -- Successfully executed
EXEC sp_rename 'dbo.DIM_Table_2.LoadDate',
'LOAD_DATE', 'COLUMN' -- Error: See below
Error: The new name 'LOAD_DATE' is already in use as a COLUMN name and would cause a duplicate that is not permitted.
View 2 Replies
Jul 27, 2010
I'm a novice in .NET programming. I was trying to figure a way to make a MULTI TABLE search via a stored procedure for my website. I've written a SP to select records from one table, which isn't working for some unknown reasons:
[Code]....
Whatever I search for, the datagrid is displaying all records from my table.
View 5 Replies
Dec 1, 2010
Is there a way to select data from multiple tables other than the UNION ALL statement. Addtionally I need to select data from a different database.
My current statement is as follows (there are alot more fields but I have shortened it ):
SELECT server.dbo.SRFILE.SR_GROUP, server.dbo.SRFILE.SROWNERSHIP, server.dbo.SRFILE.SRCONMAE, BSFLBWF_1.Incidentx,
BSFLBWF_1.Severityx FROM server.dbo.SRFILE INNER JOIN
BSFLBWF AS BSFLBWF_1 ON BSFLBWF_1.Incidentx = server.dbo.SRFILE.SRONUMBER
WHERE (BSFLBWF_1.Closex IS NULL).........
View 4 Replies
Jul 27, 2010
I am accessing rows in an SQL database table based upon the contents of 2 Primary key columns. But, I cannot insert new rows in the table when the content in one of the new Primary key columns already exists in another row. I get an error message that says: "Violation of PRIMARY KEY constraint 'PK_ReferendumVoters'. Cannot insert duplicate key in object 'dbo.ReferendumVoters'. The statement has been terminated."
The reason why this error is occurring is because I first stored "Referendum 1" in one column along with "me" in the second column of a new row for a "ReferendumVoters" table. Then, I attempted to insert a new row with the same "Referendum 1" string in the first column along with a different name in the second column. But, it will not let me do this even though I created a new index that defines the two columns as unique. Is there any way that will enable me to do this?
View 5 Replies
Jan 26, 2010
First off I'm a week into asp so apologies in advance for silly questions! I am looking to connect to a SQL database table and allow the user to filter the table based on a search box on the asp page. I have written a sql query with a parameter in the where clause, a bit like this:
select col1, col2
from table
where col1 like @my_parameter
Then I pointed the parameter to a textbox on my asp page, and this seems to work quite well. However, I would now like to add an additional search facility which would be a dropdown list. This would be sourcing all the unique values from the col2 in my table abve (there are only about 10 possible values here). But I don't want users to be able to use both of these searches at the same time.
So the bottom line is I would like to offer two methods of filtering the same data table, which search on different columns of the data table. Then the results should populate the same results table, but the user must only be able to use one search method or the other.
I have done a bit of research but couldn't find anything along these lines (I think it is becuase I don't know the words of the things I should be searching for!). I did find information on a standard postback event or cross page posting - not sure which of these (if any) is the best to use for a beginner?
View 2 Replies
Nov 15, 2010
One of my peer wrote a query based on multiple tables using joins. One of the table is in a different database The query was taking much time
1. Create an SP
2. Create a temp table and copy all records from the external db
3. Avoid using Left Join as much as possible and use Inner Join
4. Create and use indexes
5. Remove tables/columns that are not necessary
In this scenario, I would like to suggest to use Covering Index, but how can it be created for multiple tables and a temp table?
View 3 Replies
Nov 29, 2010
I basically have a series of tables from one database that have an identical structure thus making retrieval of all records fairly easy (I just use a UNION ALL statement). However I need a list of values from another table within a different database that contains information regarding the group of the data.
I so far have the following:
SELECT Table1.* FROM Table1 UNION ALL SELECT Table2.* FROM Table2 UNION ALL SELECT Table3.* FROM Table3 UNION SELECT Database.dbo.SRFILE.SR_GROUP FROM Database.dbo.SRFILE INNER JOIN Database.dbo.SRFILE.SRONUMBER = Table1.Incidentx
I keep receiving a unable to parse message however all I need to retreive is the SR_GROUP value but just don't know the correct syntax. Is it actually possible to do this as the structure of SRFILE is not the same as Table1/2/3.
View 3 Replies
Jan 4, 2011
I have an C# ASP application I am writing that needs to have the capability to import a generated excel or a comma delineated sheet each day. A clerk will have this job each morning so it doesn't need to be automated. My problem in trying to understand the solution to this is that the 1 sheet contains loan information, including customer information all in the same sheet. I would like to send certain columns to update information in the loan table and send other information to update the customer table. I need it to create relationships when new loans appear in the spreadsheet.
View 1 Replies
Jan 21, 2010
I am trying to create a form in MVC C# that will allow a user to input a Last Name, First Name, Department, Year and click a Search button that will bring back a list of employees based off the inputted search criteria.My problem is allowing multiple search textbox criteria into one search button. I am able to hardcode values into an html actionlink like below and it works but unable to grab the values from the textboxes.
<%= Html.ActionLink("Results", "Results", new { lastName = "Smith",
firstName = "", dept = "", year = "2008" } )%>
I would really just like to have four textboxes and a search button to bring the list back from the database.
View 3 Replies
Jul 9, 2012
I have three text boxs
1.txtname
2.txtage
3.txtmobile
and one dropdownlist
1.ddlcity
for search client information.
My requirement is when search button click the client information will bind in gridview based on data filled in textbox and dropdown list.
The difficulty is user can enter any combination for search. E.g.
1.age only
2.name and city
3.city only etc.
View 1 Replies
Apr 15, 2010
I want to select data from a table where the user can search by 3 options; date, keyword, and type. The date will always be either today or a user chosen date. The keyword can be null or something the user inputs. The type will be chosen from a drop down and can be all or a specific category. I know how to search the date, but the other two create complications. I have created a stored procedure trying to figure this out:
[Code]....
Is there a way to say if the keyword is null then don't use it as a search criteria. If that is possible then type can use that same logic I suppose.
View 6 Replies