sql

Multivalued Dependencies

For a Relational Schema Teachng(Course,Books,Lecturer) Hows Course -->---> Books and Course--->-->Lecturer Multivalued dependencies?? For a particuar Course we cannot be sure about the book name! As many books are possible! So hows it a FD in first case?? ...

How to do a case sensitive search in SQL Where clause (I'm using MS SQL Server) ?

I want to do a case sensitive search in my SQL query. But by default, MS SQL server does not consider the case of the strings. Any idea on how to do a case sensitive search in SQL query? ...

SQL Help (For Each)

I'm trying to write an SQL Statement that needs to loop through a list of departments, kind of like a For Each. Heres what I have so far. SELECT DISTINCT AVG(salary),assigned->name FROM edu_ucla_cs241_termproj_schema.InstructorImpl WHERE assigned->name = 'Anthropology' This will give me a table of Avg Salary Department 90.15...

How to count same Id in a column in a table and based on count perform concatenation.

I have a table in below format ID Name 1 Amit 2 Mohit 2 Nahar My reqiurement is to get a query that will update this table to below format ID Name 1 Amit 2 Mohit OR NAHAR Is there any query in SQL that can solve this purpose? ...

Drop 0 value in decimal places

Hi, I want to ask if anybody know the query to drop the 0 value in decimal.. E.g : A field name percent have these values Percent 770.00000000000000000000, 340.670000000000000000000, 96.00000000000000000000, 4400.56000000000000000000, 109.89000000000000000000, 109.00000000000000000000, 37.00000000000000000000, Currently I'm using th...

How I can optimize this slow query?

I want to know how I can optimize it, preferably without changes in tables structure. SELECT p.author_id member_id, m.members_display_name member_name, COUNT(p.pid) posts FROM forum_topics t STRAIGHT_JOIN forum_posts p STRAIGHT_JOIN forum_members m WHERE p.author_id != 0 AND p.author_id = m.member_id ...

Tool for monitoring SQL query results needed

Hi, I am looking for a tool to monitor results of a periodically run sql query and raise a notification based on the fact that the query returns any results. (any other filters are welcome) I need to watch a transaction table for errors, and it would be great if my sql query could run in background, refresh itself periodically and show...

How Decimal places are converted using FLOAT in SQL Server 2000/2005/2008

Hi, in this SO question the OP wanted to drop the 0's in the decimal places for his results. Now the example I gave (below) to get around this was to CAST with DECIMAL, then CAST with FLOAT. e.g. SELECT CAST(0.55 AS FLOAT) Using the example above and running it in SQL Server 2005/2008 would seem to bring up the correct result of 0.5...

Checking for an SQL result in VB.NET

I need to check if my SQL statement returned any results from the Access db I'm using to store my data. I have this code atm: cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\Computing Project\database.mdb;") cn.Open() cmd = New OleDbCommand("SELECT * FROM(" & roomvar.ToLower() & ") WHE...

Database Server 100%, for no reason

Hi, We have a Windows Server 2003 (x64) running as a Database server. The Database is equipped with 32GB of RAM Usually the Database memory usage (Task Manager) is between 5-10%. However sometimes the Database shoots up suddenly to 100% and remains there, randomly and without any changes to code or executions. All sort of research, pa...

Getting data from the database with python(on Django framework)

Hello, ordinarily if I were writing a sql statement to this I would do something like this, SELECT * FROM (django_baseaccount LEFT JOIN django_account ON django_baseaccount.user_id = django_account.baseaccount_ptr_id) LEFT JOIN django_address ON django_account.baseaccount_ptr_id = django_address.user_id;name how do I put this into...

postgresql querying on multiple identical tables

Hello I have several databases, such as mytable_2009_11_19_03 where last 2 numbers identify the hour (table for 03:00), now I want to query something from _00 to _23 . It could be done in such way but it is really clumsy select * from mytable_2009_11_19_00 where type = 15 UNION select * from mytable_2009_11_19_01 where type = 15 UNION ....

Selecting group using Unknown column value

hi guys, I have a large table with records like (id,name,Class) I want to be able to do a operation "Class" wise .. but i dont know what are all possible values for Class Currently i have to do is use 2 queries : Query 1: result = select distinct class from myTable; Query 2 : for each value from result , classWiseRows = select *...

Importing Excel data to a already established SQL DB visual basic

I have developed a program in which all data is entered into a SQL DB. the program has been designed in Visual Studio using Visual Basic. I am now getting external data supplied in an excel format and need to know how to import the excel data into the SQL DB and ensure the data goes into the appropriate columns. I have set a template up ...

sql sum or aggregate function on pre-fab column with complex query

I have a query that takes avg data (prices) from 7 days of the week for a long interval. IE avg prices for monday, tues, etc. It works fine, but I'm unsure how I can in the same query sum the avgs that this query finds? Summing Day1..Day5 As it stands this query sums the entire from of all the prices... IE huge number.. not from the ...

Searching a tables XML filed using Linq, can it be done?

I have a database table with transactions. In one of the fields there is an XML message, the field type is “xml”. In this XML there is an employee filed and it is this field that I need to search. I want to retrieve all the rows that match the employee number supplied at runtime. Is it possible to do this with Linq ? Shown here is some...

How to operate this query by puting mentioned condition?

My table is as follows ID Name 1 Amit 2 Shalu 2 Ram 3 John 3 Kripa 3 Manish 3 Abhi 1 Ayush My requirement is to generate a query that will make the format as ID Name 1 Amit OR Ayush 2 Shalu OR Ram 3 John AND Kripa AND Manish AND Abhi Conditions: when count(Id)=2 concatenate OR with Names when count(Id)>3 con...

Use a LIKE statment on SQL Server XML Datatype

If you have a varchar field you can easily do SELECT * FROM TABLE WHERE COLUMNA LIKE '%Test%' to see if that column contains a certain string. How do you do that for XML Type? I have the following which returns only rows that has a 'Text' node but I need to search within that node select * from WebPageContent where data.exist('/PageCo...

SQL Performing a search/replace search

I need to search a specific column for every occurrence of a string and replace it with a different string. The column is a MySQL TEXT column. ...

SQL: Best practice to store various fields in one table

Hi, I want to design a table for items. There are many types of items, all share several fields. Each type of item has it's own fields. I want to store the uncommon fields in a separate table. I thought of something like : ----Items +Item_id +Item_Type_Id +Item_Serial ... ----Item_types +Item_Type_Id +Item_Name ... ----Item_Fields +I...