|
Hello every body
i need to get record only from one row from this view i mean this row shout show only book who are taken.The problem in this code is becasue is show me all users who take the book i need only last one.Pleas help me where to fix the code?
use library
select [title], [author], [first_name], [last_name],max([borrow_date]), [telephone], max([id_borrow])
from
[Return View]
where status=1
group by title,author,first_name,last_name,telephone
Good bye
Best regards
|
|
|
|
|
Question is not very clear.
select *
from [Return View]
where id_borrow = (select max(id_borrow)
from [Return View]
where cond....
and group by ..
)
Hope it works !!
Thanks
Mad Max
|
|
|
|
|
I would like to know what people do with phone numbers when storing them for an app. I have several ideas and I have implemented most of them depending on the app, but I want to get to a standard so I'm asking the question:
Where do you store phone numbers for your app?
Assuming I have a Clients table and Contacts table I have done the following in the past:
1. Created fields in both tables for each row such as Phone1, Phone2...
2. Created a seperate table phone numbers and created a reference table to hold the ids of the clinet/contact and the phone number.
3. Created a text field in both tables and stored the phone numbers as and XML string
I know that creating other tables and ref tables is probably the best Normalized way to do this but is it really that much of a memory/time savings over just storing the information in the same table as the Clients/Contact?
Any thoughts would be appreciated,
Richard
|
|
|
|
|
It really depends on what you are going to do with the information. If all that will ever happen is that the phone number gets displayed on the screen for a customer services person to see and then dial the number then having phone1, phone2 etc. is probably fine.
If you are storing more than just the phone number you might consider normalising it. e.g. for each phone number you are going to put what type of number it is (work, home, mobile, fax, etc.) and maybe a description, e.g. "Available between 9:00 and 18:00"
Alternatively, if you are going to do any serious processing with phone numbers (and I really can't imagine what that could be outside of a telco or automated call centre scenario) then you would be better normalising the data otherwise the SQL will get horrendous.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
How do I sort a Dataset by a certain column value? The data will be bound to a datalist. The only sorting I've found is for the datagrid web control.
|
|
|
|
|
Hi.. what is the command to list all the tables of a data base in SQL SERVER????
Please help me out in this situation????
Bawa
|
|
|
|
|
Bawasoft wrote: what is the command to list all the tables of a data base in SQL SERVER????
SELECT * FROM INFORMATION_SCHEMA.TABLES
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
|
Bawasoft wrote: dear
Sorry, I realise English isn't your first language, but you should know that generally a person would only call their wife/husband "dear"
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Thanks for the precision, honey
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Select name from sysobjects where xtype='u'
SELECT table_name FROM INFORMATION_SCHEMA.TABLES
These two performs one nad the same
But when executed in Query Execution Plan the first query costs less
So I prefer the first one
"Aim to go where U have never been B4 and Strive to achieve it"
http://groups.yahoo.com/subscribe/dotnetforfreshers
http://himabinduvejella.blogspot.com
|
|
|
|
|
Select name from sysobjects where xtype='u' order by name
"Aim to go where U have never been B4 and Strive to achieve it"
http://groups.yahoo.com/subscribe/dotnetforfreshers
http://himabinduvejella.blogspot.com
|
|
|
|
|
Sp_help 'databasename' gives all the tables (both System and user tables)of Database
"Aim to go where U have never been B4 and Strive to achieve it"
http://groups.yahoo.com/subscribe/dotnetforfreshers
http://himabinduvejella.blogspot.com
|
|
|
|
|
I am writing a program that updates a access database. I am filling a dataset with data from a comma delimited text file. Then I insert the dataset into the database with this piece of code.
OleDbAdapter.Update(dataSet1, "Table1");
This works great, but I also need to insert records to the database using a SQL insert statement. I am using the code below to insert a single record to the database.
"insert into Table1(col1, col2, col3)"
+ " values ('" + textBox1.Text + "', '"
+ textBox2.Text + "', '"
+ textBox3.Text + "')";
This works great. The problem comes in when I try to insert another dataset. The correct number of records are added but every row is the same as the row from the SQL statement. I bound the dataset to a datagrid but the datagrid shows the correct data in each row. Please help me before I get fired. Thanks
|
|
|
|
|
Hello Everyone, not sure if this is the correct forum for my question but im sure someone will tell me if it isnt, here goes with a little intro at my place of work we use a vb based app built on both sql 6.5 and 2k. i am currently a lowly helpdesk jockey but want more ( a la matrix !) im quite happy to dive straight in the deep end so i have this question which will i believe set me on the road to all things great, we use reusable scripts from within sqlew but i want to have a .exe from my desktop that i double click, select my script from a listbox enter the required values and then execute the script ( this script would have to execute across several networked workstations) i am familiar enough with terminology of both sql and vb i would greatly appreciate somebodies words of wisdom can this be done ?
regards
MM
|
|
|
|
|
I want to create a table from existing tables in SQL sever.
I have tried CREATE TABLE TBL_NAME AS SELECT * FROM EXISTNG_TBL_NAME.
But this command is not working in SQL Server.
Please Help me out in this situation.
Bawa
|
|
|
|
|
Hi there im new these forums but couldnt help notice your question, if i read your post correctly then cant you just dump or bulk copy out your table drop table then create new bulk copy in ? sorry if that doesnt help
MM
|
|
|
|
|
SELECT * INTO NEW_tblName FROM EXISTING_tblName WHERE 0 = 1
--SQLServer Books Online--
INTO Clause
Creates a new table and inserts the resulting rows from the query into it.
The user executing a SELECT statement with the INTO clause must have CREATE TABLE permission in the destination database. SELECT...INTO cannot be used with the COMPUTE. For more information, see Transactions and Explicit Transactions.
You can use SELECT...INTO to create an identical table definition (different table name) with no data by having a FALSE condition in the WHERE clause.
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
Thanks dear.. your querry realy works.... again thanks dear.....
Bawa
|
|
|
|
|
I have successfully retrieved data with an adapter to create my required dataset. But now I want to know how many rows are in my dataset? I am using SQL 2003 and .NET1. I see that many people use the Tables.Rows.Count, but mine isn't working when I do that.
How do I retrieve the number of rows of the table in the dataset?
Thanks.
|
|
|
|
|
please try the following code
dim ds as new dataset<br />
dim da as new sqldataadapter(strQuery,conn)<br />
da.fill(ds,"test")<br />
response.write(ds.tables("test").rows.count)
strQuery is the select command, conn is the connection
|
|
|
|
|
I don't know VB
I'm using C#. Are you still able to help me in finding out how many records are in a table in a dataset.
|
|
|
|
|
cybersurferdev wrote: I'm using C#.
Your question should post in C# Forum.[^] But anyway, i still help you with this issue. Try to check this website[^] in order to convert the code from the previous post in order to answer your question.
|
|
|
|
|
//this should answer your question
string connStr = "Fill in your connection string here";
string sqlStr = "SELECT * FROM someTable";
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connStr);
System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(sqlStr, conn);
System.Data.DataSet ds1 = new DataSet("test");
System.Data.DataTable dt1 = ds1.Tables["someTable"];
int rowCount = dt1.Rows.Count;
//or a good use is
for(int i=0; i< dt1.Rows.Count; i++)
{
//do something
}
//or another
foreach (System.Data.DataRow dr1 in dt1.Rows)
{
//Do something else
}
|
|
|
|
|