|
When I read the book "teach yourself SQL in 21 days", day 7, first example::
SELECT *
FROM TABLE1
WHERE TABLE1.SOMECOLUMN =
(SELECT SOMEOTHERCOLUMN
FROM TABLE2
WHERE SOMEOTHERCOLUMN = SOMEVALUE)
When I tried this subquery, it doesn't work in SQL-server 2000 at all ! After that I searched online, then found that I have to use "IN" instead of "=" to express the subquery.
I am confused ! Why the book writes like that? Is this an old SQL ? SQL is supposed to be universal, why I cannot use above example in SQL2000? I also found some other places which is not wworking in Sql-server 2000 environment.
Please help me on this silly question.
Thanks
Dennis
|
|
|
|
|
First Be Carefull,
u can use both of them but there is exceptions.
SELECT *
FROM TABLE1
WHERE TABLE1.SOMECOLUMN =
(SELECT SOMEOTHERCOLUMN
FROM TABLE2
WHERE SOMEOTHERCOLUMN = SOMEVALUE)
command is TRUE but "SELECT SOMEOTHERCOLUMN FROM TABLE2 WHERE SOMEOTHERCOLUMN = SOMEVALUE" will be produce JUST ONE RESULT, NOT MORE. So to use any aggregation Function in this case is more true.
For Example;
USE NORTHWIND
select * from Orders where CustomerID =(select MAX(CustomerID) from Customers)
In this case, not just (=) equals sign, Also u cant use (=!,>,<,>=,<=,LIKE)
But some times we get more result from 2nd command.In this case u have to use IN keyword.
For Example, U need Orders information belongs to Customers in London.
if u execute "SELECT * FROM Customers WHERE City ='London'" u see 6 records. then write command for our first aim :
USE NORTHWIND
select * from Orders where CustomerID IN (select CustomerID from Customers WHERE City='London')
I hope u got what u need.
So u can get a result set that contains six different customers' Orders Informations.
|
|
|
|
|
in C#
I'm Beginner
Hi,
I created a function with Datareader object in DataAccessLayer side that I would like to pass to my Client Layer. What I can see that I cannot pass the DataReader itself because in a case of DataReader the connection must be open and close after. The goal is populated a combobox. How can I pass this to my clientLayer? Any idea for a beginner like me will be great.
Thanks,
Davy
|
|
|
|
|
Davy_Fraser wrote:
The goal is populated a combobox
If that`s your goal, why not just pass an array of data?
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Hi,
I wanted to be sure there is no specific way to do this.
As you said, passing array make sense.
Thanks for your help.
Davy
|
|
|
|
|
Hello to all who can help:
I am interested in importing an 83 million record file into ms sql 2000 using c#.net/ado.net and export it to a xml file.
Below is the query that I tried to use to compare two tables, CLIENT and MASTER, and remove rows in CLIENT of the Phone "column" that matches the MASTER table.
Then export CLIENT out again to a xml file.
Help!
----------------------------------------------------------
sqlConnection connclient = new SqlConnection("integrated security=SSPI;" +
"data source=(local);initial catalog=Client"); private void
butDelete_Click(object sender, System.EventArgs e) { try { sqlCommand sqlDelete
= new SqlCommand("DELETE FROM Client FROM master" + "WHERE master.Phone =
Client.Phone"); connclient.Open(); if (sqlDelete.ExecuteNonQuery() > 0) {
lblMsg.Text = "Record has been sucessfully deleted!"; RefreshList();
ClearText(); } else { lblMsg.Text = "Sorry, could not access database due to
the following error: " + ex.Message; } finally { connclient.Close(); } } }
Thank You very much...
|
|
|
|
|
Hi
I have a very very simple web application that does only one thing - tries to open a connection to SQL server.
On my PC it works fine. Connection is opened immediately!
But when I put that application on my host server I get this error "General network error. Check your network documentation."!!
The code is:
private void Page_Load(object sender, System.EventArgs e)
{
this.sqlConnection1.Close();
this.sqlConnection1.ConnectionString = "Data source=myServerIPAddress;Initial Catalog=dbName;User ID=user;Password=passwd";
try
{
this.sqlConnection1.Open();
}
catch(System.Data.SqlClient.SqlException ex)
{
this.Label1.Text = ex.Message;
}
finally
{
this.sqlConnection1.Close();
}
}
Doeas anyone know why is that so?
I tried tu turn pooling off, set bigger timeout but useless!
|
|
|
|
|
I've seen a similar thing when using Names Pipes if you don't have sufficient authentication to connect to the server. Are you using names pipes? If so, try changing to TCP/IP and see if the problem goes away. If it does, then its a security issue.
Database FAQ
|
|
|
|
|
The problem was that, that my host-server and sql server wad in one domain and they use different internal ip addresses, but I was given a different sql server address so I could reac it from outside the domain.
So I got the real ip and everything works fine!
Thanx
|
|
|
|
|
We have a VB6 application that uses an Access DB. One of our customers has reported that edits to the database are not there when they go back into the record. The structure is something like:
The function is to add reciepts to a customers booking.
Edit record (create reciept record)
Commit changes (ado commit to reciept recordset)
Call routine to update log in another database (log of changes to booking including receipts)
Print Crystal report with reciept details.
Close reciept form
refresh booking form with new balance.
Everything looks OK and the reciept prints off fine (data must be in tables correctly for Crystal report to pick it up). the problem is over the past week on 4 occasions the end of day reports which list cash taken are less than the actual cash taken (reciepts are missing from the DB). I have looked at one example and although i have the printed reciept there is no evidence of it in either the main DB or the log DB. The commit has been completly reversed out.
Any ideas?
Jon
|
|
|
|
|
The Jet database engine is not capable of recovering from bad writes. If data is missing, it's usually that some kind of hardware problem has occurred: power failure, disk errors, memory errors, etc.
I would check the file server holding the MDB file very thoroughly.
As I said, Jet is not capable of recovering from these errors. In the long term I would suggest moving to MSDE (SQL Server 2000 Desktop Engine) or, when released, SQL Server 2005 Express Edition which both have these capabilities.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
It is not just that the data is missing it is that it has been removed. It was in the tables (even if it was only for about 10 seconds) but must have dissapeared quite soon after that. Would the hardware problems cause that?
Yes,MSDE or SQL server would be better (especially given that some ofour new customers are quite large organisations) and i keep pushing that we look at migrating the code, but in this case it would be a big job. The app uses a mix of DAO and ADO and a lot of dynamic SQL, the boss just keeps saying 'maybe we'll look at it in the future', ie never.
Jon
|
|
|
|
|
I've added a dropdown list to a data grid and I've populated it with Dataset values.Its working fine.But its selected index is always 1. ie., the first list element is displayed in the dropdown by default. Can anyone pls tell me how to set the selected index of dropdown listdynamically while populating the data grid based on the value that is retrieved from the database?
Thanx a lot in advance, Sandhya
|
|
|
|
|
How to tell MS Access to allow zero lenght in the strings field using the CREATE TABLE command. Thanks in advance.
|
|
|
|
|
it is not possible.
i think u want to use Char Value type for that field. if there will be a lot of zero length data in field, use varchar type. It doesnt consume your performanse. If u use Char, as if u save zero length data to field, it will reserve a n length place. (n, your charecter count as CHAR(5))
|
|
|
|
|
As far as I know MS Access doesn't have any DML DDL statements like CREATE TABLE. The closest you'll get it reading the Msys... hidden tables.
If you go into the design view of the table, you will see the various options per field.
I think Access allows zero length by default. Remember that zero length and null are different.
Cheers,
Simon
sig :: "Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards "Most of us are programmers, but a few use VB", Christian Graus
|
|
|
|
|
Thanks, but I do create my tables with CREATE TABLE (OleDbCommmand.ExecuteNonQuery) and the problem is that I afterwards have to go into access and alter the settings from there.
Allowing null I have no problems with. /Robert
|
|
|
|
|
Hi,
I tried to install MSDE2000 in my PC by downloading sql2kdesksp3.exe from microsoft. after installation, when i tried to access the databases through osql tool, it is displaying the following error:
[Shared Memory]SQL Server does not exist or access denied.
[Shared Memory]ConnectionOpen (Connect()).
when i checked in AdministrativeTools-> Services, i could see MSSQL$Myinstance running. even i re-started that service, there is no use.
Can anybody please help
|
|
|
|
|
Use your machine name inplace of localhost while using osql commands
|
|
|
|
|
By default MSDE with SP3 allows only Windows authentication and does not enable any network protocols. The shared memory protocol should work.
To re-enable network protocols, use the Server Network Configuration utility.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hello there,
With an array list containing structures that I want to insert into the database, I attempted to use BULK INSERT in insert all the data at once (this is faster than a loop of INSERTs right?).
However, can I do a BULK INSERT without first writing the data into a file?
Thanks,
Rafferty
|
|
|
|
|
Hm.. no one's replying.. does this mean that there's no other way to do this?
maybe there's another command (other than BULK INSERT) that can accomplish such a task.
|
|
|
|
|
Hello All,
I am implementing merge replication over internet, having following scenario
.
Publisher has some 14 tables in the database out of which only 7 are to be p
ublished, because only 7 tables are having information which will be changed
hence no need to publish.
At the subscriber side also there will be 14tables and out which 7(published
by publisher) will be receive updates from the publisher vis synchronizatio
n.
Now come to the problem:-
When I am trying to apply initial snapshot its it trying to drop existing ta
bles (which I don't want), since table contain froeign key constraint(I came
to know this by seeing output file of merge agent) and because of master-de
tail relation it is not able to drop it and giving error.
I don't want dropping and recreation of the tables in the databse as I am ha
ving correct schema at the subscriber side can anyone help me???
RuchirDhar Dwivedi
Software Engineer
Windowmaker Software Pvt.Ltd.
Baroda, India.
|
|
|
|
|
In my application, I create new databases and tables in the MSDE server. After inserting all the records into the tables I want the user to be able to view the data in Access. This I would like to automate instead of having the user open up access and doing the import themselves. Is this possible? And how is that done?
Now what is the best way to import the data? By creating an access project (.adp) or a database (.mdb)? I would like the user to be able to copy the file to a disk and view it on another machine. The problem with creating an Access project is the user will still be able to edit the data. Based on Windows NT Authentication, the user did have the right to write the extracted data in the application to the MSDE server. But after that’s done with, I don’t want them to edit the data. And if project was used, would I still be able to transport the files to be viewed on another machine or it needs to be exported to mdb?
If exporting to mdb, wouldn’t that complicate the automation of the database creation because a DSN must first be created?
Any help would be much appreciated!
|
|
|
|
|
Instead of duplicating the work of creating data in MS Access, why dont you create a small VB application or a macro in EXCEL (just for displaying data). because you dont want the users to edit the data.
|
|
|
|