|
Afzaal Ahmad Zeeshan wrote: Learn more
I think this may be an invalid assumption
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I want a code of java prog
which can take million integers as input,
sort them (bubble or quick or selection sort).
It should display time taken to sort first 10 integer, then for first 100 integer, then for 10000 and total.
Please help me soon I have very less time to complete my project.
iamsohail.srk@gmail.com
|
|
|
|
|
No, this is not how it works. We gladly help when you get stuck but we aren't going to do all your work for you.
You didn't even manage to post this in the correct forum.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I am using sql server 2005.
I have a column with date values (say column1). I need to fetch the date which does not exist in the past 15 days.
Means : user insert records daily. But on May 1st due to leave no records got inserted. So I need to analyse past 15 days (from current date) and fetch only May 1st.
I tried below query.But its return the past 15 days (excluding weekends). But i need days which not exist in past 15 days.
select distinct top 15 inserteddate from table1 where
((DATEPART(dw, inserteddate) + @@DATEFIRST) % 7) NOT IN (0, 1) and ( inserteddate >= DATEADD(DAY,-15,inserteddate) and inserteddate <= getdate())
order by inserteddate desc
Help me pls.
modified 11-May-15 9:22am.
|
|
|
|
|
I would suggest you create a temporary table with the dates for the last 15 days and then select the dates from the temporary table not in the table1 you referenced.
The temporary table can be populated using a while loop.
|
|
|
|
|
Realized you might need to go across month boundaries, so yes, I think generating a list dates 15 days back in a table variable and doing a datediff against those in a join might be the easiest solution.
|
|
|
|
|
Something like this should work:
WITH cteTally (N) As
(
SELECT TOP 21
ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) - 1
FROM
sys.objects
),
cteDays (TheDate) As
(
SELECT
DATEADD(day, -N, GetUtcDate())
FROM
cteTally
)
SELECT
TheDate
FROM
cteDays As D
WHERE
((DATEPART(dw, TheDate) + @@DATEFIRST) % 7) Not In (0, 1)
And
Not Exists
(
SELECT 1
FROM table1 As T
WHERE T.inserteddate = D.TheDate
)
ORDER BY
TheDate DESC
;
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Is there any benefit to the CTE over a temp table. I consider the temp table to be much more readable but if there was a significant performance benefit I will need to reconsider!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
For 21 rows, there probably won't be much difference in performance between a CTE and a temp table.
I prefer the CTE solution because it's a single statement. With a temp table, you need to check if the table exists, create it, populate it, run your query, and drop it again.
Of course, if you've already got a tally table in your DB, then you could use that instead. It might even be worth creating a table of dates, so that you can mark holidays and other closures as well as weekends.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
For simple dates I have a view that goes from start of previous year to + 10 years but for some apps I have a table Holiday with all the public holidays of various countries we deal with.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
how to display employee name, department name and salary where department number 10 ?
|
|
|
|
|
Display it where? On the screen, a form, the console, printer ... ?
|
|
|
|
|
SELECT employeename, departmentname, salary FROM employees WHERE departmentno = 10;
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Can somebody tell me why the following isn't working?
UPDATE JobTicket_024 SET JobTicket_024.file = Replace([file_link],"\\52qjkl-as-004p","F:\CE\CE\CEDrawings");
I stole this from a previous update I did to the same table.
Now I'm just changing the path again.
It updates the field "file" with "\\qjkl-as-004p" not the new path. What gives?
Thanks in advance.
Windows 7
MS Office 10 (32 bit)
Access
64bit machine
modified 7-May-15 10:06am.
|
|
|
|
|
You are asking sql to look at the file_link column, find "\52qjkl-as-004p" and replace it with "F:\CE\CE\CEDrawings" and put the result into the file column.
Perhaps a before and after picture would help.
However, instead of UPDATE just change to SELECT so you can see what it will do.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
SELECT JobTicket_024.file_link, JobTicket_024.Project_Number
FROM JobTicket_024
WHERE (((JobTicket_024.file_link)=Replace([JobTicket_024]![file_link],"'\\52qjkl-as-004v\CE_Data\CE\CEC\oce_drawings'","'F:\CE\CE\CE Drawings'")));
OK, first I changed UPDATE TO SELECT per your suggestion and I changed it to look at the "file_link" column and replace the "file_link"
Interestingly, the query shows a table and then an error message pops up with "Data type mismatch in criteria expression" and as soon as I click "help" it clears the table. And, the field isn't updated either.
|
|
|
|
|
Don't put it in the where clause. Use the SELECT statement as a preview of what you want the update to do.
For example:
SELECT file, file_link, Replace([file_link],'\52qjkl-as-04v\CE_Data\CE\CEC\oce_drawings','F:\CE\CE\CE Drawings') AS NewFile
FROM JobTicket_024
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Thanks RyanDev, but still a no go. I copy/pasted your code to make sure I did not have any typos.
It creates the new column, NewFile, but there were no changes to the resulting data. It just copied the old column to the new column verbatim.
|
|
|
|
|
I know there were no changes. It is a SELECT statement, not an update statement. Perhaps run it again and paste some of the results here so we can see.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
F#*#k
There was a typo in my select statement. That's why it wasn't finding anything in the search/select column.
Sorry for the troubles.
Thanks for helping.
|
|
|
|
|
No problem. Glad you found it.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I am using Qlik to writeback to the database (Sybase IQ), however, the insert query fails after inserting 3500 rows stating "access violation." but the 3500 rows get inserted into the target table.
I have verified that the data beyond 3500 rows also gets inserted if I run it for 3500 to 7000th rows, so it cannot be a data issue.
I have looked around for this error, and tried setting the BufferCacheSize, PrefetchRows, EnableBulkInsert etc properties, but to no help. Also, if I execute the query with 1000 rows for a single insert, it fails with same error. If, however, I try to insert the same data 100 or 500 rows at a time, the load succeeds.
Is there a limitation with how much data the Sybase IQ ODBC Driver can handle for an open connection? Any ideas/solutions would be much appreciated.
Thanks.
modified 7-May-15 5:30am.
|
|
|
|
|
Ankit RS wrote: Any ideas/solutions would be much appreciated. It sure does sound like you are hitting some sort of memory threshold. I'd suggest batching your records in smaller amounts.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I second RyanDev's suggestion. I've seen a benchmark somewhere, comparing the insert speed depending on the batch size and it had diminishing returns starting around 50. I think it was for SQL Server but I'd imagine it's similar for other DBMS'. Which would mean you won't gain much anyway with a batch size of 1000.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Thanks Ryan and Sascha.
I think I figured out the issue: it most certainly looks to be a threshold issue. On executing an insert inside a loop for 1 to 2000 in the query editor, Sybase throws up a pop-up stating "Maximum number of entries for the editor is 1000 and you should remove successful logs from the log file." Paraphrased. There are options to either remove or keep the successful entries from the log. See attached snapshot.
Surely, this is what's causing the insert to fail, when executed through Qlik, as there's no handler for the pop-up.
(Funny I can't locate the attach option here for the snapshot)
Edit: Turns out the solution is: 1) keep the number of rows in the insert less than 1000 for each execution (loop or otherwise), and 2) include the begin and commit the transaction statements as a part of the query itself instead of using the connection.BeginTrans and connection.CommitTrans in the VBScript code (which is what I was doing initially.)
modified 8-May-15 7:07am.
|
|
|
|