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 |
|
hasanali00
Posting Yak Master
207 Posts |
Posted - 2006-01-27 : 09:40:31
|
| HiI have written the following SP, but I am not sure if this is the correct way to write the stateemnt:CREATE PROCEDURE spv_Products_InsertDuplicateCategory@OldCategoryID int,@VerifiedBy nvarchar (50),@DateModified datetime,@CategoryID int OUTPUTASDECLARE @TempCatTypeID int -- get the category type id. we need it to duplicate the dataSELECT @TempCatTypeID = CategoryTypeID FROM Categories WHERE CategoryID = @OldCategoryID INSERT INTO Categories (Name, Description, VerifiedBy, DateModified)Select Name, Description, @VerifiedBy, @DateModifiedfrom Categories where categoryID = @OldCategoryID SET @CategoryID = @@IDENTITYGOThen I am trying to run it like:declare @CategoryID intexec spv_Products_InsertDuplicateCategory 25, 'q9', getdate, @CategoryID outputprint @CategoryIDHowever, I am getting some errors when I run the SP. I am not sure if its the SP that is wrong or the way I am running it.Would be grateful if u can help.regards |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-27 : 09:45:29
|
| Try thisdeclare @CategoryID intdeclare @Date DateTimeset @Date=getdate()exec spv_Products_InsertDuplicateCategory 25, 'q9', @Date, @CategoryID outputprint @CategoryIDMadhivananFailing to plan is Planning to fail |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-01-27 : 09:50:08
|
NOthing is wrong with your SP syntax, but when you call your Sp, make sure you pass all the parameters it requires. Also see the correct code for getdate()declare @CategoryID intexec spv_Products_InsertDuplicateCategory 25, @CategoryID, 'q9', getdate(), @CategoryID outputprint @CategoryID |
 |
|
|
hasanali00
Posting Yak Master
207 Posts |
Posted - 2006-01-27 : 09:52:21
|
| thanks a lotA very quick reply, as ever. |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-01-27 : 09:54:20
|
Sorry i corrected the codequote: Originally posted by afrika NOthing is wrong with your SP syntax, but when you call your Sp, make sure you pass all the parameters it requires. Also see the correct code for getdate()declare @CategoryID intexec [spv_Products_InsertDuplicateCategory 25], @OldCategoryID, 'q9', getdate(), @CategoryID outputprint @CategoryID
|
 |
|
|
hasanali00
Posting Yak Master
207 Posts |
Posted - 2006-01-27 : 10:04:22
|
| thanks a lotA very quick reply, as ever. |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-01-27 : 10:10:16
|
Is it ok now ?Hello madhivanan, must be around 9pm your time ? Slam on your brakes |
 |
|
|
|
|
|
|
|