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 |
|
BendJoe
Posting Yak Master
128 Posts |
Posted - 2007-11-15 : 15:41:35
|
| I am trying to do the following.While inserting a record into a table I need one field to be created based on a stored procedure output.The stored procedure will create something like this, "XX-mm-yyyy-incremental number which resets to zero at the end of every month". All other field except the Identity field and the above mentioned storeproc generated field will be inputted manually. How can I do this?ThanksHope my question is clear enough. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-11-15 : 15:43:59
|
| well you could put the stored procedure output into a temp table and select from there, or you could add an output parameter to your sproc and use that._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
BendJoe
Posting Yak Master
128 Posts |
Posted - 2007-11-15 : 16:29:34
|
| Assuming that I use the second approach ie, specifying an output parameter for my stored proc. How will I include the stored proc output to my Insert Command.My Insert Command isINSERT INTO [Table] ([CODE], [TYPE], [ID]) VALUES (@CODE, @TYPE, @ID) Here CODE is the field which should be the output of the my Stored Proc.Thanks |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-11-15 : 16:51:07
|
| declare @CODE varchar(50) -- <- change to your datatype hereexec yourSproc @CODE outINSERT INTO [Table] ([CODE], [TYPE], [ID]) VALUES (@CODE, @TYPE, @ID)_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
|
|
|