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

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 2 million rows of data need the min

Author  Topic 

sharaiqa
Starting Member

7 Posts

Posted - 2007-02-06 : 09:27:29
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)

17689 Posts

Posted - 2007-02-06 : 09:29:28
is this T-SQL ?


KH

Go to Top of Page

sharaiqa
Starting Member

7 Posts

Posted - 2007-02-06 : 09:34:23
I am not sure... I am new to SQL
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-06 : 09:40:10
is this for Oracle ? This is a MS SQL Server forum


KH

Go to Top of Page

sharaiqa
Starting Member

7 Posts

Posted - 2007-02-06 : 09:42:05
yes... sorry for being in the wrong forum
Go to Top of Page

sharaiqa
Starting Member

7 Posts

Posted - 2007-02-06 : 09:44:28
Does anyone know what the correct forum is for Oracle/SQL?

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-06 : 09:46:27
try www.dbforums.com or just google for it


KH

Go to Top of Page

sharaiqa
Starting Member

7 Posts

Posted - 2007-02-06 : 09:50:49
thanks!
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-02-06 : 10:54:30
Continued: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=78660
Go to Top of Page
   

- Advertisement -