|
Respected sir,
I have some of the questions related to sql queries
1.what is the sql server query for having the 3rd max salary record from the following table
EmpId Empname EmpSal
1 Joseph 1000
2 rahul 299
3 Rahim 4000
4 John 350
5 kate 2000
2.what is the sql server query for arraning the records with latest date for the following table
EmpId Empname EmpSal Date
1 Joseph 1000 21may2005
2 rahul 299 12 june2004
3 Rahim 4000 3may2006
4 John 350 5april2001
5 kate 2000 8june1998
3.how to sort the particular coloumn with out affecting to other coloums like
Empnam empSal
Joseph 1000
rahul 299
Rahim 4000
John 350
kate 2000
the above table has to be translated as given below in which only the salary is sorted in descending order with out disturbing empnames
Empname Empsal
joseph 4000
rahul 2000
rahim 1000
john 350
kate 299
4.In stored procedures how to jump to required line,
for example we have 1 stored procedure in which it contains 20 lines of code,but during accessing if we want to execute 8th line directly jumping from 2line of code.how to make it possible
please suggest me
Thanking you in anticipation
|
|
|
|
|
MD12 wrote: what is the sql server query for having the 3rd max salary record from the following table
SELECT TOP 1 FROM (SELECT TOP 3 FROM MyTable ORDER BY Salary ASC) ORDER BY Salary DESC
MD12 wrote: what is the sql server query for arraning the records with latest date for the following table
It depends what you mean by "arraging the records with the latest date"
SELECT * FROM MyTable ORDER BY SomeDateColumn
MD12 wrote: 3.how to sort the particular coloumn with out affecting to other coloums like
I have never come across a situation where that was useful.
MD12 wrote: 4.In stored procedures how to jump to required line
Use GOTO - or better would be to create a proper conditional structure with an IF block.
|
|
|
|
|
I have a the following table structure
t_entity
entity_id
connect_date
disconnect_date
t_entity_info
entity_id
property_name
value
Let's say I have the following data in the tables
t_entity
1 | 1/1/2005 | 12/1/2005
2 | 1/1/2006 | 12/1/2006
t_entity_info
1 | application | ds3
1 | subapplicaiton | wan
2 | application | voice
2 | subapplicaiton | phone
I want the following results with one query (using Oracle)
1 | 1/1/2005 | 12/1/2005 | ds3 | wan
2 | 1/1/2006 | 12/1/2006 | voice | phone
Anyone got any ideas? Thanks in advance.
Mike Lasseter
|
|
|
|
|
Hi all .
I wanna know ... :
1. What is the difference between Sqlserver2000 and SqlServer2005 ??
2. Which one is more useful ?
3. Which one works better and is more compatible with Asp.net2003 ?
Thank you very Much.
|
|
|
|
|
"4"
Sorry, could not help myself.
Our developers never release code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
|
|
|
|
|
My calculator gives 5, but I have my doubts.
Chris Meech
I am Canadian. [heard in a local bar]
I agree with you that my argument is useless. [Red Stateler]
Hey, I am part of a special bread, we are called smart people [Captain See Sharp]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
Calculated starting from zero. OOps. That only works if you are worried about a context out of range error!
Any suggestions for this guy. I prefer 2005 because of SMO and SQL Server Express is free. Plus, nifty serialization and inside out CLR.
Our developers never release code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
|
|
|
|
|
|
Hi,
I have a table Main with 3 fields: ID, Name, and Info.
I created a listbox, but how do i populate it using with data from this query.... "select distinct Name from Main"
Below is the portion of my code.
***************
OleDbDataAdapter* da;
OleDbConnection* odc;
DataSet* ds;
odc = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\Main.mdb");
da = new OleDbDataAdapter("SELECT DISTINCT Name FROM Main",odc);
ds = new DataSet();
da->Fill(ds,"Main");
//stuck... don't know how to proceed from here.
please help..thanks!!!!
|
|
|
|
|
I am developing an sms messaging app (Let say app A) with backend in SQL2K. This app depends on a schema of an already deployed application (Let say app X). I have also created a schema of my own application which may reside on any other machine.
Whenever app X done a transaction on some of the tables I am initiating a trigger from there. After doing some operations on the inserted record in the trigger I am inserting that record to my own schema generated for App A by the link server to my Schema.
I have made a windows service, whenever a new rocord is inserted in my tables through schema I'll compose and send an SMS message to my client.
My problem is since triggers runs in an implicit transaction whenever the inserting triggers fails the transaction which was inserted by App X is also got failed. Which I don't want. How to cope with this... I don't know about error handling. How to implement fail save recovery in this scenario.
SMK
|
|
|
|
|
Hi All,
I want to know whether loops in ERDs are wrong or show weak design or not.
Example: if table A is connected to table B & table B is connected to C & C is connected to A..
Is this wrong??
Actually the ERD is larger than that & the alternative is to make multiple joins when retreiving data so I want to know which is better.
Thanks a lot
|
|
|
|
|
mytotaleclipse wrote: want to know whether loops in ERDs are wrong or show weak design or not
No, they are not wrong.
|
|
|
|
|
The tightest "loop" (relationship) you can have is when a table joins onto itself - which is perfectly valid.
e.g. An employee has a manager, a manager is an employee also. So the managerID column of the employee table refers to the ID of another employee.
|
|
|
|
|
Hi,
How to search all columns of a table in a database for a keyword?
I am using ASP.NET 2.0 and Sql Server 2000. Give me the logic behind this operation?
Thanks,
Regards,
Regards,
Jay
|
|
|
|
|
Not sure exactly what you are trying to do, but if you need to look for a particular value and if you are using datatables you could loop through your column names and in each loop run a datatable.select command, storing the values in an array.
More information would be helpful.
Our developers never release code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
GISDevCafe.com
|
|
|
|
|
hi guys
can anyone plz tell me the syntax for the following queries
1.Alter Table name
2.Alter Column name
3.Alter Column dataType
4.Alter Primary/Foreign/Unique constraints of a Column
plz tell queries that work in Sql Server.
these are the queries that i am using for the first two tasks and they don't work
1.
string sql="ALTER TABLE "+comboBox2.Text+" TO "+new_tn;
2.
string sql="ALTER TABLE "+comboBox2.Text+" RENAME COLUMN "+new_tn;
regards
|
|
|
|
|
The syntax for SQL Server 2000 is:
1. EXEC sp_rename 'old_table_name', 'new_table_name'
2. EXEC sp_rename 'table_name.old_column_name', 'new_column_name', 'COLUMN'
3. ALTER TABLE table_name ALTER COLUMN column_name new_data_type
4. Lookup "ALTER TABLE" in "SQL Server Books Online".
Regards
Andy
|
|
|
|
|
thank you
regards
Saira
|
|
|
|
|
I want examples of some complex sql queries.
such as there could be some 2 - 3 tables as Purchase , Order and Order Details etc..
and there would be some 50 questions asked with answers i.e sql queries
pls suggested me some links that would contains above mentioned example.
Thanks in advance
Praveen
|
|
|
|
|
If you have Access of SQL Server 97/2000 installed, I would suggest that you take a look at the stored procedures/queries that are installed as part of the reference database. If you have some variant of SQL Server 2005, the AdventureWorks database is an excellent source of queries to look at.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi, I am learning C# and .NET 2.0. I have so far read two books that touch on ADO and SQL. They are Pro C# 2005 and the .NET 2.0 Platform and Pro .NET 2.0 Windows Forms and Custom Controls in C#. They both confused me more than anything. I want to understand these concepts as a Windows or ASP .NET application programmer. I want to understand how to access databases as well as create one, but don't want to learn enough to become a DBA. I just want to know enough to know what I am doing with them.
For example, I am thinking of writing a client/server Quicken like program. Users can access it to create their own bank accounts, and others can then access the DB to get reports.
So where should I start? Do I get a book on SQL or ADO .NET first? Is there a good book that explains it to a beginner?
Thanks!
|
|
|
|
|
|
Will SQL Server truncate input that is longer than the allotted field automatically or do I need to pre-truncate it? I only ask because some code I've inherited does this and I always thought that it would just drop what didnt fit.
I also know this isnt a good thing necessarily and may never be an issue but it just seems like wasted comp cycles to do this in the application.
Cleako
|
|
|
|
|
I have always been of the opinion that the data should be as clean as possible before it gets sent to the database. As a user, I would prefer to know if my data is being truncated and have the ability to change it if it is. Sometimes a re-wording is preferrable to a truncation.
|
|
|
|
|
The problem in my case is that I am working on a web service so it is up to the sending person to limit the length.
Are you saying, though, that you would rather have the data pre-truncated than to let SQL Server do it?
Cleako
|
|
|
|