Want to build the ChatGPT based Apps? Start here
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Sathya Sambath
1.9k
284
99.9k
Create the Userdefine table ,Not insert the value into table
Mar 29 2018 1:42 AM
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
Reply
Answers (
1
)
How we return identity value from sql table
How to find median, 2nd standard deviation, min, max sql2008