I am trying to build a database using visual studio. But i saw that you can also use SQL server to do the job with stored procedures. Is it worth learning SQL server 2005 and stored procedures or can i code SQL straight to the sqlCommand when insert or select data?
5 Answers
It is better to learn new things. So you must learn SQL Server and STORED PROCEDURE because writing stored procedure is must to learn for a programmer.

- 21,570
- 27
- 74
- 94
-
cant i do stored procedure inside visual studio 2010 – Dmitry Makovetskiyd May 16 '11 at 12:57
-
@Dmitry Makovetskiyd: VS2010 also installs SQL Server Express. Srver Explorer is basically SQL Server Express. – Amit May 16 '11 at 13:01
-
oooh, but i saw video tutorials, that connect to sql server express. may be it was the old visual studio edition..(visual studio 2005) – Dmitry Makovetskiyd May 16 '11 at 13:04
-
@Dmitry Makovetskiyd:you can write stored procedure in VS http://msdn.microsoft.com/en-us/library/zxsa8hkf.aspx – Amit May 16 '11 at 13:04
-
@Dmitry Makovetskiyd: As you can see in last comment's link it is hard to write SP in C# than in SQL Server. You are writing almost double code in C#. So it is better to learn SQL Server, believe me it is easy. – Amit May 16 '11 at 13:33
-
i believe you.. does it matter if i use SQL Server 2005 or 2008? – Dmitry Makovetskiyd May 16 '11 at 13:44
-
@Dmitry Makovetskiyd: Yes Sql Server 2008 has some new features and some new datatypes like 2005 has only `DateTime` but 2008 has `DateTime` as well as `Date` and `Times`. But main T-SQL almost same. – Amit May 16 '11 at 13:48
-
are there any advantages of using SQL server over visual studio 2010? – Dmitry Makovetskiyd May 16 '11 at 13:52
-
@Dmitry Makovetskiyd: I think you are taking unnecessary burden, here learning SQL Server means learning T-SQL. Which is must. – Amit May 16 '11 at 14:02
-
T SQL is a table SQL. well, if you say it isnt difficult, i will learn it. it cant be more difficult than c# which i already know – Dmitry Makovetskiyd May 16 '11 at 14:36
-
To start there are two links for you [Wikipedia](http://en.wikipedia.org/wiki/Transact-SQL) and [MSDN](http://msdn.microsoft.com/en-us/library/aa299742(v=SQL.80).aspx) – Amit May 16 '11 at 14:40
-
, no, thomas thank you, i have downloaded two books. one on SQL querry and the other on stored procedures – Dmitry Makovetskiyd May 16 '11 at 14:42
-
But MSDN link is good for quick reference. Anyway best of luck for T-SQL journey :) – Amit May 16 '11 at 14:46
Either approach will work.
There is already a SO Post here discussion the benefits of either approach.
Given that you must already have some SQL DML knowledge, you can code inserts, selects and updates, why not go further and learn more. In my experience SQL has been the one language which has remained relatively constant throughout my career.
-
so if i work with visual studio alone, will i be able to use stored procedures. how do i compose stored procedures in Visual studio? – Dmitry Makovetskiyd May 16 '11 at 13:02
-
Yes, you can code Stored Procs in VS and then deploy them to a SQL database using a Database Project - see http://msdn.microsoft.com/en-us/library/ff678491.aspx – StuartLC May 16 '11 at 13:08
-
I believe learning stored procedures is a valuable skill. I've seen developers write hundreds of lines of code when to do data manipulations that would have been simple to express in a SQL statement and ran as a stored procedure.

- 101
- 4
My understanding is that Stored Procedures ("sproc's") are often more efficient than the equivelent in-line SQL, because they are pre-optimized by the database engine.
Further, you can perform multiple actions with a stored procedure, and include conditional logic that is difficult to do effectively from in-line code.
In terms of implementing da logic, an sproc is a sensible place to do it. While you CAN accomplish many of the things you might want to do in-line, the database engine is specifically designed to perform certain types of operation very, very efficiently. Stored Procedures enable you to push the heavy lifting related to data access where it belongs (on the server) and keep your client code doing what IT is supposed to do. Namely, applying business ruiles to the use of the data.
I strongly recommend investing a little time learning your way around SQL Server Management Studios (SSMS) and the construction of Stored Procedures.

- 4,442
- 19
- 24
-
But i have my tables written in VS. Do i have to re-write them?!/1 – Dmitry Makovetskiyd May 16 '11 at 13:22
-
From what it sounds like, you have SQL statements in your VS code which *execute* against your tables. Your tables exist on the SQL Server instance. You would want to take the code used in your vs front end and incorporate it into sprocs on the back end. – XIVSolutions May 17 '11 at 01:50
-
I strongly recommend it. As someone else in this thread pointed out; SQL has been one to the most stable languages. Knowing how to use SQL (be it SQL Server, Oracle, MySQL, etc) can only add to your strength as a programmer. – XIVSolutions May 17 '11 at 01:52
Using Stored Procedure in contrast of inline query is a better option in most of the cases. And if you want to make application that uses a database, it is important for you to have hands on Store procedures and atleast some understanding of SQL Server. Hope I answer your question.

- 6,537
- 2
- 25
- 38
-
i can see that i can add a new query when i set a database. can i write it in sql and then take it out of there? and feed it to my sql command – Dmitry Makovetskiyd May 16 '11 at 13:00
-
Why would you want to do that? Create a Stored Procedure, then feed the name of the sproc (along with any parameters) to your command. This neatly decouples your data acceess from your logic. – XIVSolutions May 17 '11 at 01:56