sql

SQL Server Drop Table

If you drop a table in SQL Server that has Keys, Indexes, Contraints, etc on it will it drop those as well? I was just wondering when I am building my scripts if I need to create drop scripts for all of those as well or if I can simply drop the tables? Thanks, S ...

What would be the relational way to store a tournament bracket in MySQL?

Right now I have a table for matches where each match has a reference to 2 competing participants and a winner, but there isn't a way to store the order of the rounds. ...

.Net - Email sent through outlook should update database

We have to build a small grievance report system. In this users enters their grievance on a ASP.Net page. An email is sent to particular individual of a department. When this individual opens this email in outlook and responds a field in a SQL server table needs to be updated. How to accomplish this SQL Server update? Platform : .Net...

How do I compare the results of two queries, and find matches between the two?

EDIT: Changed the question to be more clear. EDIT 2: The intention here to create an "add to list" and "remove from list" when outputting a catalog (I don't want a user to be able to add an item more than once) First of all, I'm not sure if this should be done in Coldfusion or MySQL. I have a query of items that retrieves items in a ...

How to implement Foursquare's "Mayor" feature - find the user with the highest score in the last N days?

In Foursquare, the user who has the highest score for a place in the last N days is awarded the Mayorship of that place. What is the most efficient way to implement that? A user could have checked into hundreds of places. To display all the mayorships that belong to a user, it'd be necessary to go through all those hundreds of places ...

Sql CommandTimeout set for EnterpriseLibrary

Hi, I have a sql query which takes longer than 30seconds to execute. I'm aware I need to set the CommandTimeout for the command object to overcome this. However, the first place the command object occurs is within the method 'LoadDataSet' within the Enterprise Library. I don't think I want to be modifying it here. Could someone please ...

nHibernate Linq join support; The method Join is not implemented

I am using the latest nHibernate.Linq 2.1.2. But if I use join in my linq query I will get run time error "The method Join is not implemented". Could someone tell me if join is supported by nHibernate.Linq and if it is supported what is the cause of this error? ...

Too many Database Calls

I have an auto refresh script that refreshes a page every 3 seconds. The page it refreshes ha few database queries. When I get 20 or more members on my site the server crashes because of all the calls to the database. Is there another way to check for changes in the database? //Can't Chat $strFind="SELECT * FROM cantchat"; $result=mysql...

SQL Server / Oracle : Private temporary tables

In Oracle, you can create a temp table using something like: CREATE GLOBAL TEMPORARY TABLE temp_table ( field1 NUMBER, field2 NUMBER ) ON COMMIT DELETE ROWS; ... which could be pretty nifty, as this creates a table visible to everyone, but the data one INSERTs into the table is visible only to him or her. Additionally, that da...

Is there a faster way to perform this mysql query?

Is there a faster way to perform this most simple query in terms of server load? I don't think I've ever tried anything other than this method: $sql = 'SELECT thing FROM table WHERE id="' . $id . '" '; $res = mysql_query($sql); $row = mysql_fetch_array($res); $thing = $row[0]; Any way to improve this? ...

How to save the last serial value in Postgres?

This is how I do in SQL Server: insert into users(name, password) values('admin', '1'); declare @id int; set @id = @@identity; insert into usersroles values(@id, 1); insert into usersroles values(@id, 2); @@identity is in sql server the last inserted identity (serial) How to do the same in Postgres? ...

mysql CREATE VIEW not working from mysql_query

I have a code to create VIEW in mysql database which is working fine on my local server. It creates and crop view normally. But on my Online server it gives error "CREATE VIEW command denied to user" for online database I manually create VIEW in Database form PHPmyAdmin [Myadmin is in localhost online] it creating, SO i have permissio...

database link in oracle 10g

I have two users System and jagan in oracle10g . I could display contents of table TAB (select *from tab) when i login as system.But i want same result when i login as jagan also.. database name is XE. Can somebody give me syntax to create database link from jagan to XE. ...

How to Nested Case in Select SQL?

I have this select Case SQL statement which compute the totalvolume of a given quantity. SELECT DropshipPackinglist.CaseNumber as 'CASE NO.', DropshipPackinglist.ItemNumber as 'BOM NO.', DropshipPackinglist.Quantity as 'QTY', CASE WHEN DropshipPackinglist.Quantity >=31 and DropshipPackin...

Oracle ceil for decimal numbers

When rounding up to 2 decimal places, the value 4.01132141 would be rounded to 4.02 because it exceeds 4.01. How can you do this in PL/SQL? ...

difference between varchar(500) vs varchar(max) in sql server

I want to know what are pros and cons while using varchar(500) vs varchar(max) in terms of performance, memory and anything else to consider? Will both use same amount of storage space? Is the answer differ in case of sql server 2000/2005/2008? ...

What is TAB in oracle10g why does not it display default table names for newly created user?

If I login as "system" then it shows default table names(select * from tab). But when I login as "jagan", if I run a query (select * from tab) it is not displaying...In order to display default tables from "jagan", what should I do? ...

How to get total number of products in virtuemart?

I want to display total number of products sold for each product. There are around 30 products in my virtue mart and I want each one's total sold number. Table named jos_vm_order_item contains product_id and product_quantity with all other information. How can I display this? Please Help me out its very urgent for me..... Thanks in a...

select statements how to read all from "*"

My statement: string sqlCommandText = "SELECT * FROM ForumThread WHERE"; How can I read * from it? I'm trying like this but its doesnt work: if (reader["*"] != DBNull.Value) { result.TextContent = Convert.ToString(reader["*"]); } ...

I would like to combine ROLLUP with PIVOT - is that an option?

I have been using SELECT Author, ISNULL(MAX(CASE Status WHEN 'Duplicate' THEN NumDocs END),'') AS Duplicate, ISNULL(MAX(CASE Status WHEN 'Failure' THEN NumDocs END),'') AS Failure, ISNULL(MAX(CASE Status WHEN 'Rejected' THEN NumDocs END),'') AS Rejected, ISNULL(MAX(CASE Status WHEN 'Success' THEN NumDocs END),'') AS...