|
genubath12
Starting Member
2 Posts |
Posted - 2007-03-08 : 21:27:34
|
| Hey all, I have been working with Northwind on SQL Server ExpressTrying to learn Transact-SQL. I am stuck at this point from code in the instruction manual. I don't know if I have a permission set to something that I need or what but I get the following error that is outlined at the bottom of the code. Any help would be appreciated.USE NorthwindGOALTER PROC spInsertDateValidatedOrder @CustomerID nvarchar(5), @EmployeeID int, @OrderDate datetime = NULL, @RequiredDate datetime = NULL, @ShippedDate datetime = NULL, @ShipVia int, @Freight money, @ShipName nvarchar(60) = NULL, @ShipAddress nvarchar(40) = NULL, @ShipCity nvarchar(15) = NULL, @ShipRegion nvarchar(15) = NULL, @ShipPostalCode nvarchar(10) = NULL, @ShipCountry nvarchar(15) = NULL, @OrderID int OUTPUTAS DECLARE @InsertedOrderDate smalldatetime--Test to see if supplied date is over seven days old. If so--replace with NULL value otherwise, truncate the time to be midnight.IF DATEDIFF(dd, @OrderDate, GETDATE()) > 7BEGIN SELECT @InsertedOrderDate = NULL PRINT 'Invalid Order Date' PRINT 'Supplied Order Date was greater than 7 days old' PRINT 'The value has been reset to NULL'ENDELSEBEGIN SELECT @InsertedOrderDate = CONVERT(datetime, (CONVERT(varchar,@OrderDate, 112))) PRINT 'The Time of Day in Order Date was truncated'END--create the new recordINSERT INTO OrdersVALUES( @CustomerID, @EmployeeID, @InsertedOrderDate, @RequiredDate, @OrderDate, @ShippedDate, @ShipVia, @Freight, @ShipName, @ShipAddress, @ShipCity, @ShipRegion, @ShipPostalCode, @ShipCountry)--Move the identity value from the newly inserted record into output variable.SELECT @OrderID = @@IDENTITYErrors received,Msg 8101, Level 16, State 1, Procedure spInsertDateValidatedOrder, Line 46An explicit value for the identity column in table 'Orders' can only be specified when a column list is used and IDENTITY_INSERT is ON. Thanks |
|