CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    [RESOLVED] SqlServer [2008] Stored Proc. Info needed..

    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...
    Code:
    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...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  2. #2
    Join Date
    Sep 2006
    Posts
    95

    Re: SqlServer [2008] Stored Proc. Info needed..

    Code:
    SELECT City
    FROM Table
    GROUP BY City
    Cake.
    On Error Kill(User)

  3. #3
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: SqlServer [2008] Stored Proc. Info needed..

    Quote Originally Posted by GremlinSA
    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...
    Code:
    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.

  4. #4
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: SqlServer [2008] Stored Proc. Info needed..

    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....
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  5. #5
    Join Date
    Sep 2006
    Posts
    95

    Re: [RESOLVED] SqlServer [2008] Stored Proc. Info needed..

    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.
    On Error Kill(User)

  6. #6
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: [RESOLVED] SqlServer [2008] Stored Proc. Info needed..

    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....


    Now looks like this.....


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

    Gremmy...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured