Click to See Complete Forum and Search --> : [RESOLVED] SqlServer [2008] Stored Proc. Info needed..


GremlinSA
April 24th, 2008, 04:14 AM
I can do some simple stored proc's, however for the project that i'm busy with i need a 'Special' Stored proc to return Unique entries from a specific col..

I have a table with Suburbs, Postal code, and City... Uid Suburb Code City

1 Que 2015 JHB
2 Kelvin 2017 JHB
3 Turf 2091 JHB
4 Bla 3082 VDB

So i need to select all unique City's from the DB to populate a Combobox.

I've previously done this all within the app or used a seperate DB to hold the City, however in this app i'm following the clients 'Preset' layout and trying to follow as close as posible...

Thanks ...

Gremmy...

KrisSimonis
April 24th, 2008, 06:28 AM
SELECT City
FROM Table
GROUP BY City


Cake.

Alsvha
April 24th, 2008, 07:32 AM
I can do some simple stored proc's, however for the project that i'm busy with i need a 'Special' Stored proc to return Unique entries from a specific col..

I have a table with Suburbs, Postal code, and City... Uid Suburb Code City

1 Que 2015 JHB
2 Kelvin 2017 JHB
3 Turf 2091 JHB
4 Bla 3082 VDB

So i need to select all unique City's from the DB to populate a Combobox.

I've previously done this all within the app or used a seperate DB to hold the City, however in this app i'm following the clients 'Preset' layout and trying to follow as close as posible...

Thanks ...

Gremmy...

I think DISTINCT is the keyword for you.

GremlinSA
April 24th, 2008, 07:36 AM
Thanks a mil Kris...

Maybe a piece of cake for you ... I've been doing stored proc's for a month now, with out any sort of guidance.. Just chucked into the deep end.. The .NET side of it i got licked...

Lucky 99% of the project is .NET, with only a few 'Special' calls to SQL....

I need this type of Select statment for 3 Stored Proc's....

Now at least i can continue on it ... :)

Gremmy....

KrisSimonis
April 24th, 2008, 07:57 AM
Sorry, didn't mean to be nasty. and don't worry.

Here in the deep end, We.. All.. Float.. Gremmy..

Best place to learn it IMHO. Oh, something you might want to check out if you're new to SQL, if it's MS SQL, open your query analyser, type your basic SELECT and hit F1. The Help files of MS SQL are VERY good in my opinion.
Quite exhaustive descriptions of everything, just have to learn the keywords. SELECT, in this case, will show you the full description of the syntax of a SELECT statement. ( duh ), with all the neato tricks you can do to it. and from there, you can read up all the other cool stuff you can do.
In this case for instance, like Alsvha said. DISTINCT would work nicely too.
Take an afternoon reading syntax and examples, browse around in that helpfile and you'll learn a ton.

GremlinSA
April 24th, 2008, 11:03 AM
Not to worry , I know it was not meant to be nasty. And i'm getting used to the deep end ... I've also just found how to merge columbs in a Stored proc ..

So from this....
http://i141.photobucket.com/albums/r78/Gremlinsa/other/DGVselect2.jpg

Now looks like this.....
http://i141.photobucket.com/albums/r78/Gremlinsa/other/DGVselect3.jpg

I'm starting to do more than just float now...

Gremmy...