|
Thank you mark,
I have manged to copy the file from the FTP task to the local Pc where SQl is running.However now would like to update my table with the Bulk Insert task in to the table.
How will I make sure that every 30 Minutes its getting a new file from the Ftp and then Insert it to My table in Sql2005.No Duplicated data will be enterd in to the table more than once.
As I am dumping the file on two one folder how will the bulkinsert task remembers this file is used and the other one is going to be used.
Thank you
|
|
|
|
|
Create a data flow task. Use the flat file transform as your source and either Sql Server destination or OleDb destination transform. I personnally don't like the Sql Server destination because it seems buggy to me.
If you want to prevent duplicate data you have a couple options:
1) create an empty table you can load using the data flow task. Then use a sql command to copy the data from the loading table into your target for all records which don't exist in the target. I recommend that you include a step to truncate your loading table before loading it will data. This option is probably the easiest if you're not familiar with SSIS and will probably perform best if you are working with a large dataset.
2) Add a lookup transform to your data flow task to match existing records from your target table with records in your flat file source. Then redirect any errors (ie. records which don't match, thus don't exist already in your target) to your destination transform.
3) Use 2 source transforms, one for your flat file source and one for your target table. Then use a merge transform and use it to filter any matches and return only records which don't have a match. Then pass the results to your destination transform.
Options 2 and 3 may not be viable if your target table is large, unless you have a way to filter the data for the lookup/merge. Like if you can filter the data by a date range or by some foreign key based on your knowledge of the data that is in your flat file source.
Hope this helps
|
|
|
|
|
Your Help is much appreciated,
What i want mark now is how to select files that are not picked up from the Ftp site and only load them as they are not copied.
That is to say for instance You Have a file name : -- 20080430_11.csv file generated from Ftp site at 11 O'clock today.
and --20080430_12.csv for 12 hours ftp.
How will the FTP task remembers that it has copied one file but not another one?
Thank you once again.
Reagrds
modified on Wednesday, April 30, 2008 11:53 AM
|
|
|
|
|
You could use another FTP task to delete the file after you're done. Or you could try and rename it. I don't know if that is directly supported, but if you have permissions you could possibly rename your local copy when you're done, then upload it back to the ftp server and delete the original copy from the server.
You could try and keep a local list of files you're already processed if you don't have permissions on the FTP server and use that to determine which files need to be downloaded and processed.
|
|
|
|
|
Is it possible to restore the (SQL Server 2000)database in SQL Server 7.0?
How to do this?
Thank ^^
|
|
|
|
|
I'm sure you could use the database copy wizard or DTS, but I'm not sure about attach/detach or backup/restore. I would try to set the database compatibility level to match 7.0, if there are no problems then you might be able to try either detach/attach or backup/restore method.
But first, before you do anything else, make a backup of your database in 2000 so you can restore it to the same state in case something goes wrong.
|
|
|
|
|
You cannot restore a backup, nor attach files from an SQL 2000 database to an older Server instance. This works in the older to newer direction (the database gets upgraded automatically), but never in the reverse. Your only choice is to export the data (with BCP, for example), and import into an empty SQL 7 database.
modified on Wednesday, April 30, 2008 10:26 AM
|
|
|
|
|
i have to create a generic stored procedure which accept XML as parameter in which root element contain the table name & inside tags are there field name with values like
<product>
<id>1
<desc>mobile
<price>4500
if the a xml is like above then data shoiuld be inserted in Product table in product.id,product.desc,product.price & so on
how can i read xml tags inside stored procedure
please help me in the above issue
thanxs
|
|
|
|
|
Lot of informations [^] just by simple google search.
I Love T-SQL
|
|
|
|
|
i have tried google but i dont find the appropriate result
by the way
thankx
|
|
|
|
|
Hi,
I am in the process of trying to find out what is the best practise for generating reports from an sql database useing different tables, that would be usefull to user on the Software access the DB, how do you do it? I come from a web design background and are now having to design a reporting engine for an ancient VB 6 application i have been lumped with....
I am used to having to build each report manually in html line for line and writting the formatting out in code, using sql querys for getting the data I need. but this is hard crap work and I would like to know if I am the only one doing it this way or do you have another way of doing it using some kind of report builder like crystal reports.
Its just there must be a better and faster way to get usefull reports from a db without the hard work building every line in the report from different querys and functions that jump all over the place in your application and db.
your insiteful comments will be greatly appreciated...
|
|
|
|
|
If you're programming under .NET, I would suggest to use Microsoft's Reporting Technology (I think Crystal Report is a little more complicated, but that's just my personal opinion). It's easy--all you have to do is to design a report (Add new item -> Report), create an instance with parameters and attach it to your program. You don't have to worry about print margins or layout. They can be set by changing some variables, unlike HTML, which you'd have to mess with CSS. This is especially useful when you have to print labels.
Plus, The Reporting Technology and Crystal Report comes with VS2005. If you're programming .NET you should have them installed already.
|
|
|
|
|
Hi, I have a table that lists the incomes and expenditures of various organizations.
<br />
Organization | Report Year | Income | Expenditure<br />
Org 1 | 1/4/2008 | £20 | £30<br />
Org 1 | 1/4/2007 | £20 | £30<br />
Org 2 | 1/4/2003 | £20 | £30<br />
Org 2 | 1/4/2002 | £20 | £30<br />
Org 2 | 1/4/2001 | £20 | £30<br />
Org 3 | 1/4/2006 | £20 | £30<br />
Org 4 | 1/4/2002 | £20 | £30<br />
I have been trying to write a query that will return the latest record for each organization. So the result would be
<br />
Org 1 | 1/4/2008 | £20 | £30<br />
Org 2 | 1/4/2003 | £20 | £30<br />
Org 3 | 1/4/2006 | £20 | £30<br />
Org 4 | 1/4/2002 | £20 | £30<br />
Tried searching but came up with no uselful answers. Can someone help? It needs to be compatible with Microsoft Access
|
|
|
|
|
here it is :
select distinct organisation,<br />
(select top 1 t1.rerportyear from myTable as t1 where t1.organisation = myTable.organisation order by rerportyear desc) as reportYear,income,expenditure<br />
from myTable
I Love T-SQL
|
|
|
|
|
Hi
Try this:
SELECT<br />
Organization,<br />
[Report Year],<br />
[Income],<br />
[Expenditure]<br />
FROM <br />
Table1 a <br />
WHERE [Report Year] >=<br />
(<br />
SELECT TOP 1 <br />
[Report Year]<br />
FROM <br />
Table1 b <br />
WHERE <br />
a.Organization = b.Organization <br />
ORDER BY [Report Year] DESC<br />
)<br />
ORDER BY <br />
Organization
Hope you are getting results as expected.
Harini
|
|
|
|
|
Thanks for replying blue_boy and harini. I used blue_boys solution in the end and it works as i want it. it actually fits into another much longer sql statement.
|
|
|
|
|
Glad to help you...
I Love T-SQL
|
|
|
|
|
I have an application under test, where I iteratively reset an export batch and then run the export for different configurations. For major testing, I wish to test each config over the full monty, 70k documents exported, but for dev testing I like to keep the rows in each section down to 500. Last night in the interests of not breaking code, I was popping ‘TOP 500’ into each query, but I’m sure there is a better way. Any suggestions will be appreciated. I’m using a SqlDataAdapter to fill my DataTable objects.
|
|
|
|
|
hai,
i m using SQL server 2000.
i have 3 columns A,B,C respectively. the columns consist of the following values.
Col-A: a,b,c,d,e,f,g,h,i,i,i,i,i
Col-B: j,k,l,m,n,o,p,q,r,i,r,r,r
Col-C: s,t,u,v,w,x,y,z,a,b,c,n,s
I need the output as
Col-D: a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
Note : Commas are not needed. just in row-wise
i.e, i want to combine 3 columns and want to remove the REPEAT values,NULL and EMPTY
how to achieve it? - KARAN
|
|
|
|
|
here it is my quick solution:
select distinct cola <br />
from myTable<br />
union all<br />
select distinct colb from myTable where colb <> (select top 1 cola from myTable order by cola desc)<br />
union all<br />
select distinct t3.colc from myTable as t3 where t3.colc <='z' and t3.colc >(select top 1 colb from myTable order by colb desc)
I Love T-SQL
|
|
|
|
|
thanks blue_boy.
but all the three columns is in the same table and i dt know the last value whether the last value is "z" or anyother (since, i cant understand {t3.colc <='z'} statement)
|
|
|
|
|
Instead harcoded 'z' condition then modified query looks like this:
select distinct cola <br />
from myTable<br />
union all<br />
select distinct colb from myTable where colb <> (select top 1 cola from myTable order by cola desc)<br />
union all<br />
select distinct t3.colc from myTable as t3 <br />
where t3.colc <=(select top 1 colc from myTable order by colc desc)<br />
and t3.colc >(select top 1 colb from myTable order by colb desc)
result of this query comes from one table in my case named myTable
I Love T-SQL
|
|
|
|
|
wwowooow.... awosome...... my friend! thats working fine! i achieved 99% of my result. thanks a lot. But the thing here i have some EMPTY values (i.e, string without any values(string count is 0)). how to remove these?.. expecting your reply so as to fulfil my work in 100%
|
|
|
|
|
which column return empty text?
I Love T-SQL
|
|
|
|
|
The Final result should not contain any NULL or EMPTY values..................
Now the NULL is removed. how about the EMPTY?
|
|
|
|
|