Click here to Skip to main content
15,887,267 members
Home / Discussions / Database
   

Database

 
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 
GeneralRe: Inserting commas in database Pin
Hesham Amin30-Apr-04 22:14
Hesham Amin30-Apr-04 22:14 
GeneralRe: Inserting commas in database Pin
Jeff Varszegi1-May-04 9:29
professionalJeff Varszegi1-May-04 9:29 
GeneralSQL Named Instance Pin
vikramlinux29-Apr-04 18:02
vikramlinux29-Apr-04 18:02 
GeneralRe: SQL Named Instance Pin
Colin Angus Mackay30-Apr-04 9:51
Colin Angus Mackay30-Apr-04 9:51 
GeneralName and Data Type of all columns Pin
DotNet_Newbie29-Apr-04 11:08
DotNet_Newbie29-Apr-04 11:08 
GeneralRe: Name and Data Type of all columns Pin
Jeff Varszegi29-Apr-04 11:32
professionalJeff Varszegi29-Apr-04 11:32 
GeneralRe: Name and Data Type of all columns Pin
DotNet_Newbie29-Apr-04 11:56
DotNet_Newbie29-Apr-04 11:56 
GeneralRe: Name and Data Type of all columns Pin
Jeff Varszegi29-Apr-04 12:05
professionalJeff Varszegi29-Apr-04 12:05 
GeneralAuto Translate=False problem Pin
saglam29-Apr-04 5:38
saglam29-Apr-04 5:38 
GeneralRe: Auto Translate=False problem Pin
Mike Dimmick4-May-04 23:04
Mike Dimmick4-May-04 23: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.