Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 2 million rows of data need the min
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sharaiqa
Starting Member

7 Posts

Posted - 02/06/2007 :  09:27:29  Show Profile  Send sharaiqa a Yahoo! Message  Reply with Quote
I have 2 million rows of data. I am trying to use this select statement but I can't seem to get it to work. I need three examples of each state by state_code. Can someone look at this and tell me what I am doing wrong...

EXEC SQL BEGIN DECLARE SECTION;
v_counter INTEGER DEFAULT 0;
v_given VARCHAR(12);
v_surname CHAR(22);
v_surname VARCHAR(60);
v_city VARCHAR(13);
v_state VARCHAR(2);
v_zip VARCHAR(5);
v_census_tract VARCHAR(12);
v_matchcode VARCHAR(22);
v_state VARCHAR(2);
v_state_code VARCHAR(2);
v_c1 CURSOR FOR
EXEC SQL END DECLARE SECTION;
SELECT given, surname, address, city, state, zip, census_tract, matchcode, state_code, state
FROM ethnic_vendor_data;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET counter = -1;
OPEN c1;
fetch_loop:
LOOP
FETCH c1 INTO v_given; v_surname; v_lastname; v_surname; v_city; v_state; v_zip; v_census_tract; v_matchcode; v_state; v_state_code;
IF v_state = ' ' THEN
LEAVE fetch_loop;
END IF;
SET v_counter = v_counter + 1;
END LOOP fetch_loop;
SET counter = v_counter;
CLOSE c1;
BEGIN
...
END;

khtan
In (Som, Ni, Yak)

Singapore
17689 Posts

Posted - 02/06/2007 :  09:29:28  Show Profile  Reply with Quote
is this T-SQL ?


KH

Go to Top of Page

sharaiqa
Starting Member

7 Posts

Posted - 02/06/2007 :  09:34:23  Show Profile  Send sharaiqa a Yahoo! Message  Reply with Quote
I am not sure... I am new to SQL
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17689 Posts

Posted - 02/06/2007 :  09:40:10  Show Profile  Reply with Quote
is this for Oracle ? This is a MS SQL Server forum


KH

Go to Top of Page

sharaiqa
Starting Member

7 Posts

Posted - 02/06/2007 :  09:42:05  Show Profile  Send sharaiqa a Yahoo! Message  Reply with Quote
yes... sorry for being in the wrong forum
Go to Top of Page

sharaiqa
Starting Member

7 Posts

Posted - 02/06/2007 :  09:44:28  Show Profile  Send sharaiqa a Yahoo! Message  Reply with Quote
Does anyone know what the correct forum is for Oracle/SQL?

Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17689 Posts

Posted - 02/06/2007 :  09:46:27  Show Profile  Reply with Quote
try www.dbforums.com or just google for it


KH

Go to Top of Page

sharaiqa
Starting Member

7 Posts

Posted - 02/06/2007 :  09:50:49  Show Profile  Send sharaiqa a Yahoo! Message  Reply with Quote
thanks!
Go to Top of Page

Kristen
Test

United Kingdom
22859 Posts

Posted - 02/06/2007 :  10:54:30  Show Profile  Reply with Quote
Continued: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=78660
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000