Hi,
I have create table and user defined the table. Please clarify the error.
Below the procedure,table,output and error also.
Table field are:
- Create table UpdatePatientdetails
- (
- PatientID int Not NULL,
- FieldChange varchar(255),
- NewValue varchar(255),
- OldValue varchar(255),
- CRDateTime datetime ,
- UserName varchar(200),
- )
User Defined Table
- CREATE TYPE [dbo].[UpdatePatienttable8] AS TABLE(
- [PatientID] [int] NOT NULL,
- [FieldChange] [varchar](255),
- [NewValue] [varchar](255) ,
- [OldValue] [varchar](255) ,
- [CRDateTime] [datetime] ,
- [UserName] [varchar](200)
- )
- GO
Stored Procedures:
- ALTER PROCEDURE [dbo].[Update_PatientDetails_SP]
- (
- @ptype char(1) = NULL,
- @UpdatePatient1 [dbo].[UpdatePatienttable8] READONLY
- )
- AS
- IF (@ptype='UP')
- BEGIN
- INSERT INTO UpdatePatientdetails
- (
- PatientID,
- FieldChange,
- NewValue,
- OldValue,
- CRDateTime,
- [UserName]
- )
- SELECT * FROM @UpdatePatient1
- END
- Execute the Procedure:
- DECLARE @MyUserDTableType UpdatePatienttable8
- INSERT INTO @MyUserDTableType VALUES (1, 'name','sa','ser',GETDATE(),'xxx')
- INSERT INTO @MyUserDTableType VALUES (2,'name','sa','sere',GETDATE() ,'xxx')
- INSERT INTO @MyUserDTableType VALUES (3, 'name','sa','sera',GETDATE(),'xx')
- INSERT INTO @MyUserDTableType VALUES (4, 'fathername','sas','ser',GETDATE() ,'xxx')
- EXECUTE [Update_PatientDetails_SP] @MyUserDTableType
After execute
(1 row(s) affected)
(1 row(s) affected)
Msg 206, Level 16, State 2, Procedure Update_PatientDetails_SP, Line 0
Operand type clash: UpdatePatienttable8 is incompatible with char