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.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 How to insert unicode using procedure

Author  Topic 

dophuong_cs
Starting Member

15 Posts

Posted - 2015-02-04 : 06:44:28
Dear all,
I have 1 problem with insert unicode character in sql server 2012.
I have 1 procedure as below:

[Code]
USE [ECN_System]
GO
/****** Object: StoredProcedure [dbo].[Pro_Insert_Update_CRGQA] Script Date: 2/4/2015 6:41:30 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[Pro_Insert_Update_CRGQA]
@Ecn_Part_Det_Id nvarchar(30),
@Need_Awi nvarchar(300),
@Awi_No nvarchar(300),
@Change_Jig nvarchar(300),
@Awi_Date nvarchar(300),
@Awi_Pic_Issue nvarchar(300),
@Eval_Std_Date nvarchar(300),
@Eval_Std_Pic_Issue nvarchar(300),
@Ss_Cecp_Appr_Result nvarchar(300),
@Ss_Cecp_Appr_Date nvarchar(300),
@user varchar(20)
AS
BEGIN
SET NOCOUNT ON;
declare
@v_kt int,
@v_id int;
select @v_id=dt.Ecn_Part_Det_Id from ECN_PART_DETAIL dt where dt.Ecn_Part_Cover_Id=@Ecn_Part_Det_Id;
select @v_kt=count(*) from ECN_CRG_QA t where t.Ecn_Part_Det_Id=@v_id;
if(@v_kt !=0)
begin
update ECN_CRG_QA set
Need_Awi=@Need_Awi ,
Awi_No=@Awi_No ,
Change_Jig=@Change_Jig ,
Awi_Date=@Awi_Date ,
Awi_Pic_Issue=@Awi_Pic_Issue ,
Eval_Std_Date=@Eval_Std_Date ,
Eval_Std_Pic_Issue=@Eval_Std_Pic_Issue ,
Ss_Cecp_Appr_Result=@Ss_Cecp_Appr_Result ,
Ss_Cecp_Appr_Date=@Ss_Cecp_Appr_Date ,
User_Update=@user,
Date_Update=getdate()
where Ecn_Part_Det_Id=@v_id ;

end
else
begin
insert into ECN_CRG_QA
values(@v_id ,
@Need_Awi ,
@Awi_No ,
@Change_Jig ,
@Awi_Date ,
@Awi_Pic_Issue ,
@Eval_Std_Date ,
@Eval_Std_Pic_Issue ,
@Ss_Cecp_Appr_Result ,
@Ss_Cecp_Appr_Date ,
@user,
getdate(),
Null,
Null);
end

END

[/Code]

In my table also data type is nvarchar(max).
However when i using above procedure with parameter input unicode character, after insert, can not see correct data.
How to solve this problem??

Phuong

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-02-04 : 09:25:36
please post:

1. the table definition (CREATE TABLE statement)
2. the statement that calls your procedure (EXEC [dbo].[Pro_Insert_Update_CRGQA] ...)
3. The resulting row updated or inserted in the target table ECN_CRG_QA
Go to Top of Page

dophuong_cs
Starting Member

15 Posts

Posted - 2015-02-04 : 20:48:34
quote:
Originally posted by gbritton

please post:

1. the table definition (CREATE TABLE statement)
2. the statement that calls your procedure (EXEC [dbo].[Pro_Insert_Update_CRGQA] ...)
3. The resulting row updated or inserted in the target table ECN_CRG_QA



Hi gbritton,
Thank you very much!
I will post content as your request:
1. Table definition
[Code]
CREATE TABLE [dbo].[ECN_CRG_QA](
[Ecn_Part_Crg_Qa_Id] [int] IDENTITY(1,1) NOT NULL,
[Ecn_Part_Det_Id] [int] NULL,
[Need_Awi] [nvarchar](100) NULL,
[Awi_No] [nvarchar](100) NULL,
[Change_Jig] [nvarchar](100) NULL,
[Awi_Date] [nvarchar](50) NULL,
[Awi_Pic_Issue] [nvarchar](100) NULL,
[Eval_Std_Date] [nvarchar](50) NULL,
[Eval_Std_Pic_Issue] [nvarchar](100) NULL,
[Ss_Cecp_Appr_Result] [nvarchar](100) NULL,
[Ss_Cecp_Appr_Date] [nvarchar](50) NULL,
[User_Entry] [varchar](100) NULL,
[Date_Entry] [datetime] NULL,
[User_Update] [varchar](100) NULL,
[Date_Update] [datetime] NULL,
CONSTRAINT [PK_ECN_CRG_QA] PRIMARY KEY CLUSTERED
(
[Ecn_Part_Crg_Qa_Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [ECN_PART_CRG_QA_UK] UNIQUE NONCLUSTERED
(
[Ecn_Part_Det_Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[ECN_CRG_QA] ADD CONSTRAINT [DF_ECN_CRG_QA_Date_Entry] DEFAULT (getdate()) FOR [Date_Entry]
GO
[/Code]

2. Statement call procedure from asp.net

[Code]
public ActionResult CRGQASaveUpdate(int id, string Txt_Need_AWI, string Txt_AWI_No, string Txt_Change_Jig, string Txt_AWI_Date,
string Txt_Awi_Pic_Issue, string Txt_Eval_Std_Date, string Txt_Eval_Std_Pic_Issue, string Txt_SSCECP_Result, string Txt_Ss_Cecp_Appr_Date, string Txt_Ecn_No)
{
conn.Close();
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "Pro_Insert_Update_CRGQA";
cmd.Parameters.Add(new SqlParameter("@Ecn_Part_Det_Id ", id));
cmd.Parameters.Add(new SqlParameter("@Need_Awi", Txt_Need_AWI));
cmd.Parameters.Add(new SqlParameter("@Awi_No", Txt_AWI_No));
cmd.Parameters.Add(new SqlParameter("@Change_Jig", Txt_Change_Jig));
cmd.Parameters.Add(new SqlParameter("@Awi_Date", Txt_AWI_Date));
cmd.Parameters.Add(new SqlParameter("@Awi_Pic_Issue", Txt_Awi_Pic_Issue));
cmd.Parameters.Add(new SqlParameter("@Eval_Std_Date", Txt_Eval_Std_Date));
cmd.Parameters.Add(new SqlParameter("@Eval_Std_Pic_Issue", Txt_Eval_Std_Pic_Issue));
cmd.Parameters.Add(new SqlParameter("@Ss_Cecp_Appr_Result", Txt_SSCECP_Result));
cmd.Parameters.Add(new SqlParameter("@Ss_Cecp_Appr_Date", Txt_Ss_Cecp_Appr_Date));
cmd.Parameters.Add(new SqlParameter("@user", Session["SessionUserID"]));
SqlDataReader da = cmd.ExecuteReader();
conn.Close();
return RedirectToAction("CRGQA_Detail_Page", new { Txt_Ecn_No = Txt_Ecn_No });
}
[/Code]
With all parameter from Form's input data.

3. Result after insert data

[Code]
Ch? th? t? ASSY ph?i du?c th?c
[/Code]
=> Can't show unicode character



Phuong
Go to Top of Page
   

- Advertisement -