[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

create a new stored procedure in SQL2012

Posted on 2014-08-08
4
Medium Priority
?
132 Views
Last Modified: 2014-08-21
I want to create a small stored procedure called UpdateOrderDate that runs this bit of code
How do I create it?

  update [TC_Integration].[dbo].[tbl_orderheaders]
  set createddate ='2014-01-06 09:38:08.000'
0
Comment
Question by:Chris Michalczuk
4 Comments
 
LVL 15

Expert Comment

by:Vikas Garg
ID: 40248187
Hi,

SP.jpg
Clicking on New procedure will open script window

SP2
Hope this would help
0
 
LVL 36

Expert Comment

by:ste5an
ID: 40248206
Caveat: This UPDATE will change every row in your table.
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 40248316
WHY would you create a stored procedure to sett ALL records of a table to a constant date/time value????????

Do you intent to have every record in that table "created" at '2014-01-06 09:38:08.000' no matter when you create them?

perhaps use

GETDATE()

instead??
0
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 40248543
In addition to the above excellent comments...
--  Note that the database name is NOT in the SP.   
--  That way if this is copied to a different db, it'll still work. 

USE TC_Integration   
GO

CREATE PROC UpdateOrderDate AS

/*
Hey looky here, meaningful code comments!!!

08-08-14   chrismichalczuk   Original.  Serves {some purpose}
*/

update tbl_orderheaders
set createddate ='2014-01-06 09:38:08.000'
GO

Open in new window

0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question