Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Text Import and Search

Author  Topic 

ashkot
Starting Member

3 Posts

Posted - 2012-03-06 : 12:36:50
Hi there,
I have several small text files (10MB ~ 20 MB) and I want to search through them. Since searching via .NET code might not be the easiest, i though of imperting them into SQL Server using TEXT field.

Are there any downsides to doing this?

Can this cause the database to crash at some time?

Also, what is the best way to query a text field.

Thanks in advance.

Ashwin

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-06 : 12:50:22
Maybe



CREATE TABLE txtSearch_Stage([Data] varchar(max))
CREATE TABLE txtSearch([Row_ID] int IDENTITY(1,1),[Filename] varchar(256), [Data] varchar(max))
GO

TRUNCATE TABLE txtSearch_Stage

BULK INSERT txtSearch_Stage FROM 'D:\SPROC_EXEC_XML.SQL'
WITH (
DATAFILETYPE = 'widechar'
)
GO

INSERT INTO txtSearch ([FileName], [Data])
SELECT 'D:\SPROC_EXEC_XML.SQL', [Data]
FROM txtSearch_Stage

SELECT * FROM txtSearch
WHERE [Data] Like '%e%'
GO

DROP TABLE txtSearch, txtSearch_Stage
GO




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -