Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Brittney10
Posting Yak Master
154 Posts |
Posted - 2011-02-28 : 12:05:01
|
I need a stored proc that will insert and update records. First it needs to insert data into the Customers table, then update fields in Customers table from another existing table. Create procedure myproc( @name nvarchar(50),@address nvarchar(75), @phone nvarchar(20))ASinsert into Customers (name,address,phone, date)values(@name, @address, @phone, getdate())--need to put several update statements here. |
|
|
KlausEngel
Yak Posting Veteran
85 Posts |
Posted - 2011-02-28 : 12:19:12
|
| so what exactly is your question...? |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-02-28 : 12:20:15
|
So where is the problem?We can't help without having any information about your table structure... No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Brittney10
Posting Yak Master
154 Posts |
Posted - 2011-02-28 : 12:55:06
|
| Really all i need to know is the syntax of the stored proc. with both the insert and update statements. |
 |
|
|
KenW
Constraint Violating Yak Guru
391 Posts |
Posted - 2011-02-28 : 14:03:53
|
| Really, all we need is the info webfred asked you to provide.Seriously, if you don't want to provide the information to use to answer your questions then you shouldn't ask the question. If you're too busy to provide the information to us, why should we spend the time providing an answer to you? |
 |
|
|
mandm
Posting Yak Master
120 Posts |
Posted - 2011-02-28 : 16:22:19
|
| Also, why not make it so that you combine both pieces together and just do it in one insert step. If we have more information we can recommend a better solution. |
 |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-03-01 : 10:45:59
|
quote: Originally posted by Brittney10 Really all i need to know is the syntax of the stored proc. with both the insert and update statements.
Ok ok .. never mind .. let me give you the query .. Create procedure xyz value1 datatype,value2 datatype,...,ValueN datatypeasInsert into TableName (Col1,Col2,...,ColN) Values (Value1,Value2,...,ValueN) Update TableName Set Col1=<some value>,Col2=<SomeValue>,...,ColN=<some value>Where <condition if required>Hope your query is resolved now as this is how the syntax is ... CheersMIK |
 |
|
|
|
|
|
|
|