|
|
I was looking at yours.
|
|
|
|
|
Jorgen, as usual... Thanks for the clear explanation
Getting all the required rows after following your suggestion.
|
|
|
|
|
If you want to include that condition then include that in the Join like
left join scheme.stockm s on s.warehouse+s.product = d.warehouse+d.product and s.analysis_a not in ( 'LNG', 'INFANTRUST')
Else you will face that issue
|
|
|
|
|
try it:
select * from scheme.podetm d
left join scheme.stockm s on s.warehouse+s.product = d.warehouse+d.product
where d.qty_received >0 and d.inv_value_posted =0
and (s.analysis_a not in ('LNG','INFANREUST')
or s.analysis_a is null)
|
|
|
|
|
I'm going to be developing a WPF/C# app that will run on single PC's/Laptops.
I have extensive experience with SQL Server, but now I need a replacement DB that I can install and use on the target environment.
Again, something similar to SQL would be nice so I keep the learning curve to a minimum.
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
How about CE[^], some limitations and no stored procs but...
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Never used it. I'll take a look
If it's not broken, fix it until it is
|
|
|
|
|
Know of any tutorials to get me up & running quickly?
Thanks!
If it's not broken, fix it until it is
|
|
|
|
|
Sorry, I started using it for a training app and chucked it because I am so reliant on stored procs it irritated the hell out of me. Coding up all the queries in c# as strings was excruciating. I would seriously look at EF if I had to use it, and I hate EF!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Query strings???
Use Linq to SQL.... no query strings. No sprocs.
If it's not broken, fix it until it is
|
|
|
|
|
Never used Linq to SQL so I have no opinion, but does that not emit a Tsql query.
I don't have a problem with CRUD coming from the DAL but I end up doing a lot of processing in procs, the industry I am in I guess.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Have a look at SmartPaster[^].
It allows you to build the query in your favourite tool and paste it as a stringbuilder in VS.
If you ever get the idea to try again that is.
|
|
|
|
|
SQL CE is pretty close to SQL server in terms of the actual queries you write. If you know one you should easily get to grips with the other.
|
|
|
|
|
|
Have you considered SQLite[^]?
I have used it a small amount and it seems fairly good as a database engine.
As an afterthought, if you write your code in a layered manner you should be ably to create something that is database agnostic. You could then experiment with different databases to see which one suits your needs.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
A local version of Sql Server, that looks/act a lot like Sql Server?
LocalDB[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
At least at one time Microsoft allowed SQL Server to be used for free for smaller businesses. Figuring that out can be difficult but might be worth it.
The normal goto for free alternatives is MySQL but you should look at the license for that, but an alternative which might be even better now is one that started as a fork of MySQL which is MariaDB.
Those however are 'servers' and an embedded database might serve your application better. But you might want to make sure that your application will never have a need to have multiple clients and one server.
|
|
|
|
|
I should remember this, but my mind is drawing a blank.
In SQLServer 2008, I have a table: site, datapoint (there are other columns, but not important right now).
I would like to produce a list of datapoints and the sites they are listed with.
Example:
Site DataPoint
KC WindSpeed
KC Temp
CH WindSpeed
CH Temp
CH Power
Output:
Power CH
Temp CH KC
WindSpeed CH KC
Can someone help me with the T-SQL? I can do this with temp tables and updates, but would prefer an elegant solution.
Thanks,
Tim
|
|
|
|
|
If I've understood your question properly, you're looking to concatenate row values rather than PIVOT them.
This article[^] covers most of the options. For example, the black-box XML method:
SELECT
DataPoint,
STUFF
(
(
SELECT ',' + Site
FROM YourTable As I
WHERE I.DataPoint = O.DataPoint
ORDER BY Site
FOR XML PATH(''), TYPE
).value('.', 'varchar(max)')
, 1, 1, ''
) As Sites
FROM
YourTable As O
GROUP BY
DataPoint
;
http://sqlfiddle.com/#!3/5657e6/3/0[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you, but, no. Not concatenation.
I need the CH and KC to be the column headers.
What I have is 1400 data points and 4 sites; in theory, all sites SHOULD have the same datapoints, but... they don't.
I need to create a matrix of datapoints and sites to show what is there and what isn't.
What I've presented is the simplified version, but the concept is correct.
|
|
|
|
|
So if CH and KC are the column headers, what are the column values?
Remember, you can't have different columns for different rows in the same resultset, which is what the "output" section of your question seems to be doing.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Either the column name or the datapoint or 'Exists'; any indicator to show the datapoint exists for that site, but if it doesn't exist, a blank value.
|
|
|
|
|
So a basic dynamic pivot then?
DECLARE @cols As nvarchar(max), @query As nvarchar(max);
SET @cols = STUFF
(
(
SELECT DISTINCT ',' + QUOTENAME(Site)
FROM Source
FOR XML PATH(''), TYPE
).value('.', 'nvarchar(max)')
, 1, 1, ''
);
SET @query = N'SELECT DataPoint, ' + @cols + N' FROM Source PIVOT (COUNT(Site) FOR Site IN (' + @cols + N')) As p';
EXEC(@query);
http://sqlfiddle.com/#!3/5657e6/5/0[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you.. yes, that worked... like I said, I used to use it, but forgot how.
|
|
|
|