Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Unanswered: Stored Procedure

    I think I am finally starting to understand stored procedures..this is an example of one I did. Its suppose to Insert to one table (TERMINATION) from the other (GamingCommissiondb), please let me know if I did this correctly. Think what I was doing wrong was no @@Identity. Let me know if this is ok

    Code:
    CREATE PROCEDURE [insert_TERMINATION_1]
    	(@TM_#_1 	[int],
    	 @FirstName_2 	[nvarchar],
    	 @LastName_3 	[nvarchar],
    	 @SocialSecurityNumber_4 	[int],
    	 @DateHired_5 	[datetime],
    	 @Status_6 	[nvarchar],
    	 @TM_#_7 	[int],
    	 @FirstName_8 	[nvarchar](50),
    	 @LastName_9 	[nvarchar](50),
    	 @SocialSecurityNumber_10 	[int],
    	 @DateHired_11 	[datetime],
    	 @Status_12 	[nvarchar](50),
    	 @TerminationDate_13 	[datetime],
    	 @Title_14 	[nvarchar](50),
    	 @DepartmentName_15 	[nvarchar](50),
    	 @Reasonfortermination_16 	[ntext],
    	 @VoluntaryorInvoluntary_17 	[nvarchar](50),
    	 @ConditionalLicense_18 	[nvarchar](50),
    	 @LicenseDenial_19 	[nvarchar](50),
    	 @Revocaion_20 	[nvarchar](50),
    	 @EmployeeFine_21 	[nvarchar](50),
    	 @Licensesuspension_22 	[nvarchar](50))
    
    AS INSERT [GamingCommissiondb].[dbo].[TERMINATION] 
    
    SET  [TM #]	 = @TM_#_7,
    	 [FirstName]	 = @FirstName_8,
    	 [LastName]	 = @LastName_9,
    	 [SocialSecurityNumber]	 = @SocialSecurityNumber_10,
    	 [DateHired]	 = @DateHired_11,
    	 [Status]	 = @Status_12,
    	 [TerminationDate]	 = @TerminationDate_13,
    	 [Title]	 = @Title_14,
    	 [DepartmentName]	 = @DepartmentName_15,
    	 [Reasonfortermination]	 = @Reasonfortermination_16,
    	 [VoluntaryorInvoluntary]	 = @VoluntaryorInvoluntary_17,
    	 [ConditionalLicense]	 = @ConditionalLicense_18,
    	 [LicenseDenial]	 = @LicenseDenial_19,
    	 [Revocaion]	 = @Revocaion_20,
    	 [EmployeeFine]	 = @EmployeeFine_21,
    	 [Licensesuspension]	 = @Licensesuspension_22 
    
    WHERE 
    	( [TM #]	 = @TM_#_1 AND
    	 [FirstName]	 = @FirstName_2 AND
    	 [LastName]	 = @LastName_3 AND
    	 [SocialSecurityNumber]	 = @SocialSecurityNumber_4 AND
    	 [DateHired]	 = @DateHired_5 AND
    	 [Status]	 = @Status_6)
    GO

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    I think you confused your INSERT with UPDATE a little. Your INSERT looks like UPDATE. What was your original intent?
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  3. #3
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Ok

    My original intent was to INSERT(APPEND) not to update

    thank you for responding

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •