Open / Read / Split / Insert / Repeat
Jul 11, 2006
Right now I have a web page that when you click on the only button on the page it opens a text file, reads a line from the text file, splits the comma separated line and stores it in to an array 'strData' and then moves on to the next line and repeats this process.
What I want to do before it goes to the next line is insert that strData in to a SQL DB.
This is my InsertCommand for my SqlDataSource1:
InsertCommand="INSERT INTO [Numbers] ([WTN], [DSL_Qualified], [DSL_Qualified_Date], [Equip_1MM], [Line_Trouble], [Sync_Rate], [Res_Bus], [Host_Remote]) VALUES (@WTN, @DSL_Qualified, @DSL_Qualified_Date, @Equip_1MM, @Line_Trouble, @Sync_Rate, @Res_Bus, @Host_Remote)"
Plus the <InsertParameters>:
<InsertParameters>
<asp:Parameter Name="WTN" Type="Int32" />
<asp:Parameter Name="DSL_Qualified" Type="String" />
<asp:Parameter Name="DSL_Qualified_Date" Type="DateTime" />
<asp:Parameter Name="Equip_1MM" Type="String" />
<asp:Parameter Name="Line_Trouble" Type="String" />
<asp:Parameter Name="Sync_Rate" Type="String" />
<asp:Parameter Name="Res_Bus" Type="String" />
<asp:Parameter Name="Host_Remote" Type="String" />
</InsertParameters>
So I'm not sure exactly what to do after this:
while (file.Peek() > -1)
{
string strCSVData = file.ReadLine();
string [] strData = strCSVData.Split(',');
// somehow get strData in to the SqlDataSource1.Insert method??
}
Any help would be appreciated.
Thanks.
View 1 Replies
ADVERTISEMENT
Sep 21, 2006
Hello
I'm working on a package which loops through each xml file in a folder.
The name of each xml file is put in variable.
The format of the filename is something like "part1_part2_part3.xml"
I need to store the 3 parts in three different columns of table A
The content of the xml file needs to be manipulated ("." needs to be replaced with ",", ....)and put in serveral columns in tableB
It's not clear to me yet how to start this but my main concern is read the three parts of the filename. I don't find any task in SSIS which could help me with that.
Could someone give me some pointers?
Many thanks!
Worf
View 3 Replies
View Related
Mar 26, 2008
Hi all,
How to Open Or read SQL Server log file .ldf
When ever we create database from sql server, it's create two file. (1) .mdf (2) .ldf.
I want to see what's available inside the .ldf file.
Thanks,
Ashok
View 6 Replies
View Related
May 9, 2008
Hi : Can any one send me the sql code for split and insert the strings in a table dynamically using stored procedure Thanks:suresh
View 3 Replies
View Related
Apr 4, 2014
I have a string stored in field v_images in table tbl_DealerFeed_temp. This string is split by the "|" character. I want to create a SQL query to grab this string, split it, and insert it into tbl_Vehicles_photos. I also need to pass the value d_id into the photos table:
tbl_Vehicles_photos:
vp_id, d_id, vp_image_name
The vp_id is the unique ID. I need to populate the d_id and vp_image_name field with my values.
View 1 Replies
View Related
Mar 12, 2008
Hello all,
I just wanted to know whether is it possible to use Bulk Insert and Conditional Split together for one transformation.
Regards,
Kapadia Shalin P.
View 3 Replies
View Related
Apr 17, 2014
I have a string which is delimited by commas:
Green,Red,Blue,Orange,Black,White
I need to create a SQL statement to read the string, split it at the "," character, and insert it into individual rows. I also need to insert an ID (the same for all split values).
For instance:
INSERT INTO tbl_Temp (unique_id, ID, color) VALUES (1, 999, Green)
INSERT INTO tbl_Temp (unique_id, ID, color) VALUES (2, 999, Red)
INSERT INTO tbl_Temp (unique_id, ID, color) VALUES (3, 999, Blue)
etc...
I would like to be able to do this all in one statement so I don't have to break it out into individual SQL statements.
View 4 Replies
View Related
Oct 13, 2004
I am passing in a string of dates, delimited by a comma.
So
01/01/04, 02/01/04, 03/01/04
etc
I would like to enter each of these values into a table via an INSERT stored procedure.
Does anyone have any code for this?
View 1 Replies
View Related
Oct 19, 2012
I have an empty employee table and employee_details table. The temp table which i created say it has 10 columns of which 6 are from employees and 4 from employee_details. I have loaded some data into temp table say 10 rows.
Now the stored procedure using cursor should be created such that, it should fetch the rows one by one from temp table and insert the values into employee table(6 columns) and the rest in employee_details table(4 columns).
This is the scenario.
Here is the column names of my temp table
CREATE TABLE [dbo].[temp](
[employee_id] [char](7) NOT NULL,
[first_name] [char](50) NOT NULL,
[middle_name] [char](50) NOT NULL,
[last_name] [char](50) NOT NULL,
[title] [char](5) NOT NULL,
[Code] ....
Here the last 4 columns belong to the employee_details table. The stored procedure should fetch record by record from temp split and insert into employee and employee_details table.
View 1 Replies
View Related
Aug 20, 2015
I have a string ,want to split the values after every space as column value and insert them into a table
1306453 0 0 0 0 0
col1 col2 col3 col4 col5 col6
1306453 0 0 0 0 0
View 7 Replies
View Related
Aug 28, 2007
Hi
I am using conditional split Checking to see if a record exists and if so update else insert. But this cause database dead lock any one has suggestion?
Thanks
View 7 Replies
View Related
Jun 5, 2006
Hi, Anybody has an example of reading a csv comma delimited file and insert the fields into a datatable?Thanks
View 2 Replies
View Related
Mar 21, 2008
Hi, I was wondering which is the best way to read data from a txt file and insert each row into sql.
OLE DB Command could be? It will be necesary to work with variables?
My txt file will have a defined width (if it is necessary to know). I will have many rows with many columns. I have to map eah column from the txt file to it's corresponding column in sql server and insert data into it for each row.
Thanks for your help!
View 7 Replies
View Related
Jul 27, 2007
Hi,
My procedure to implement a task is like this
I will be using execute SQL task to fetch the records from source,after this wanna use For each loop to access each record one at a time,perform some trnsformations and insert that record into destination.
Help me in accessing the data stored in the Variable(SQL task) in Dataflow task of foreach loop.
View 10 Replies
View Related
Nov 6, 2014
i have a linked server that i use a variable to get the last invoice date and only pull in the latest records that are after the last invoice date but i dont know how to insert that into a table?
DECLARE @TSQL varchar(MAX), @LastDate As Datetime, @LastRunDate As Varchar(6)
SET @LastDate = (SELECT MAX(OrderDate) FROM [SYNC_REPORT].[DPY_SyncReport_Prod].[Stage].[Sales])
Set @LastRunDate = ( select right(convert(char(4), year(@LastDate)), 2) + right('000' + convert(varchar(3), datediff(dd, convert(datetime, '01/01/' + convert(char(4), year(@LastDate))), @LastDate+1)), 3) +100000 )
[code]....
but i get msdtc on server xxxxx is unavaiable?how to get my linked server query into my table
View 3 Replies
View Related
Aug 8, 2000
hello!
i'm an sql server beginer. i was wondering if some of you guys can help
me out. i need for the sql server to be able to read an outside file (just text) and be able to run a script that will insert it in the database. it's a dcc output file. we've tried running this script:
DROP TABLE tests
go
DECLARE @SQLSTR varchar(255)
SELECT @SQLSTR = 'ISQL -E -Q"dbcc checkdb(master)"'
CREATE TABLE tests (Results varchar(255) NOT NULL)
INSERT INTO tests EXEC('master..xp_cmdshell ''ISQL -E -Q"dbcc checkdb(master)"''')
and it's running good but the problem is the results of the dbcc here did not come from a file but directly after executing the dcc command. is there a way to do it?
thank's for the help!
View 1 Replies
View Related
Mar 28, 2008
hi my friends
i want read data from text file,and write to my table in sql,
please help me
M.O.H.I.N
View 6 Replies
View Related
May 6, 2015
I have a requirement to
a. Read data from Different CSV files.
b. insert and update data to Data base in multiple table using joins.
This execution runs for 1-2 hours.I can use C# with Ado.net, but only concern I see is if in between execution fails due to some connection or other error. All insert data has to be cleaned up again.I feel writing and Store procedure inside transaction, which will take path's for CSV file as input and insert data in database. using transaction we will have flexibility rollback to original state.
View 9 Replies
View Related
Mar 19, 2007
Hello,Would it be possible to open a socket connection and send few data based on an insert TRIGGER?My client would basically like to send the ID of a product via socket connection when a new product is inserted into the SQL database.Thanks for your helpArnold
View 13 Replies
View Related
Feb 24, 2014
Insert data to database foxpro using open query. I already create connection like below
@server = 'EXIMBIL_LINK',
@provider = 'MSDASQL',
@srvproduct = '',
@provstr = 'Driver={Microsoft Visual FoxPro Driver}; UID=;SourceDB=D: raining_testdata;SourceType=DBF ;Exclusive=No;BackgroundFetch=Yes'
when i try to show table van with command :
select * from openquery(EXIMBIL_LINK,'select * from van')
It show query running well but when i try to insert new row to table van with command :
INSERT into OpenQuery(EXIMBIL_LINK, 'SELECT c_user_id,c_user_name,full_name from van')
VALUES('1000007668','IDMTEST2','IDMTEST2')
throws error like this : Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done
View 1 Replies
View Related
May 25, 2007
Hai Everbody,
for me in my project i want to read data from a csv file and insert it in a sql server databse table.The csv file may contain n number of columns,but i want only certain columns from that, and insert it in the database table.How to achieve this. Plz help me it is urgent. Thanks in advance.
Thanks and regards
Biju.S.G
View 1 Replies
View Related
Mar 24, 2008
Hi,
I have load a CSV file into one of the table in sql server 2005 using bulk insert command. But the csv file in remote system.
Please help me.....
View 1 Replies
View Related
Jul 18, 2007
Hi again all,
Is there a way to read a file name automatically from a network folder? I can successfully bulk insert from this particular folder. The next step is as I add files, I wish to bulk insert the latest file added so the program must make that determination and import that specific file. I can delete the older files if necessary and save them elsewhere but it would still be nice to be able to read the file name. I then wish to store the name of this file, whatever it is, into a field called "SourceFileName" in my table that I am bulk inserting into. Does anyone have an example in dynamic SQL? Thanks.
ddave
View 1 Replies
View Related
Apr 23, 2008
I am using Microsoft SQL 2005, I need to do a BULK INSERT from a .csv I just downloaded from paypal. I can't edit some of the columns that are given in the report. I am trying to load specific columns from the file.
bulk insert Orders
FROM 'C:Users*******DesktopDownloadURL123.csv'
WITH
(
FIELDTERMINATOR = ',',
FIRSTROW = 2,
ROWTERMINATOR = ''
)
So where would I state what column names (from row #1 on the .csv file) would be used into what specific column in the table.
I saw this on one of the sites which seemed to guide me towards the answer, but I failed.. here you go, it might help you:
FORMATFILE [ = 'format_file_path' ]
Specifies the full path of a format file. A format file describes the data file that contains stored responses created using the bcp utility on the same table or view. The format file should be used in cases in which:
The data file contains greater or fewer columns than the table or view.
The columns are in a different order.
The column delimiters vary.
There are other changes in the data format. Format files are usually created by using the bcp utility and modified with a text editor as needed. For more information, see bcp Utility.
View 12 Replies
View Related
Sep 27, 2012
Is there a way to open EDI file in SQL Server and insert the data into tables?
View 9 Replies
View Related
Apr 4, 2015
I am inserting updating few tables from snapshot and reading same bunch of tables from reporting using readcommitted . It is showing some deadlocks i think it is write in this situation as " x" is not compitable with "s" ,"is".
View 4 Replies
View Related
Apr 29, 2015
I've a dataflow task on For Each Loop container at control flow of SSIS package. This For Each Loop container reads the CSV files from the specified location one by one, and populates a variable with current file name. Note, the tables where I would like to push the data from each CSV file are also having the same names as CSV file names.On the dataflow task, I've Flat File component as a source, this component uses the above variable to read the data of a particular file.
Now, here my question comes, how can I move the data to destination, SQL table, using the same variable name?I've tried to setup the OLE DB destination component dynamically but it executes well only for first time. It does not change the mappings as per the columns of the second CSV file. There're around 50 CSV files, each has different set off columns in it. These files needs to be migrated to SQL tables using the optimum way.
Which is the best way to setup the Dataflow task for this requirement?Also, I cannot use Bulk insert task here as we would like to keep a log of corrupted rows.
View 10 Replies
View Related
Sep 1, 2002
Hi all,
I'm new to SQL Server 2000. There are certain record that always return a repeated data in a colomn.
I'm using a very simple sql command. Just select.
In quetry analyser it always return a repeated data.
Thanks for help
View 2 Replies
View Related
Jun 22, 2006
Hi all
I am new in the forum and in SQL
I have this code
Code:
SELECT
PersPlac.Name,
Zoom1.Descr,
Client.PersonID,
Client.Name AS CLIENT_NAME,ClientCu.Period,ClientCu.YearID,IVPeriod.PrdDescr,(ClientCu.DebitP/((InvVAT.VATVal+100)/100)),InvVAT.VATVal
FROM Client
RIGHT JOIN Salesman WITH (READUNCOMMITTED)
ON (Client.SalesmanAA = Salesman.AA)
LEFT JOIN PersPlac WITH (READUNCOMMITTED)
ON (Client.Place = PersPlac.Code)
LEFT JOIN Zoom1 WITH (READUNCOMMITTED)
ON (Client.Zoom1 = Zoom1.ID)
LEFT JOIN CLIENTCU WITH (READUNCOMMITTED)
ON (CLIENT.PERSONID=CLIENTCU.PERSONID)
RIGHT JOIN InvVAT WITH (READUNCOMMITTED)
ON (CLIENT.TAXCAT=InvVAT.TAXCAT)
RIGHT JOIN IVPeriod WITH (READUNCOMMITTED)
ON (ClientCu.Period = IVPeriod.PeriodID)
WHERE Salesman.Name='ΚΟΡΜΠΟΣ ΦΩΤΙΟΣ'
AND ClientCu.Period<>0
AND PersPlac.Name<>'Εικονική Γεωγρ. Περιοχή'
AND Client.Name='ΦΩΤΕΙΝΙΑ ΑΝΝΑ'
and InvVAT.VATVal in (13,19)
the code run fine but every line is turn back 4 times.
Why?
Thanks for the help
View 2 Replies
View Related
Jun 26, 2007
After finally overcoming a number of hurdles with LisaNicholls help, I've got one hurdle left that I can't seem to get around. A system I'm updating currently outputs attendance registers in HTML which is built using some complex ASP.NET code. To make this more manageable, I decided to try and handle this output in Reporting Services.
Whilst the output looks fairly inocious and simple, in theory it's been a nightmare to implement. Because it's inteded for print output, my intention was to output the report straight to PDF, however I'm encountering an issue trying to get some of the data to "repeat" on each of the PDF pages.
If you look at the following image; http://mparter.pwp.blueyonder.co.uk/images/register_page.png, you'll see 4 main areas.
The problem areas are the red, green and blue ones.
The unmarked bottom section is a matrix which pages fine on PDF.
The TEXBOXES in the red area can possibly be worked-around by using report parameters.
The TABLES in the blue and green areas are the main problem. I can't include them in a report header workaround because there could be multiple rows per table
So, back to my question, how do I get the three marked coloured areas to repeat on each "page" of the PDF?
View 3 Replies
View Related
Nov 14, 2007
Hi all,
I am designing a mailing label report. I put the client info. on a sub-report.
I want to use a parameter to input the label amount and sub-report will be repeated by that amount.
How can I implement this?
TIA
Micror
View 4 Replies
View Related
Sep 27, 2007
This may get brought up again and again, but I don't know how to deal with it by heart yet... in fact I mean to say, I don't know how to deal with it.
With the given data set how do you only return one of the 2 rows where a given user ate the same fruit?
apples gregpeach greglemon gregapples greg
peach brucepeach brucelemon bruceapples bruce
pear paulpeach paulplumb paulplumb paul
apples barbpeach barblemon barbpear barb
What T-SQL is needed to produce the following dataset?
apples gregpeach greglemon greg
peach brucelemon bruceapples bruce
pear paulpeach paulplumb paul
apples barbpeach barblemon barbpear barb
View 2 Replies
View Related
Oct 21, 2006
hi guys,
In reporting services i have a table and below which i have a chart. The table has lot of values so the report spans multiple pages. I have set page breaks such that the table displays only 10 records. After all the values have been displayed in the last page the chart is displayed. I want the chart to display in each and every page of the report. It is the same chart that i want to display. How do i do this?
plz can anyone give me ideas.
Thanks,
Sai Abhiram Bandhakavi
View 3 Replies
View Related