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 2005 Forums
 Transact-SQL (2005)
 Query correction required urgent

Author  Topic 

Sindbad
Starting Member

5 Posts

Posted - 2008-05-25 : 04:58:32
Hi All,

First of all its very very urgent. Secondly I am not an expert.

Now here is my problem.

I want to loop through my html files and want to save the data in my table column. here is the Code which need correction.

CODE:
USE [AdventureWorks]
DECLARE @cmd varchar(1000);
DECLARE @FileName varchar(100);
DECLARE @FilePath varchar(100);
SET @FileName = 'C:\test'+@FilePath+'html';
SET @cmd = 'INSERT INTO myTable(FileName, FileType, Document)' +
'SELECT ' + @FilePath + ', FileType,
* FROM OPENROWSET(BULK @FileName, SINGLE_CLOB) AS Document'

EXEC (@cmd);
Select * from myTable

Just for practice I am using Adventureworks db. I am using SQL Express 2005.

My html files are named something like this:

AC0234.html
DB9803.html
CG4571.html

I cannot change my file names.

Thanks in advance.

Regards;

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-25 : 06:59:15
May be this:-
USE [AdventureWorks]
DECLARE @cmd varchar(1000);
DECLARE @FileName varchar(100);
DECLARE @FilePath varchar(100);
SET @FileName = 'C:\test'+@FilePath+'html';
SET @cmd = 'INSERT INTO myTable(FileName, FileType, Document)' +
'SELECT ''' + @FilePath + ''', FileType,
* FROM OPENROWSET(BULK '+ @FileName +' , SINGLE_BCLOB) AS Document'

EXEC (@cmd);


b/w How will you be assigning values to @FilePath?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-05-26 : 05:03:46
You can find some examples here also
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -