Very elegant :) I ended up having to use a varchar 12 and ended up with this beautiful mess. It's ugly... but it works!
It starts as a char(6) in 200510 format and ends up as Oct-05
STUFF(CONVERT(VARCHAR(12),CONVERT(DATETIME, (SUBSTRING(MyField, 5, 2) + '-01-' + SUBSTRING(MyField, 1, 4))...
I'm trying to change a date from 2005-10-01 00:00:00.000 to Oct-05.
I would need this to work for any month. How can I do this?
I'm using SQL Server 2005.
Thanks!
We have a report where we allow the user to specify a date range and pull all of the purchase orders pulled between the specified dates.
Well, there is a problem with the report.
The code is like this:
WHERE CreatedDate BETWEEN @begindate AND @enddate
If the begin date is 2011-06-29 and the...
Blarg. Shoot me now. I'm going to dump all of the inventory count data (the IDs of which are in the #temp_counts table) into their own temp table so I can more easily refer to them.
My goal is to do the following calculation:
CurrentCount(of count0)+PurchaseOrders-CurrentCount(of count1). This will produce the overall inventory utilization by inventory ID. I'd be doing it for multiple weeks, but don't worry about that. Once I can do it for one week, I can do it for all...
I am pulling from a few temp tables and am not sure how to join them so I get the right results. The goal is, in essence, to make the following calculation:
InventoryCount1+PurchaseOrdersMadeBetweenCount1and2-InventoryCount2=InventoryUsage
Tables:
1) Inventory Counts Temp Table containing...
Honestly, looking at it, I'm not sure there is really anything I can cut out. I might be able to recode something to make it run faster, like I did for the like statements, but, for the most part, I'm just pulling data from tables and I need to pull it all.
Considering the size of the...
Cool!
Holy cow, yeah. It's saying 95% of the time is the Table Scan at the end. Is there a way to make it highlight the code that that element of the execution plan comprises?
Intuitively, I'd think that any time I'm doing a query I'm doing a "table scan", but based on the percentages I'm...
Sorry, that is rife with typos. I wish I could edit on this forum.
I meant to say "I don't know a THING about indexes" on line 1 and **COULD'VE** on the 2nd-to-last line, not "couldn't
Honestly, 4 seconds is pretty great to me, but I'm always up for squeezing some more performance out of it. I don't know a think about indexes. ...I don't think I want to be altering the DB for this report (we have 100s of reports that pull from these tables).
I have 4 temp tables with a lot...
Hello again :)
Thanks not in small part to the assistance of you fine people, I have my 6-pages of code working. Now I'm working on optimizing it. I've knocked the run time down from 11 seconds to 6, but I know of a couple other places I could speed it up.
One is with filtering inventory...
Sure does :) I'll sort of mentally break off UPDATE and SET from the rest of the pack; FROM and everything else just determines what I'm setting and updating.
Thanks again!
Thank you! Worked like a charm. That has to do with order of evaluation, yeah?
I thought I'd be able to use the alias for the SET if I declared it in the FROM, much like how you can use a table alias that you declare in the FROM where you join to refer to fields in the select.
...if that...
SQL Server 2005 is saying that Wk1Usage.Wk1Usage in the update statement for my temp table can't be bound, but I don't see any problems with my syntax. Help? :S The subquery in the update runs flawlessly.
CREATE TABLE #temp_usage
(
SiteID CHAR(10),
InvtID CHAR(30),
Wk1Usage FLOAT...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.