Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MS SQL Server


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





How To Make A Search Engine To Search My Database


hi there,

 i am doing a school project and i need to have this search engine that will search the data that i have stored inside the database and display the results out

can anyone help?

thanks




View Complete Forum Thread with Replies

Related Forum Messages:
How To Make A Fuzzy Search Engine
When i search for Peter.Peter,Pan was successfully retrieved from the DatabaseBut when i Search for Peter Pan.It found no results.How can i make it such tat it can find results for Peter Pan too?In another words, how to make my search engine more powerful,fuzzy and intelligent?My current Code:<asp:SqlDataSource ID="dsSearch" runat="server" ConnectionString="<%$ ConnectionStrings:csHPDB %>" SelectCommand="SELECT * FROM [employee_table] WHERE ([employee_name] LIKE '%' + @employee_name + '%') <SelectParameters> <asp:QueryStringParameter Name="employee_name" QueryStringField="Search" Type="String" /> </SelectParameters> </asp:SqlDataSource>

View Replies !
How Can I Search Throught DOCX (MS Word 2007) Documents By SQL Server 2005 Full Text Search Engine?
How can I search throught DOCX (MS Word 2007) documents by SQL Server 2005 Full Text Search engine?

Should I something download?

View Replies !
Database Search Engine
Hi folks,
Whts up........??? M back, after a long gap.
I have come across with a major issue. And u know wht th issue is.........???
It is about th DATABASE SEARCH TOOL. I have a database of around 30 tables. Now I wud like to have aa search engine on my .asp page. There will be a text box on th page and one submit button. After typing some text in th text area n submitting th page, my package sud check tht perticular text in all th COLUMNS of all th TABLES, n whrevr it gets a match (exactly same, or by speech recognition), it sud through th links on th next page.

Nw i wud like u guys to take this problem, at th earliest n come up with a up to th mark solution.

Thnkx

View Replies !
SQL 2000 MS Search: Boolean Search Doesn't Work When Search By Phrase
I'm just wonder if this is a bug in MS Search or am I doing something wrong.

I have a query below

declare @search_clause varchar(255)

set @Search_Clause = ' "hepatitis b" and "hepatocellular carcinoma"'

select * from results

where contains(finding,@search_clause)

I don't get the correct result at all.

If I change my search_clause to "hepatitis" and "hepatocellular carcinoma -- without the "b"

then i get the correct result.

It seems MS Search doesn't like the phrase contain one letter or some sort or is it a know bug?

Anyone know?

Thanks

 

View Replies !
Search Engine
Hi,
I am building a website using visual web developer and sql server 2005, i want to implement a search box/engine which will return search results to the user, the results would be details of a movie they are looking for, i appreciate all advice and help given, thanks.

View Replies !
How To Search A Database For A Key Word Based Search?
Can anyone tell me how to search an SQL database for a given key word in a textbox? I basically have a database that has a qualifications column and this column needs to be searched for the data given in the textbox. Which is the best method to search for the data? Is it a simple SQL query or an XML based search engine type? Can anyone give any suggestions regarding this? If XML is efficient then how do I use it to query my database, as I'm pretty new in XML based searching.Thanks 

View Replies !
Search Engine Logic???
Hi All,
I am doing search engine in my home page. It will search all products details for a specified pattren/search keyword in all categories. It should display the first product as the most character match of key words which the user has entered for the Products. Any idea plz......................
My logic is prod_name like '%mobile%'
Thanks.

View Replies !
Creating A Search Engine
I'm not sure if this is the appropriate forum to ask this question; however, here goes.
I'm being asked to create/modify a search engine for our Web site.  Beyond trying to enhance the speed, I've been asked to add spelling and punctuation checks into the search text.
Right now, all that's being done is a simple like statement.
What's the best method to query a database? 
For example, if someone typed in "A and W" or "A/Ws" to get the value"A & W's", how would I make the link?  Is there a database table that exists that I could reference to replace & with and (or vice versa) , etc...  Is there a good place to start?

View Replies !
Search Engine Problem
Hello Friends,
                  I am developing a search engine with Full-Text Catalogues. Now I wanna give two options to user for search 
1)   Exact word
2)   Like Word
But catalogues always searches for like words.e.g. If "Customer Responsivness" is search text and i want exact word .but It  gives result as like query means return records contains the text "Customer" or "Responsivness" or "Customer Responsivness" Can any body help that how can i change catalogues to behave it like Exact word  also If there is any other method to serach from sql server except catalogue please reply.
Thanks
Dheeraj Verma

View Replies !
Search Engine In SQL Server ?
hi,I'm building a simple search engine using keyword and title of a page:select ID, content_ID, 3 as 'weight'from tblPagewhere keywords LIKE '%test%'unionselect ID, content_ID, 2from tblPagewhere title LIKE '%test%'now I want to sum and order 'weight'thx

View Replies !
Search Engine Is Not Working
Swynk have implemented a new search engine on this site. I have found that
whatever I search for it finds nothing. Does anyone know of a work around?

View Replies !
How Do I Program A Search Engine?
I heard that making a search engine involves PHP programming. I would like to know how to program a secure well developed image search engine for my website. Are there any websites or books you could recommend? I know a little C-sharp, but I think a beginners book in PHP would be better than an advanced or novice one. I understand this may be in the wrong forum but I figured it may involve some MySQL


www.digital-orb.com

View Replies !
3rd Party Search Engine Web To SQL?
Hi All,
I am pretty new to SQL and would like a bit of friendly help, please. Am trying to set up a .Net web site that will have dynamic content supplied by a true SQL server (am using MSDE to build this first).

My issue is in building a search engine on my web site that will return hits from the content of the pages which are loaded in MSDE.

Is there a third party or open source search engine available?

Any clues for how to build (or beg, borrow or steal) a workable search engine to do this?

Many thanks,
Newbie

View Replies !
A Full-text Search Engine
Hi
I'm working on a digital Library project. Can anybody suggest a powerful Asp.net full-text search engine Script or guide?
Thanks

View Replies !
Making A Proc For A Search Engine
Dave writes "I am in the dark on this one, but maybe by talking about it I can figure something out. I am an amature with sql, so bear with me. What is need to do is search 3-4 fields in a table. For example. If I search for "I am a football fan of the Colts" I somehow need to take out those conjunctions and smaller words. Not to mention weighting the search results. Any help would save me"

View Replies !
Simple Search Engine (windows Application)
I'd like to build a simple search engine against Sql Server. Does .NET Framework provide some class to help in this task? From what I've heard there is an interface which implements it..

View Replies !
NetSearch The Business Intelligence Search Engine
Ardenta Ltd, announce the release of NetSearch, the premier BusinessIntelligence Search Engine. NetSearch provides tradditional search enginefunctionality combined with a database querying system giving a unparalleledad-hoc query capability. Find out more at http://www.ardentia.com.

View Replies !
Error Installing Full-text Search Engine
Hi, though i've been using sql server 2000 developer edition for awhile, I guess i overlooked the fact that the full-text search tool was never installed and i never needed it until now. Anyway, tried installing it today and get this error:

Installation of Microsoft Full-Text Search Engine Package Failed (-2147220991) 0x80040201
An event was unable to invoke any of the subsribers

I have no idea what this means - can you help me to get this installed correctly? I did just install service pack 4, and i tried reinstalling the components, tried rebuilding the registery of the current instance, and even tried creating a new instance with hopes that the new instance would install the full-text component - which it did not.

Any suggestions? Maybe I have to unistall the entire Software and reinstall it? Would I lose any of my data in doing this? I should note that all other tools seem to function fine.

Thanks ahead!

Dan

View Replies !
Indexing SL CE To Make Search Faster. How?
Dear VB coders!

I have 8.000 or 16.000 products on my list in an sql table. It takes 8 or 16 secs to find the last item.

How could I make the search faster? Indexing? But how?

I created:
createTable1.CommandText = "Create TABLE products (ID int IDENTITY(0,1) PRIMARY KEY, name ntext)"
 
and I use simple WHERE to search.
 
Thank you!

View Replies !
How To Make Full-text Search Accent-insensitive?
My SQL Server 2000 does not use the accent insensitive collation setting(collation containing _AI) in full-text serches:While SELECT * FROM <table> WHERE <column> LIKE '%a%' returns 'Mäuse',SELECT * FROM <table> WHERE CONTAINS(*, 'a') does not.Setting 'default full-text language' to neutral (0) does not help.How can I make full-text searches accent insensitive?Thanks for any ideas!Matthias

View Replies !
Help W/ Stored Procedure? - Full-text Search: Search Query Of Normalized Data
 Hi -  I'm short of SQL experience and hacking my way through creating a simple search feature for a personal project. I would be very grateful if anyone could help me out with writing a stored procedure. Problem: I have two tables with three columns indexed for full-text search. So far I have been able to successfully execute the following query returning matching row ids:  dbo.Search_Articles        @searchText varchar(150)        AS    SELECT ArticleID     FROM articles    WHERE CONTAINS(Description, @searchText) OR CONTAINS(Title, @searchText)    UNION    SELECT ArticleID     FROM article_pages    WHERE CONTAINS(Text, @searchText);        RETURN This returns the ArticleID for any articles or article_pages records where there is a text match. I ultimately need the stored procedure to return all columns from the articles table for matches and not just the StoryID. Seems like maybe I should try using some kind of JOIN on the result of the UNION above and the articles table? But I have so far been unable to figure out how to do this as I can't seem to declare a name for the result table of the UNION above. Perhaps there is another more eloquent solution? Thanks! Peter 

View Replies !
Save Indexed Search Words (Index Full-text Search)
We have SQL Sever 2005 and created a Full-text Search on a one of our main tables. When some one comes for the first time and searches for "carb" it takes a long time to return results, but when the same search is done within a few more minutes, results return in less than 1 second.

Is there a setting in SQL Server 2005 to save all the indexes of searched words?

Thanks

View Replies !
Full-Text Search: Prefix / Suffix Search
Please help me to create an SQL Server 2000 Stored Procedure for using prefix and suffix terms.

Example:

Say I want to find "Terminator" (1984).

I want to be able to use "Term" or "ator" as search results and still return the proper record.

Here is my Stored Procedure creation sql:


CREATE PROCEDURE sps_searchTitles(@searchTerm varchar(255)) AS
SELECT * FROM Video
WHERE FREETEXT (Video.*, '"*@searchTerm*"')
GO


--- The above does not appear to properly check both prefix ("Term---") and suffix ("---ator") terms.

I am trying to accomplish what is similarly done with LIKE '%term%'.

thanks, YM

View Replies !
Full Text Search- Substring Search Not Working
I have Sql server 2005 SP2.
I enabled it for Full Text search. Substring search where i enter *word* doesn't return any row.
I have a table testtable where description has word Extinguisher.

If i run a query with *ting* it doesn't return any row.
select * from testtable where contains(description,'"*xting*"') ;

But it works if i do
select * from testtable where contains(description,'"Exting*"') ;

The Full text search document says it supports substring search.
Is it an issue with sql server 2005?Please help.

View Replies !
Full Text Search Vs LIKE Search
Are there any big differences between the two search techniques? It seems like they are both very similar.

SELECT * FROM TABLE1 WHERE TEXTFIELD1 LIKE '%DATABASES%'
SELECT * FROM TABLE1 WHERE CONTAINS (TEXTFIELD1 ,' "DATABASES" ')

View Replies !
Create Site Search Using Sql Server &"full Text Search&"
would you use sql server "full text search" feature as your site index?  from some reason i can't make index server my site search catalog, and i wonder if the full text is the solution. i think that i wll have to you create new table called some thing like "site text" and i will need to write every text twice- one the the table (let's say "articles table") and one to the text. other wise- there is problems finding the right urlof the text, searching different tables with different columns name and so on...
so i thought create site search table, with the columns:
id, text, url
and to write every thing to this table.
but some how ot look the wrong way, that every forum post, every article, album picture or joke will insert twice to the sqr server...
what do you think? 

View Replies !
Database Search
Hi
I would like to know whether any tools are there to search in a database. Ex. i am using sql server2005 and in my db, more than 1000 tables r there.
i want to search for a perticular column. This search should be on tables, sps, functions, triggers.....etc.
 
If anybody aware of any tool for this or any code in dotnet to develop such tool, pls let me know.
 
Regards
Sanjay

View Replies !
Search Database
Hi All!I have a Table with name "Mytable" and fields as below: Tittle Date Category

View Replies !
Search Database
I design table which has column "keywords" for keep keywords seperated by comma (,). If user pass one keyword, how can I know that the keyword user select is exactly match with any keyword in field. I mean I just want SQL return only rows that user's keyword is exactly match with at least one keyword in "keywords" column.

Ex.
PK1 Data1 Data2 keywords
1 1 1 apple, orange
2 2 2 mange, orange
3 3 3 mange, apple

If user select keyword 'orange', SQL must return only row 1 and 2.

View Replies !
Sql Database Search
Does anyone know of a software product that can search through a large Network Enterprise, searching for all SQL databases while, specifying an IP range?

View Replies !
How Search A Value In A DataBase.
--Author:=> Kapil Choudhary Jaipur (India)
--Motive:- Search A Text value In A DataBase With The Table Name.


create procedure [search_value]
@fstr nvarchar(128)
with encryption
as

set nocount on
declare @rc int --Counter Variable For The Cursor 1.
declare @rcc int --Counter Variable For The Cursor 2.
declare @tc nvarchar(128)--TABLE_CATALOG.
declare @ts nvarchar(128)--TABLE_SCHEMA.
declare @tn nvarchar(128)--TABLE_NAME.
declare @tt nvarchar(128)--TABLE_TYPE.
declare @Ctn nvarchar(128)--Column Table Name.
declare @Cts nvarchar(128)--Column Table Schema.
declare @Ccn nvarchar(128)--Column Column Name.
declare @Cdt nvarchar(128)--Column Data Type.
declare @currow1 int--Total Row Count For The Cursor 1.
declare @currow2 int--Total Row Count For The Cursor 2.
declare @str nvarchar(128) --Dynamically Created Query String.
declare @strresult nvarchar(128)--Value Stored From Temp Table.
declare @findwhat nvarchar(128) -- String To Be Searched.
set @rc=1
create table #temp (colval nvarchar(128))
create table #myresult(Table_Name nvarchar(128),Column_Name nvarchar(128),Column_Value nvarchar(128))
declare mycur1 cursor static for
select TABLE_CATALOG,TABLE_SCHEMA ,TABLE_NAME,TABLE_TYPE
from INFORMATION_SCHEMA.TABLES
where TABLE_TYPE='BASE TABLE'
open mycur1
set @currow1=@@cursor_rows
--print 'table rows = '+str(@currow1)
while @rc<=@currow1
begin
fetch next from mycur1 into @tc,@ts,@tn,@tt
declare mycolcur cursor static for
select TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME,DATA_TYPE
from information_schema.columns
where TABLE_CATALOG=@tc and TABLE_SCHEMA=@ts and TABLE_NAME=@tn and data_type in('char','varchar','nchar','nvarchar')
open mycolcur
set @findwhat='wa'--Your Search Value Here
set @rcc=1
set @currow2=@@cursor_rows
--print 'table col = '+str(@currow2)
--print 'Table name'+' '+'owener'+' '+'Column Name'
--print '-----------------------------------------------'
while @rcc<=@currow2
begin
fetch next from mycolcur into @Cts,@Ctn,@Ccn,@Cdt
-- print @ctn+' '+@cts+' '+@ccn
set @rcc=@rcc+1
set @str='select '+quotename(@ccn) + ' from ' +quotename(@cts)+'.'+ quotename(@ctn) + ' where ' + quotename(@ccn) +' like '+char(39)+@findwhat+char(39)
set @str='insert into #temp(colval) '+@str
--print @str
exec (@str)
if exists(select * from #temp)
begin
select @strresult= colval from #temp
--print 'colval =========>>>>> ' + @strresult
delete from #temp
insert into #myresult(Table_Name,Column_Name,Column_Value) values(@ctn,@ccn,@strresult)
end
end
close mycolcur
deallocate mycolcur

set @rc=@rc+1
end
--print @@cursor_rows
select * from #myresult
close mycur1
deallocate mycur1
drop table #temp
drop table #myresult
set nocount off
Go

View Replies !
Search For Tables In Database
 well i am using vb.net and would like to know how to search a specific table in the databasefor egif  table1 exists in database then drop table1end  if ...something like that

View Replies !
Search Database Tutorial?
Do someone know good tutorial on web with examples for search data from SQL database?

View Replies !
How To Search Record In Database By Using ASP.NET
I have problem in searching record using ASP.Net:
Here is the error:
The column prefix 'txtID' does not match with a table name or alias name used in the query
Here is the code:
<%@ page language = "vb" runat = "server"%><%@ Import Namespace = "System.Data"%><%@ Import Namespace = "System.Data.SqlClient"%><script runat = "server">
Sub SearchData(sender As Object, e As EventArgs)dim StudentConnection as SqlConnectiondim StudentCommand as SqlCommanddim StudentReader as SqlDataReaderdim i as Integer = 1
StudentConnection = New SqlConnection("Server=MYCOMP;uid=tim;pwd=tim;database=Student")StudentConnection.Open()
StudentCommand = New SqlCommand("Select * From Student_Table Where STUDID = txtID.text",StudentConnection)StudentReader = StudentCommand.ExecuteReader()StudentDataGrid.DataSource = StudentReaderDataBind()
StudentReader.Close()StudentConnection.Close()
End Sub</script>
<html><head><title>::SAG Computer School::</title></head><body><form runat = "server">Student ID : <asp:TextBox id = "txtID" runat = "server" /><asp:Button id = "btnSearch" text = "Search" runat = "server" OnClick = "SearchData" />
<asp:DataGrid id = "StudentDataGrid" BorderColor = "Black" BorderWidth = "1" CellPadding = 3 CellSpacing = 0Font-Name = "Arial" Font-Size = 10pt Font-Color = "Black" AutoGenerateColumns= false ItemStyle-BackColor = "White" HeaderStyle-BackColor = "#FFEFD5"ItemStyle-Font-Size = 8pt runat = "server"></asp:DataGrid>
<Columns><asp:boundcolumn HeaderText = "ID" DataField = "STUDID" /><asp:boundcolumn HeaderText = "NAME" DataField = "STUDNAME"/><asp:boundcolumn HeaderText = "ADDRESS" DataField = "ADDRESS" /><asp:boundcolumn HeaderText = "IC NO" DataField = "ICNO" /><asp:boundcolumn HeaderText = "PHONE" DataField = "PHONE" /><asp:boundcolumn HeaderText = "EMAIL" DataField = "EMAIL" /><asp:boundcolumn HeaderText = "DATE OF BIRTH" DataField = "DOB" /><asp:boundcolumn HeaderText = "NATIONALITY" DataField = "NATIONALITY" /><asp:boundcolumn HeaderText = "COURSE" DataField = "COURSE" /></Columns></form></body></html>
Anyone know the solutions??? Or, is this a correct way in searching data??
Thanks,
Suigion
 

View Replies !
Can Anyone Help Me With Connecting To A Database To Search?
I'm trying to make this piece of code work, I get all of it except how I get the data from the database, what I wish to do is. On page load I wish to take the value of a querystring in the page URL called ProductID and search a database to see if it exists in a specifical table and column, if it exists I wish to make a button not visible. the code I am using is:
 
#############
 
protected void Page_Load(object sender, EventArgs e)
    {
// Get the querystring value
        String inQueryString = Request.QueryString["ProductID"];
       
        // Get the data from the database, using the above value
        DataTable data = ??
  
The datasource I want to connect to is SqlDataSource1, and the table I want to search is “Reviewsâ€?. I want to search in the column “ProductIDâ€? and search for the ProductID from the URL query string above.
       
        // Did we find a product in the database?
        if (data != null &&
            data.Rows.count > 0)
        {
            // Code to display the product's information
           // We found a product, so we need to hide a button
            Button5.Visible = false;
        }
       
   
        }
 
##########################
 
Please can somebody fill in the missing bit for me so i know how it should be, i've searched the quickstart tutorial on the menu above and I still don't understand it, as it doesn't show anything like what I want to do, and I have looked at numerous websites about the matter. If you don't have time that is okay, but If somebody does have the time to show me what I need, I would be very greatfull.
 
Regards
 
Daniel coates

View Replies !
Using Webforms To Search A Database
Currently, I am working on a website that will use a webform to search a SQL database and list the results in a datalist.  I have the database set up with four tables.  The form will have choices in each of the tables for users to choose from.  The problem I am having where to even start with the code to make this possible.  I have the cosmetic part of it set up already.  I appreciate any help I can get on this.

View Replies !
How Search PDF File In The SQL Database ?
Hi guys, Now I  upload the PDF file and store it in the database as binary.  But  now I need to search the text in the PDF file. Is there any way I  can search the content  in the database ?   Anyone has any idea about it ?Thanks!Regards,Sam

View Replies !
Search Text In Database
Hi,I would like to use keywords inside a record to search for - like asearchengine.How can I design the table? Right now I would store data in Memo-Column in aformat like ";apple;banana;lemon;". I would use a INSTR(ring)-function - butI wonder if the performance is still OK then - even when I index the field.Are there maybe even better ways?Thanx in advance.Greg

View Replies !
To Search A Record In A Database
Hi,
I have a sql server database with 250 tables in it, i wanted to find one particular value from one of the tables in the database. How to find that appreciate your help..
Thanks

View Replies !
Search A Word In Database
Hi I was wondering if anyone can help me out here. I want to search a word in the database which has more than 80 tables is it possible to search all the tables at once for that word.

I am using SQL2005.

Thanks in advance.

View Replies !
Search Database For [expression]
Yep, I know this will have been asked before (because I've seen it), but I can't for the life of me find a thread!

So I've inherited this database and I need to search the whole darn thing for a single word, returning something lovely, like the table or column the thing resides in.
Basically it's a code in one of 100+ code tables, all with inconsistant, unclear naming - YAY!

FYI, I'm using SQL Server 200 and the word I'm looking for is "Unpaid".

Thanks guys, girls and gurus

View Replies !
Search Database Maintanance
Is there any speicial considerations when you prepare the maintanance Plan for the Search Database.

View Replies !
Search A String Throughout The Database
Hello
I have a Database which contains like 1000 Tables.
I am not the designer of that DB.So I need to in which table and which column
that string exists. IS there a DBWIDE String search possible?
Thanks and Regards

View Replies !
Dropdownlist Database Search
Hi all.

I have a huge problem that ive been sitting with for awhile.

I have a web page with 4 dropdownlist boxes on it

Gender:
Race:
Field:
Location:

Now a user can search a SQL db from selecting values from these 4 dropdownlist boxes which are equal to values in the db obviously.

when they have done that and pressed submit a Gridview is populated with the people corresponding details and the user is able to view each row seperately.

Now the problem i am having is that when i havent used all 4 selections for eg

Gender: null (no value selected)
Race: Black
Field: Accounting
Location: Los Angeles

then no information is returned from the db in the gridview.
im using a sqldatasource to populate the gridview and here is the query string that i am using :


Code:

sql
SELECT [title], [gender], [initials], [name], [surname], [birthdate], [postaladdress], [suburb], [city], [zipcode], [criminalrecord], [drivers], [maritalstatus], [dependants], [citizenship], [province], [contactref], [hometel], [cell], [jobtitle], [relocate], [emmigrate], [email], [worktel], [enddate], [startdate], [FIELD], [education], [company], [positionheld], [jobdescription], [contactperson], [contacttel], [startdate2], [contactperson3], [jobdescription3], [positionheld3], [company3], [enddate3], [startdate3], [contacttel3], [other] FROM [cvinformation] WHERE (([race] = CASE WHEN @race IS NOT NULL THEN @race ELSE [race] END) AND ([province] = CASE WHEN @province IS NOT NULL THEN @province ELSE [province] END) AND ([education] = CASE WHEN @education IS NOT NULL THEN @education ELSE [education] END))



what i want to do is whether the user doesnt choose any selection and leaves the choice null that ALL the information in the table of the db be shown and even if they only choose 2 values and leave the others null then it still brings back the information from the criteria chosen..

Is this possible.?

View Replies !
How To Search The Entry Of A Database
Hi.. May I know is there a way to search on all the tables in the DB whether any of them contain a entry like a IP address 10.10.10.10 ??

View Replies !
Search For Keyword In Database
Hii
 
I want to search for a keyword in the database.
The database has approximately 30 tables and the amount of data in tables is very large. Most of the tables hold 25000 rows. The search procedure for searching a keyword that i want to use is as below. When i executed the stored proc it took  20 minutes. What i want to know is full-text search a better option than this or is there any other way out.
 

CREATE PROC SearchAllTables

(

@SearchStr nvarchar(100)

)

AS

BEGIN

CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))

SET NOCOUNT ON

DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)

SET @TableName = ''

SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')

WHILE @TableName IS NOT NULL

BEGIN

SET @ColumnName = ''

SET @TableName =

(

SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))

FROM INFORMATION_SCHEMA.TABLES

WHERE TABLE_TYPE = 'BASE TABLE'

AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName

AND OBJECTPROPERTY(

OBJECT_ID(

QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)

), 'IsMSShipped'

) = 0

)

WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)

BEGIN

SET @ColumnName =

(

SELECT MIN(QUOTENAME(COLUMN_NAME))

FROM INFORMATION_SCHEMA.COLUMNS

WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2)

AND TABLE_NAME = PARSENAME(@TableName, 1)

AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')

AND QUOTENAME(COLUMN_NAME) > @ColumnName

)



IF @ColumnName IS NOT NULL

BEGIN

INSERT INTO #Results

EXEC

(

'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)

FROM ' + @TableName + ' (NOLOCK) ' +

' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2

)

END

END

END

SELECT ColumnName, ColumnValue FROM #Results

END
 

EXEC SearchAllTables 'FileName'

View Replies !
How To Search A Database By Paramaters
Hi,

Does anyone know how i go about writing a search query using paramaters, ive been using this as my template:
Select Distinct Recipedata.Name, Ingredients.Ingredient, Directions.Directions
from Recipedata,Ingredients,Directions
Where Ingredients.Ingredient Like '%Chicken%' and

RecipeData.RecipeID = Ingredients.RecipeID and Ingredients.RecipeID = Directions.RecipeID;

Problem is now that i want to use paramters instead of hard coded values as this is for a user. How do i go about this? This database has a VB2k5 front end for the desktop and PDA(and no the target PDA is not web enabled so web servcies arent available to me).

 

Thanks Much

 

 

 

View Replies !
Data Search In SQL Database
 

Hi, i want user to type a string in textbox, and i will search, if textbox.text exists in my SQL database table or not. Below is the code i'm using :---------------
 
 string txtname = (txtEmpName.Text).Trim();
 sQuery = "select * from tbUser where UserName='_username'";
 sQuery = sQuery.Replace("_username", txtname);
 SqlConnection objConnection = new SqlConnection(source);
 objDataAdapter = new SqlDataAdapter(sQuery,objConnection);
// DataTable dtTable = new DataTable();
 if (objConnection.State  == ConnectionState.Closed)
 objConnection.Open();
 objDataSet = new DataSet();
 objDataAdapter.Fill(objDataSet);
// objDataAdapter.Fill(dtTable);
 
or i want to search if "txtname" exists in "tbUser" table.
 
Thanks & Regards.
 
Manish S. Anand

View Replies !
Attribute Search In A Database
Hi guys,
 
I'm trying to find some attributes within a database I'm working with. I'm working with SQL Server 2000, and I'm trying to find table which have a certain attribute in them. for example, If I want to see tables from my database which have an attribute called 'home_address', what would the query be? Or is there an inbuilt function in SQL Server 2000 which allows me to search this?
 
Thank you!
 

 

View Replies !
Search Column Name In Database?
Hi all:

what i am trying to do is search one column name in whole database.  i used to achieve this by using Query Analyzer .

Can anyone tell me does this function available in SQL 2005?

Thanks

Nick

View Replies !
Search A Column In Database
Hi,

Can any one say how to search a particular column in a database so that the tables containing the column are listed

View Replies !
Want To Search The Whole Dang Database?
Hope I'm posting this the right way (newbie forum member)...

So, today I get this crazy request from a data migration team to search an ENTIRE database for a particular string value. The question goes something like this: "Hey, what's the syntax for searching the whole database for a string value? There are lots of tables and we know it's in one of them somewhere...Will 'SELECT * FROM *' work maybe?" You know, the really technical manager is asking. So I patiently explained to him that there really isn't a syntax in T-SQL directly for doing that and kinda walk out of the office for the day (they always ask you stuff like this at 5:08 pm).

While reading some excellent stuff on SQLTeam.com, particularly an article by graz (http://www.sqlteam.com/item.asp?ItemID=1283) on "Letting SQL Server Write SQL Statements" I was inspired to take the two-step approach to this problem. I'll bet some smarter person can make this into a one-stepper, but I have a quick solution that doesn't require the purchase of any fancy database management utility and will hopefully make my manager a happy person in the morning. I should mention (for anyone that missed this) this is not exactly the most efficient use of a database server and should be implemented in situations where there is only a little data in each table or you're the only user.

Here's the approach:
1. Use the INFORMATION_SCHEMA to get a list of all columns in all tables in your database that are CHAR, NCHAR, VARCHAR, or NVARCHAR types (sorry, TEXT and NTEXT won't work here).
2. In that same SELECT statement, use the COLUMN_NAME and TABLE_NAME to build a list of SELECT statements which will each query one column in the tables for the desired value.
3. Copy the results of your SELECT statement (text results, not grid) and paste them into a new Query Analyzer window. You can add a SET NOCOUNT ON at the top to reduce the output.
4. Once the series of generated statements executes, you'll have a line for each column in each table and the result of the individual table/column query. It's easy to scan for a YES! in the result (you could also modify the following to output nothing instead of NO).

Soo, you use:

DECLARE @SearchString VARCHAR(100)
DECLARE @Comparison VARCHAR(4)

-- Set this to whatever you want
SET @SearchString = 'Hanna Moos'

-- Set this to '=' or 'LIKE'
SET @Comparison = '='

SELECT 'SELECT (CASE WHEN (SELECT COUNT([' + c.COLUMN_NAME + ']) FROM [' + t.TABLE_NAME + '] WHERE [' + c.COLUMN_NAME + '] ' + @Comparison + ' ''' + @SearchString + ''') > 0 THEN ''[' + t.TABLE_NAME + '].[' + c.COLUMN_NAME + '] - YES!'' ELSE ''[' + t.TABLE_NAME + '].[' + c.COLUMN_NAME + '] - NO'' END)'
FROM INFORMATION_SCHEMA.TABLES t
INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME
WHERE t.TABLE_TYPE = 'BASE TABLE'
AND c.DATA_TYPE IN ('char', 'nchar', 'varchar', 'nvarchar')

to produce lines like this (the following is only a few columns from Northwind's Customer table):

SELECT (CASE WHEN (SELECT COUNT([CustomerID]) FROM [Customers] WHERE [CustomerID] = 'Hanna Moos') > 0 THEN '[Customers].[CustomerID] - YES!' ELSE '[Customers].[CustomerID] - NO' END)

SELECT (CASE WHEN (SELECT COUNT([CompanyName]) FROM [Customers] WHERE [CompanyName] = 'Hanna Moos') > 0 THEN '[Customers].[CompanyName] - YES!' ELSE '[Customers].[CompanyName] - NO' END)

SELECT (CASE WHEN (SELECT COUNT([ContactName]) FROM [Customers] WHERE [ContactName] = 'Hanna Moos') > 0 THEN '[Customers].[ContactName] - YES!' ELSE '[Customers].[ContactName] - NO' END)

which produce output like this:
-------------------------------
[Customers].[CustomerID] - NO

--------------------------------
[Customers].[CompanyName] - NO

--------------------------------
[Customers].[ContactName] - YES!

Hope this helps someone, it blew an hour of a perfectly good evening at home for me.

Cheers!

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved