|
I think 'Insert into' query will help you
|
|
|
|
|
Hi All,
I have an SSIS package, which is trying to import data from a flat file in to a destination table in SQL. But the problem is not all columns in the destination table should come from flat file, there are few columns that should be filled from some other SQL Server source table.
Can we import data from a flat file and a table simultaneously into one table, is so how can we do that?
Please help me, its urgent. I am also searching but any help like code snippet, link or even a free advice is great.
Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Change your strategy to ELT, import your data into a staging table that is an exact match for the source, all varchar columns!
The use a stored proc to transform the data into your final table. This method NEVER fails in the load process because of missing columns or date formats or a number has a $ sign.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Have a five.
Be excellent to each other. And... PARTY ON, DUDES!
Abraham Lincoln
|
|
|
|
|
Dammed if I know why someone would down vote this it is a perfectly valid question - balanced.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Is Entity Framework is best choice for database creation and manipulation in Web application which is made on MVC4.
If yes then how is it ?
|
|
|
|
|
NO the best way is to roll your own DAL layer. You will then have the knowledge and control to manage your data. EF is too much of a black box for my taste.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Well said: I used it on a couple of projects but have now gone back to ADO and my own DAL as it gives me more control and I don't feel that ORMs are the be-all and end-all.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
Those who seek perfection will only find imperfection
nils illegitimus carborundum
me, me, me
me, in pictures
|
|
|
|
|
hi to all
how to union two below query
thanks in advance
SELECT
dailyAbsences.*,'غیبت' as [RowType], '0' as [RowTypeCode]
INTO
#fullPersonnelDetails2
FROM
#personnelWorkingPeriodRange personnelWorkingPeriodRange
INNER JOIN dbo.tkp_vwDailyAbsences As dailyAbsences
ON dailyAbsences.PersonnelBaseID = personnelWorkingPeriodRange.PersonnelBaseID
And dailyAbsences.StartDate >= personnelWorkingPeriodRange.StartDate
And dailyAbsences.EndDate <= DateAdd(day, 1, personnelWorkingPeriodRange.EndDate)
LEFT JOIN tkp_CalculationQueue As calculationQueue
ON dailyAbsences.PersonnelBaseID = calculationQueue.PersonnelBaseID
And calculationQueue.StartDate <= personnelWorkingPeriodRange.EndDate
ORDER BY
dailyAbsences.PersonnelBaseID,
dailyAbsences.StartDate
UNION
SELECT
'اضافه کاری' as [RowType], '1' as [RowTypeCode]
FROM
dbo.tkp_DailyStatistics dailystatistics
WHERE
dailystatistics.ActualExtraWork > dailystatistics.ExtraWork AND
dailystatistics.PersonnelBaseID = @PersonnelBaseID AND
dailystatistics.WorkingPeriodID = @WorkingPeriodID AND
dailystatistics.YearWorkingPeriodID = @WorkingPeriodYear
IF EXISTS ( SELECT * FROM tempdb..SYSOBJECTS WHERE Name = '#PersonnelWorkingPeriodRange' and xType = 'u')
DROP TABLE #PersonnelWorkingPeriodRange
|
|
|
|
|
Your 2 select statements do not have the same number of columns - union requires the 2 queries to match exactly. dailyabscence.* is not in your 2nd query.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Also using * is not advised. Technically okay but it is better to spell out the columns.
|
|
|
|
|
I think using .* is the least of his problem if he does not understand the structuring of a union query. He obviously has not even glanced at the BOL doco for union so expecting him to understand a more subtle issue of using * is probably asking a little too much.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I agree. I was just pointing out one of many things to look at.
|
|
|
|
|
Hi,
I would like to ask if I have a query like this:
SELECT * FROM member
which one is better to use specially performance wise, stored procedure or views?
Technology News @ www.JassimRahma.com
|
|
|
|
|
Neither; it's fine the way it is. There may be other reasons to choose to write a view or a procedure, but performance generally isn't one of them.
|
|
|
|
|
If you're going to use SELECT * FROM ... rather than an explicit list of columns, you should be aware of this potential problem with views[^]: any changes to the underlying table will not be reflected in the view unless you explicitly refresh it.
Since your application is likely to expect a specific list of columns, it's always better to selected them explicitly. The SELECT * FROM ... syntax should only be used for temporary ad-hoc queries when you're exploring the data.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: ...will not be reflected in the view unless you explicitly refresh it.
Select * is a problem regardless of how it originates.
|
|
|
|
|
my suggestion is stored procedure. its create execution plan while create the procedure.
|
|
|
|
|
Based on the performance considerations, the SPs are more versatile and allow a broader range of inquiries and actions than the views.
|
|
|
|
|
in mysql database i implemented simple query on 1 like select * from dbo.company limit 2 .it taking tomuch time.except that table remaning all tables are working well.
in that table records also very less.i try to editing,droping,deleting any thing it is not responding.any one know answer Please give answer.
|
|
|
|
|
Member 9671482 wrote: Please give answer. Fetching a lot of data takes a lot of time. There's no cure for that, other than fetching less.
Here's some idea's you can try if you need more speed;
- verify and update the indexes (what fields are you using in your search?)
- look into (horizontal) paritioning
- select fewer columns (are you really using them all?)
- execute the optimize table[^]-command to compact the table (if deleted a lot recently)
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi i need some help creating an sql script that can update info from one table in dbase1 to another table in dbase2 that has the same columns and if posible insert date and time in one column when the syncronized is done in the table thats modified? Can anyone help me whit this?
|
|
|
|
|
What have you tried? Where are you stuck? Where's the problem?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The problem is that i am new at this and i need all the help i can get i have tried with program that compares and execute the changes but i need help qith some script so i can make a bat file that excutes every hour i am fresh at this and need all the help i can get. I can c++, java and some sql but i nned help with oracle.
|
|
|
|
|
Miguel Quintanilla wrote: I can c++, java and some sql but i nned help with oracle. I've never worked in C++ nor Java, but the Oracle-database speaks SQL.
Miguel Quintanilla wrote: and need all the help i can get. What are you trying to achieve (on a higher level)? Create some kind of synchronization?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|