sql

Help me with my SQL project (please).

Hey everyone, For this grading period, my CS teacher left us a open-choice project involving SQL and Delphi/VB. I ended up with the assignment of designing and building a program that allowed the users to, through a GUI in Delphi/VB, insert and read hurricane data pulled from a database (latest SQL Server, by the way). However, there...

SQL logic: two tables (group by?)

I have two tables, a table of movies (mt, the primary table), and a table listing where those movies are available (st, the secondary table). For each mt record, there are multiple st records. I need a query which will join the records, and allow me to run queries on both tables. I currently use an inner join like this: SELECT * FROM...

Counts for lots of boolean fields in one sql query?

Not sure exactly how to explain this but Imaging you have a table with lots of boolean fields like this...... Table: Cars Columns: Automatic: boolean Silver: boolean American: boolean Noisy: boolean Smelly: boolean fast: boolean (silly fields and most of them wouldn't be bools in reality but just an examp...

Duplicating / Unnecessary data in a SQL database.

When designing a new application/database for multiple users, it usually involves having a table for user management. The table usually always has Username as well as ID.... Just to check that I am not being an idiot (well, you may still think that!) I have just downloaded and taken a look at the schema of both MediaWiki and PHPBB, and...

IS (Intentional Shared) lock

Hi, can anyone give a simple example of a db transaction using an Intentional Shared lock, and (if can) one using an intentional exclusive lock. I'm studying them and trying to understand. Thanks ...

Fast way to eyeball possible duplicate rows in a table?

Similar: http://stackoverflow.com/questions/91784 I have a feeling this is impossible and I'm going to have to do it the tedious way, but I'll see what you guys have to say. I have a pretty big table, about 4 million rows, and 50-odd columns. It has a column that is supposed to be unique, Episode. Unfortunately, Episode is not unique...

SQL Date Format

How do I format a data in SQL to read like this: Monday, November, 23 2009 ...

Constraints instead Triggers (Specific question)

I read here some reasons to use constraints instead of triggers. But I have a doubt. How can be assure (using only constraints), the coherence between SUPERCLASS tables and SUBCLASSES tables? Whit a trigger is only a matter of check when INS.. UPD... Is there a way to define that kinda relation by using only constraints (I'm newbie at ...

Find last sunday

How will you find last sunday of a month in sql 2000? ...

Use Of Correlated Subquery.

Even though It has a performance issue, may I know what is the use of correlated subquery? ...

Does altering a session invalidate Pakage States in Oracle 10g?

Hi, I have a package that gets invalidated on a regular basis and found this in the code: ALTER SESSION CLOSE DATABASE LINK; Can this invalidate package states? Though I can't seem to replicate it. create or replace package body invalid_package_state_test is procedure test is TEMP VARCHAR2(1) := NULL; begin SELECT 'Y' INTO TEM...

Inserting 1000s of rows to SQL table using SSMS

Hello Everyone, I have a sql script with insert statements to insert 1000s of rows (12000 approx.). When i try running the script in SSMS, it throws 'Out of memory' exception after a while. "An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown." I have SQL Server 2008 o...

SQL Injection Vulnerability found

Hello All, Yesterday i received an email from a guy that our site is vulnerable to SQL injection. The email said: I tried some classic SQL injection on your server. This URL contains the result: http://www.mysite.com/ppreview.php?id=611111161%20and%201=0%20UNION%20all%20SELECT%201,2,3,4,password,6,7,8,9,10,11,12,13,14,15,16...

SQL not a single-group group function

When I run the following SQL statement: SELECT MAX(SUM(TIME)) FROM downloads GROUP BY SSN It returns the maximum sum value of downloads by a customer, however if I try to find the social security number that that max value belongs to by adding it to the select statement: SELECT SSN, MAX(SUM(TIME)) FROM downloads GROUP BY SSN I get ...

Querying entities which have a specific collection entry using HQL

I have Item objects which have a collection of attributes defined as a map. Now I want to retrieve all objects which have a specific attribute (by name, locale and value) An expecert of the Item mapping: <map table="ITEM_ATTRIBUTES" name="attributes"> <key column="item_id" foreign-key="fk_itmr_attrbts_itmrs"/> <composite-index clas...

Linq Entity Inheritance makes BIG SQL Sentences

We are developing an application with a base entity with more than 10 childs (which inherited from it). When we make any request with Linq to the base entity we get a SQL statement with a "UNION ALL" for each child. To make a Count() over the base entity it takes near one second and getting only one row can takes two seconds. For this ...

Cannot Delete a SQL job.

Hi, I have disabled log shipping on a SQL 2005 database and deleted the log shipping DB on the secondary server. However i cannot delete the LSRestore_DB___ job, either by T-SQL (sp_delete_log_shipping_primary_secondary, sp_delete_job) or using the management studio on the secondary server. It just wont go. The query keeps on executing f...

How visible/traceable is local CSV data queried from an ASP.NET page?

I want to have a page on a remote site that selects a local CSV file as a data source which outputs to a GridView. What is the format of the source data and how is it transferred to the server in this instance? Could it be retrieved in some way from a cache or the IIS logs? The data is mildly sensitive and I'd like to know the potenti...

Calling a procedure that uses reference cursors from another procedure?

How can I call a procedure that uses reference cursors from another procedure? ...

How to read an attribute of the XML.

DECLARE @XmlData xml SET @XmlData= '<?xml version="1.0" encoding="utf-8" ?> <ROOT PROCESS_DATE="25-Nov-2009" ROW_COUNT="2" VERIFY_TOTAL="654454.54"> <row rowNumber="1"> <Code1>11111</Code1> <Code2>AAAA </Code2> </row> <row rowNumber="2"> <Code1>2222</Code1> <Code2>BBBB </Code2> </row> </ROOT>' -- Foll...