Search results
Dec 31, 2019 · A stored procedure is a group of SQL statements that has been created and stored in the database. A stored procedure will accept input parameters so that a single procedure can be used over the network by several clients using different input data. A stored procedures will reduce network traffic and increase the performance.
CREATE PROCEDURE: "Avoid the use of the sp_ prefix when naming procedures. This prefix is used by SQL Server to designate system procedures. Using the prefix can cause application code to break if there is a system procedure with the same name." –
Stored procedures are simply T-SQL queries that are stored. Therefore, becoming more familiar with T-SQL and the various functions and syntaxes is really what you need to do. And even more so from a performance standpoint you will need to ensure that your queries and the underlying data structures match in a manner that allow for good performance.
CREATE PROCEDURE dept_count ( -- Add input and output parameters for the stored procedure here @dept_name varchar(20), --Input parameter @d_count int OUTPUT -- Output parameter declared with the help of OUTPUT/OUT keyword ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements.
Feb 5, 2013 · I want to search a text from all my database stored procedures. I use the below SQL: SELECT DISTINCT o.name AS Object_Name, o.type_desc FROM sys.sql_modules m INNER JOIN ...
Nov 4, 2009 · You can't add a WHERE clause to a stored procedure like this. You should put the clause in the sproc, like this: ALTER PROCEDURE [dbo].[myProc] @X VARCHAR(10) AS BEGIN SELECT * FROM myTable WHERE x=@X END GO The syntax for calling a stored procedure is through the use of EXECUTE not SELECT(e.g.): EXECUTE dbo.myProc 'a'
Feb 22, 2011 · If someone is stuck with SQL server 2000, the table sql_modules doesn't exist, so you would use syscomments, you will get multiple records for stored procdedures larger than 4000 characters, but they will have the same c.number field so you can group the parts together to get the full stored procedure text:
If a developer has a heavy SQL background, they might go with Stored Procs. If a developer has lots of app development experience, they might prefer queries in code. Personally, I think having queries in code can enable developers to move much faster and security concerns can be mitigated by ensuring teams are following best practices (e.g. parameterized queries, ORM).
Jun 19, 2012 · Use a table-valued parameter (TVP) to transmit an array (or list) from C# to a SQL Server stored procedure. Here's a step-by-step guide on how to accomplish this. Your SQL Server database must first have a user-defined table type created. The structure of your list or array will be represented by this type.
Jun 2, 2015 · yep - you can even nest the try catch statements as: BEGIN TRY SET @myFixDte = CONVERT(datetime, @myFixDteStr,101) END TRY BEGIN CATCH BEGIN TRY SET @myFixDte = CONVERT(datetime, @myFixDteStr,103) END TRY BEGIN CATCH BEGIN TRY SET @myFixDte = CONVERT(datetime, @myFixDteStr,104) END TRY BEGIN CATCH SET @myFixDte = CONVERT(datetime, @myFixDteStr,105) END CATCH END CATCH END CATCH