|
Jörgen Andersson wrote: used as a join condition in the view?
Yes.
Jörgen Andersson wrote: had a brain fart
That's what I'm thinking, but I'm no MySQL expert.
|
|
|
|
|
PIEBALDconsult wrote: but I'm no MySQL expert
Neither am I, I have never worked with MySQL.
But I have an idea that might explain the weird behavior.
In Oracle 10g you could define a query as:
SELECT ID
FROM A,B
WHERE A.ID = B.ID
Note that you didn't need to specify which table the column should come from if it existed in the join condition.
What happens if the ID Columns have different types, will there be an implicit cast? And which table will the selected column come from?
In Oracle 11g you always have to specify the table.column
Be excellent to each other. And... PARTY ON, DUDES!
Abraham Lincoln
|
|
|
|
|
Jörgen Andersson wrote: you always have to specify the table.column
Yes, but that's not the issue, so I left it out for simplicity.
|
|
|
|
|
I have the following code, which i generated using Access DB, i need to translate it to T-SQL, am mainly getting error on the IIF statement
SELECT dbo.casyAgeGroups.Sequence, dbo.casyAgeGroups.Description, Sum(IIf([gender]='Male' And [age]>=[startage] And [age]<=[endage],1,0)) AS Male, Sum(IIf([gender]='Female' And [age]>=[startage] And [age]<=[endage],1,0)) AS Female FROM dbo.casyAgeGroups, [qryStats-AgeGenderProfileDetails] GROUP BY dbo.casyAgeGroups.Sequence, dbo.casyAgeGroups.Description, [qryStats-AgeGenderProfileDetails].EntityType HAVING ((([qryStats-AgeGenderProfileDetails].EntityType)=0));
|
|
|
|
|
The IIF function was added in SQL 2012[^]. If you're using an earlier version, you'll need to replace the IIF function with a CASE block[^]:
Sum(CASE
WHEN gender = 'Male' And age >= startage And age <= endage THEN 1
ELSE 0
END)
You could also simplify the age condition by using the BETWEEN operator[^]:
Sum(CASE
WHEN gender = 'Male' And age Between startage And endage THEN 1
ELSE 0
END)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
If anybody can offer some advice on a problem with Integration Services I have I'll be eternally grateful. I'm all out of ideas and getting frustrated to say the least!
1. I have a SQL job that runs an Integration Services package
2. The job is set up to run using a proxy account.
3. When then job is run it fails with the following error:
Could not load package because of error 0xC0014062. Description: The LoadFromSQLServer method has encountered OLE DB error code 0x80004005 (Login timeout expired). The SQL statement that was issued has failed.
4. The package name is correct.
5. I’ve double-checked that the password used for the proxy account is correct.
6. I am able to connect to Integration Services using the same account as the proxy and run the job directly from there.
|
|
|
|
|
lmaycock wrote: (Login timeout expired)
I think that is your smoking gun.
You can set the timeout on connections to infinite(usually 0 represents infinite as a value) to solve this sort of issue.
Something like this: commandObj.CommandTimeout = 0
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
Thanks... I'll hopefully take a look again tomorrow but the same setup (as far as I can tell) works perfectly in my test environment. Typical...
|
|
|
|
|
Hi Folks,
I have a quick question in relation to how i select data from a table, as seen in the table below i want to get rows where Person1 & Person2 are both on the same row, so in the table below i would just want Rows 1 & 2.
Table:
ID | Person1 | Person2 | . . .
1 | ABC | DEF | . . .
2 | DEF | ABC | . . .
3 | ABC | GHI | . . .
.
.
.
I have tried the following:
Select * From MyTable Where Person1 = 'ABC' OR Person1 = 'DEF AND Person2 = 'ABC' OR Person2 = 'DEF'
This does not have the desired effect however.
Where am i going wrong here?
|
|
|
|
|
Nevermind figured it out, was missing brackets in the SQL statement
KeithF wrote: Select * From MyTable Where (Person1 = 'ABC' OR Person1 = 'DEF) AND (Person2 = 'ABC' OR Person2 = 'DEF')
|
|
|
|
|
This is another way of getting the same result:
Select * From MyTable Where Person1 in('ABC','DEF') AND Person2 in('ABC','DEF')
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
Thanks GuyThiebaut, that is cleaner code.
|
|
|
|
|
KeithF wrote: Where (Person1 = 'ABC' OR Person1 = 'DEF) AND (Person2 = 'ABC' OR Person2 = 'DEF')
Your query will also return rows where Person1 and Person2 are the same value. It's not obvious from your description whether that would be a problem, or even if it's possible in your database.
If you only want rows which have both people on the row, try:
WHERE 'ABC' IN (Person1, Person2) And 'DEF' In (Person1, Person2)
or the slightly longer version:
WHERE (Person1 = 'ABC' And Person2 = 'DEF') Or (Person1 = 'DEF' And Person2 = 'ABC')
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Richard,
It would not be possible for ABC to exist in Person1 and Person2 in the same row, but its no harm using the syntax you describe to circumvent it in case it were to happen.
|
|
|
|
|
Hi,
I had long running queery last May, early June. I got all sorts of errors trying to connect.
Then the VS2012Express Compiler gave up!
Eddy Vluggen made great effords to help me, but, in the face of a non compiling compiler, I had to call it a day.
That Compiler has now been fixed with the traditional indecent haste on behalf of Microsoft, (the Last Auto Ugrade apparently fixed it,got no notice of the fix, I hope it will last) However, the DB Connection String Problem has NOT Gone away. I now do wonder, Is this another Microsoft Issue, or am I doing something wrong!
I have the following (More or Less)from Eddy Vluggen, and in line with the documentation.:-
public static String GetConnectionString()
{
string Result="server=b-pc\\Softguard;"+
"database=SgTextiles; " +
"Name=sa;Password=12345;"+
"connection timeout=5;";
return Result;
}
The Code that uses this is:
String ConnectionString = GetConnectionString();
SqlConnection myConnection = new SqlConnection(ConnectionString);
I get the Exception:"System.ArgumentException: Keyword not supported: 'name'."
Irrespective of DB Configuration issues, the parser of the Connect String seems to choke on the Keyword 'name' (incidentely confirming the Non Case Sensitivity of the particular keyword parser).
Kind Regards
Bram van Kampen
|
|
|
|
|
Shouldn't Name be User ID ?
|
|
|
|
|
|
Hi,
Apologies for the length of this question.
Does anyone know where to find information how to develop on MSSQL? I'm not looking for information on database design (Normal Forms etc.), but on how you actually work with it. For example, it's easy to create a new database in Visual Studio, but how do I then get this onto my web hosting server? How do I make sure I can repeat this process if need be? Can I create a new database with the same schema as an existing one? Is there a recognised way to set up the tables and relationships used by the security classes built into .NET? The list goes on.
I find information on designing databases everywhere, but I can't find anything good on how you actually work with them day-to-day. What are the best practices? I am a one-man-band, starting a project that uses an MSSQL database, and while the database won't be doing anything 'heavy' initially, I don't want to get into deep water. I'd like to do things 'right'.
Any advice would be gratefully received.
Kind wishes - Patrick
Thank you to anyone taking the time to read my posts.
|
|
|
|
|
Patrick Skelton wrote: it's easy to create a new database in Visual Studio, but how do I then get this onto my web hosting server?
That depends on your hosting company. The obvious options would be:
- Backup your local copy of the database, copy the files to the server, and restore;
- Use the "Generate Scripts" option to create a SQL script which you can run on the server to create the database;
- If the host supports it, use Web Deploy[^];
Patrick Skelton wrote: How do I make sure I can repeat this process if need be?
If you're overwriting the remote copy of the database, it's simply a case of repeating the initial deployment. If you just want to deploy structural changes, you'll need to create the SQL scripts to make the changes on the server.
Patrick Skelton wrote: Can I create a new database with the same schema as an existing one?
Schemas are local to the database. Two schemas in different databases with the same name are not connected in any way.
Patrick Skelton wrote: s there a recognised way to set up the tables and relationships used by the security classes built into .NET?
If you're using the SQL providers, then the ASP.NET SQL Server Registration Tool[^] is the way to go. However, these providers are quite old; you might prefer to look at the newer "Universal" providers[^].
As for your broader question, I presume you've looked at the SQL documentation on Technet[^]?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for taking the time to write that reply. I will dive in with your suggestions.
- Patrick
Thank you to anyone taking the time to read my posts.
|
|
|
|
|
Patrick Skelton wrote: Does anyone know where to find information how to develop on MSSQL?
I buy books.
|
|
|
|
|
Okay - can you recommend any good books?
Thank you to anyone taking the time to read my posts.
|
|
|
|
|
Sage advice from both Patrick and j, I presume you are having trouble finding reference on developing sql server[^]
Also sqlservercentral.com[^] is a good resource but they tend more towards the DBA skills. As a one man show you are going to have to get a good handle on the development cycle, building the app is only the core skill.
POH has some excellent articles [^]you may be interested in
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi
i want to design database that have different object but with the same structure .
we have feeling table with this structure (code,name,id) also zone table with (code,name,id).
my question is ,i have to design separate procedure for insert & update & delete or i can use one procedure for both table ??
is it possible to send table name??
is it good way to send table name from DAL OR BLL layer?
please help me
|
|
|
|
|
Keep it simple.
Create 2 stored procedures.
Just my opinion.
|
|
|
|