Click here to Skip to main content
15,896,154 members
Home / Discussions / Database
   

Database

 
Generaldetach database Pin
Dpriya3-May-04 23:58
Dpriya3-May-04 23:58 
GeneralRe: detach database Pin
Mazdak4-May-04 5:38
Mazdak4-May-04 5:38 
QuestionHow I access database through a Map Network drive? Pin
ATC3-May-04 8:13
ATC3-May-04 8:13 
AnswerRe: How I access database through a Map Network drive? Pin
Mike Ellison4-May-04 8:31
Mike Ellison4-May-04 8:31 
Questionhow to put an image in sql database Pin
Member 7402202-May-04 11:15
Member 7402202-May-04 11:15 
AnswerRe: how to put an image in sql database Pin
Mazdak2-May-04 21:22
Mazdak2-May-04 21:22 
QuestionHow to convert null dates to String? Pin
Anonymous1-May-04 15:46
Anonymous1-May-04 15:46 
AnswerRe: How to convert null dates to String? Pin
Jeff Varszegi1-May-04 15:59
professionalJeff Varszegi1-May-04 15:59 
AnswerRe: How to convert null dates to String? Pin
-Dr_X-8-May-04 15:57
-Dr_X-8-May-04 15:57 
GeneralPreserve formatting and storing in Database Pin
Anonymous1-May-04 8:48
Anonymous1-May-04 8:48 
Generalquerying XML database Pin
ranadinesh1-May-04 0:47
ranadinesh1-May-04 0:47 
GeneralConnection Pool Pin
Albert Pascual30-Apr-04 13:24
sitebuilderAlbert Pascual30-Apr-04 13:24 
GeneralRe: Connection Pool Pin
Anonymous30-Apr-04 14:03
Anonymous30-Apr-04 14:03 
GeneralRe: Connection Pool Pin
Jeff Varszegi1-May-04 9:34
professionalJeff Varszegi1-May-04 9:34 
GeneralRe: Connection Pool Pin
Mike Dimmick4-May-04 5:45
Mike Dimmick4-May-04 5:45 
GeneralRe: Connection Pool Pin
Jeff Varszegi4-May-04 5:54
professionalJeff Varszegi4-May-04 5:54 
GeneralTrigger, extended SP, send message to a service Pin
cmk30-Apr-04 8:38
cmk30-Apr-04 8:38 
GeneralUrgent Please !!! Stored Procedure to read data from all kinds of files Pin
Wilbur J. Pereira30-Apr-04 0:38
Wilbur J. Pereira30-Apr-04 0:38 
Hey guys,
I need a stored procedure which could read data from all types of files and then print the data or store it in a table. i have tried bulk insert but when bulk insert reads the data and stores it in a table it creates many rows (.i.e rows = number of lines in the files). say if there are 20 lines then 20 rows and if 700 lines 700 rows. I want to store the data in one string and print it. Also the files i need to read are generated on runtime. If u want to take a look at the Sto. Proc. here it is. Please note files culd be of any size.
**********************************************************
1. Bulk insert
CREATE PROC sp_readTextFile @filename sysname
as
BEGIN
SET nocount ON
EXEC ('bulk INSERT WilTemp FROM "' + @filename + '"')
SELECT * FROM WilTemp
END
GO

***********************************************************
2. Using a filesytem object

CREATE PROCEDURE [dbo].[readFromFile] (@FileName varchar(255))
AS
DECLARE @FS int, @OLEResult int, @FileID int, @Text1 varchar(8000)

EXECUTE @OLEResult = sp_OACreate 'Scripting.FileSystemObject', @FS OUT
IF @OLEResult <> 0 PRINT 'Scripting.FileSystemObject'

--read a file
execute @OLEResult = sp_OAMethod @FS, 'OpenTextFile', @FileID OUT, @FileName, 1
IF @OLEResult <> 0 PRINT 'OpenTextFile'

--Read Text1
execute @OLEResult = sp_OAMethod @FileID, 'ReadAll', @Text1 OUT
IF @OLEResult <> 0 PRINT 'ReadAll'

--insert into tfromfile values (@Text1)
Print @Text1

EXECUTE @OLEResult = sp_OADestroy @FileID
EXECUTE @OLEResult = sp_OADestroy @FS
GO
GeneralInserting commas in database Pin
Anonymous29-Apr-04 22:54
Anonymous29-Apr-04 22:54 
GeneralRe: Inserting commas in database Pin
Colin Angus Mackay29-Apr-04 23:56
Colin Angus Mackay29-Apr-04 23:56 
GeneralRe: Inserting commas in database Pin
Anonymous30-Apr-04 7:52
Anonymous30-Apr-04 7:52 
GeneralRe: Inserting commas in database Pin
Colin Angus Mackay30-Apr-04 9:47
Colin Angus Mackay30-Apr-04 9:47 
GeneralRe: Inserting commas in database Pin
Anonymous30-Apr-04 14:00
Anonymous30-Apr-04 14:00 
GeneralRe: Inserting commas in database Pin
Anonymous30-Apr-04 14:01
Anonymous30-Apr-04 14:01 
GeneralRe: Inserting commas in database Pin
Colin Angus Mackay30-Apr-04 14:04
Colin Angus Mackay30-Apr-04 14:04 

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.