Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Select data flow

SQL Select data flow

Scheduled Pinned Locked Moved Database
databasesysadmincsharpsql-serverquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Antonius_r3
    wrote on last edited by
    #1

    I have some questions regarding SQL select command, but first let me explain my condition first. I am a newbie in C# and SQL, and developing some window application with database connected from SQL Server. And the questions I have is when the select command only want to retreive some portions of data (one or two rows from hundreds of row from the same table). I know there are two type or methods of having the select command: stored procedure and non-stored procedure. For the stored procedure, the query is processed in the SQL Server, and return the result to the workstation. But for non-stored procedure select command, is it doing the same thing? or the query return all row of data to the workstation, and then the workstation process it after receive all the data? Since I have concern that my network will be overloaded if all the data are being transfered only to take one or some rows of data. Thank you very much in advance.

    G B 2 Replies Last reply
    0
    • A Antonius_r3

      I have some questions regarding SQL select command, but first let me explain my condition first. I am a newbie in C# and SQL, and developing some window application with database connected from SQL Server. And the questions I have is when the select command only want to retreive some portions of data (one or two rows from hundreds of row from the same table). I know there are two type or methods of having the select command: stored procedure and non-stored procedure. For the stored procedure, the query is processed in the SQL Server, and return the result to the workstation. But for non-stored procedure select command, is it doing the same thing? or the query return all row of data to the workstation, and then the workstation process it after receive all the data? Since I have concern that my network will be overloaded if all the data are being transfered only to take one or some rows of data. Thank you very much in advance.

      G Offline
      G Offline
      Grimolfr
      wrote on last edited by
      #2

      With an ad-hoc query (a query passed to the server, instead of using a stored proc) the SQL Server will still honor the where clause and only return the rows you want to the application. There are a couple of advantages to stored procs over ad-hoc queries: - ad-hoc queries have to be compiled every time you perform the query. Stored procedures are compiled, then the compiled version is re-used for some time, and re-evaluated/re-compiled only occasionally. This is a major benefit in high-volume systems. - depending on the app, sometimes it's possible to tweak performance and/or operation of an application with modifications to the stored procedure, without having to recompile the entire application to implement the change. - depending on the complexity of the query, sometimes it's simply easier to read the code when the SQL code is completely isolated from the C#/VB code, instead of the two being mixed together in the application. There are more benefits to procs, of course. And there are some benefits that ad-hoc queries have over procedures (although IMHO few and far between.) But I much prefer using procs. Mainly for the reasons listed above.


      Grim

      (aka Toby)

      MCDBA, MCSD, MCP+SB

      Need a Second Life?[^]

      SELECT * FROM user WHERE clue IS NOT NULL GO

      (0 row(s) affected)

      1 Reply Last reply
      0
      • A Antonius_r3

        I have some questions regarding SQL select command, but first let me explain my condition first. I am a newbie in C# and SQL, and developing some window application with database connected from SQL Server. And the questions I have is when the select command only want to retreive some portions of data (one or two rows from hundreds of row from the same table). I know there are two type or methods of having the select command: stored procedure and non-stored procedure. For the stored procedure, the query is processed in the SQL Server, and return the result to the workstation. But for non-stored procedure select command, is it doing the same thing? or the query return all row of data to the workstation, and then the workstation process it after receive all the data? Since I have concern that my network will be overloaded if all the data are being transfered only to take one or some rows of data. Thank you very much in advance.

        B Offline
        B Offline
        Bill Dean
        wrote on last edited by
        #3

        ADO.NET (your SqlDataAdapter, etc) is a disconnected system. Meaning, all the data is held and manipulate on the client. (Someone correct me if I am wrong here...) So, no matter how you structure your query, all the data goes to the client when you call the Fill method on your SqlDataAdapter. If you are concerned about swamping your connection, I suggest you write a more restrictive query, so that it only returns the rows you actually need. If you cannot tighten up the logic, you can try something like: select top 2 column1,column2, etc from YourTable Hope this helps, Bill

        A 1 Reply Last reply
        0
        • B Bill Dean

          ADO.NET (your SqlDataAdapter, etc) is a disconnected system. Meaning, all the data is held and manipulate on the client. (Someone correct me if I am wrong here...) So, no matter how you structure your query, all the data goes to the client when you call the Fill method on your SqlDataAdapter. If you are concerned about swamping your connection, I suggest you write a more restrictive query, so that it only returns the rows you actually need. If you cannot tighten up the logic, you can try something like: select top 2 column1,column2, etc from YourTable Hope this helps, Bill

          A Offline
          A Offline
          Antonius_r3
          wrote on last edited by
          #4

          Thank you very much for the reply. I guess from the reply, I understand it much more than before, and I think I am in the right path. In most of my query, I used ADO.NET, but restricted the select command to the columns and rows that I am interested in by using WHERE clause. My concern was, the network load of the select command. I was afraid that the ADO.NET select command retreive all the data and rows even I only selected one column or row. And then the client applied filter to the retreived data to get the data I wanted. But I guess I'm wrong. Again, thank you so much for the reply. It gives me very much information and knowledge about SQL.

          B M 2 Replies Last reply
          0
          • A Antonius_r3

            Thank you very much for the reply. I guess from the reply, I understand it much more than before, and I think I am in the right path. In most of my query, I used ADO.NET, but restricted the select command to the columns and rows that I am interested in by using WHERE clause. My concern was, the network load of the select command. I was afraid that the ADO.NET select command retreive all the data and rows even I only selected one column or row. And then the client applied filter to the retreived data to get the data I wanted. But I guess I'm wrong. Again, thank you so much for the reply. It gives me very much information and knowledge about SQL.

            B Offline
            B Offline
            Bill Dean
            wrote on last edited by
            #5

            SqlServer does the "selecting" so only the results of the query travel from the server to your client application. Bill

            A 1 Reply Last reply
            0
            • B Bill Dean

              SqlServer does the "selecting" so only the results of the query travel from the server to your client application. Bill

              A Offline
              A Offline
              Antonius_r3
              wrote on last edited by
              #6

              Yes, I understand it now. Thank you very much for the reply. :)

              1 Reply Last reply
              0
              • A Antonius_r3

                Thank you very much for the reply. I guess from the reply, I understand it much more than before, and I think I am in the right path. In most of my query, I used ADO.NET, but restricted the select command to the columns and rows that I am interested in by using WHERE clause. My concern was, the network load of the select command. I was afraid that the ADO.NET select command retreive all the data and rows even I only selected one column or row. And then the client applied filter to the retreived data to get the data I wanted. But I guess I'm wrong. Again, thank you so much for the reply. It gives me very much information and knowledge about SQL.

                M Offline
                M Offline
                Michael Potter
                wrote on last edited by
                #7

                Antonius_r3 wrote: My concern was, the network load of the select command. I was afraid that the ADO.NET select command retreive all the data and rows even I only selected one column or row. And then the client applied filter to the retreived data to get the data I wanted. But I guess I'm wrong. Just as a clarification: It is SQL Server that is lowering your network traffic not ADO.Net. If you sent the same query to a remote MSAccess MDB database (via ADO.Net) you would experience a much heavier network hit since the filtering would happen on the client.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups