UNINSTALL OR COMPLETELY REMOVE MYSQL FROM UBUNTU 16-04

While upgrading from ubuntu 16.04.1 to ubuntu 16.04.03, we had face once issue that we unexpected.

This incident are cause by mysql server update, while setting up the mysql by apt, its hang on the server and will not work for leaving it around one hours.

So we decide to remove the mysql server and reinstall again, below are the step that we were done.

  1. sudo apt-get remove --purge mysql*
  2. sudo apt-get purge mysql*
    
  3. sudo apt-get autoremove
  4. sudo apt-get autoclean
  5. sudo apt-get remove dbconfig-mysql
  6. sudo apt-get dist-upgrade
  7. sudo apt-get install mysql-server
    
    
    Source:https://linuxscriptshub.com

Chapter 3 Resetting the Root Password: Windows Systems

On Windows, use the following procedure to reset the password for the MySQL 'root'@'localhost' account. To change the password for a root account with a different host name part, modify the instructions to use that host name.

  1. Log on to your system as Administrator.
  2. Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list and stop it.

    If your server is not running as a service, you may need to use the Task Manager to force it to stop.

  3. Create a text file containing the password-assignment statement on a single line. Replace the password with the password that you want to use.

    MySQL 5.7.6 and later:

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

    MySQL 5.7.5 and earlier:

    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
  4. Save the file. This example assumes that you name the file C:\mysql-init.txt.
  5. Open a console window to get to the command prompt: From the Start menu, select Run, then enter cmd as the command to be run.
  6. Start the MySQL server with the special --init-file option (notice that the backslash in the option value is doubled):
    C:\> cd "C:\Program Files\MySQL\MySQL Server 5.7\bin"
    C:\> mysqld --init-file=C:\\mysql-init.txt

    If you installed MySQL to a different location, adjust the cd command accordingly.

    The server executes the contents of the file named by the --init-file option at startup, changing the'root'@'localhost' account password.

    To have server output to appear in the console window rather than in a log file, add the --console option to themysqld command.

    If you installed MySQL using the MySQL Installation Wizard, you may need to specify a --defaults-file option. For example:

    C:\> mysqld
             --defaults-file="C:\\ProgramData\\MySQL\\MySQL Server 5.7\\my.ini"
             --init-file=C:\\mysql-init.txt

    The appropriate --defaults-file setting can be found using the Services Manager: From the Start menu, selectControl Panel, then Administrative Tools, then Services. Find the MySQL service in the list, right-click it, and choose the Properties option. The Path to executable field contains the --defaults-file setting.

  7. After the server has started successfully, delete C:\mysql-init.txt.

You should now be able to connect to the MySQL server as root using the new password. Stop the MySQL server and restart it normally. If you run the server as a service, start it from the Windows Services window. If you start the server manually, use whatever command you normally use.

If the ALTER USER statement fails to reset the password, try repeating the procedure using the following statements to modify the user table directly:

UPDATE mysql.user
    SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
    WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;

Import data from excel file in c#

Mô tả:Người dùng nhất vào nút “Browse …” để chọn tập tin excel cần import. Kế tiếp nhấn nút “Import excel” để thực thiện việc import dữ liệu vào database. Sau khi kết thúc import xong, lấy tất cả dữ liệu từ dabase hiển thị lên DataGridView, kết quả như hình bên dưới:https://i0.wp.com/gockinhnghiem.com/wp-content/uploads/FormImport.gif

Hình 1: Giao diện form import excel

Giờ chúng ta cùng Góc Kinh Nghiệm lần lượt làm theo các bước sau:

  • Bước 1: Tạo tập tin import tên EmployeeInfo.xls có thông tin và định dạnh như hình bên dưới:https://i0.wp.com/gockinhnghiem.com/wp-content/uploads/Dinh-dang-tap-tin-import.gif

Hình 2: thông tin và định dạng tập tin excel cần import

  • Bước 2: Vào SQL Server 2005 tạo cơ sở dữ liệu có tên HumanResourceDB và table có tên EmployeeInfo như hình bên dưới:

Hình 3: Database để lưu thông tin import

Lưu ý: ở đây bạn cũng có thể dụng SQL Server 2000 để thao tác (không nhất thiết là SQL Server 2005)

  • Bước 3: Mở Visual Studial 2010 (bạn cũng có thể dùng VS2005, VS2008 để thao tác), Vào File -> New -> Project … -> Windows (phía bên trái) -> Windows Forms Application, và gõ vào ô Name bên tên project là ImportExcel
  • Bước 4: Sau khi project được tạo, bạn đổi tên Form1 thành FormMain, vào design của FormMain tạo các đối tượng sau:
    • TextBox: tên txtFilePath, dùng để chứa đường dẫn tập tin excel cần import
    • Button: tên btnBrowse, cho phép người dùng chọn tập tin excel cần import
    • Button: tên btnImportExcel, thực hiện import khi người dùng nhấn vào nút này, sau khi import thành công sẽ hiển thị dữ liệu lên DataGridView
    • DataGridView: tên dgvData, để chứa dữ liệu được lấy từ database sau khi import xong
    • Lable “File Path” tùy ý

Tham khảo hình 1 ở trên

  • Bước 5: Nhất chuột phải lên project ImportExcel -> Add -> New Item .. -> Data (bên trái) -> DataSet (bên phải), gõ tên HumanResource.xsd vào ô Name như hình bên dưới

Hình 4: Tạo DataSet tên HummanResource.xsd

  • Bước 6: Nhấn chuột phải vào vào DataSet vừa tạo ở bước 5, chọn Add -> TableAdapter …, hiện ra một hộp thoại TableAdapter Cofiguration Wizard -> nhấn nút New Connection …, -> xuất hiện hộp thoại tên Add Connection, gõ dấu chấm (.) vào ô Server Name (dấu chấm ở đây đại diện cho localhost, tức SQL Server đang được cài trên máy hiện hành của bạn), và chọn database tên “HumanResourceDB” (database này đã tạo sẵn ở bước 2) -> nhấn nút OK -> nhất Next, và làm theo chỉ dẫn của wizard, xem hình bên dưới:

Hình 5: tạo kết nối với database

Sau khi hoàn tất Wizard, chúng ta được DataSet với kết quả hình như sau:https://i0.wp.com/gockinhnghiem.com/wp-content/uploads/Query.gif

Hình 6: kết quả của DataSet được tạo

Trong đó:

Nội dung các  hàm lần lược như sau:

GetData()

1
2
SELECT[Index], Code, FullName, WorkingYears
FROMEmployeeInfo

GetEmployeeInfoByCode()

1
2
3
SELECT[Index], Code, FullName, WorkingYears
FROMEmployeeInfo
WhereCode = @Code

InsertEmployee()

1
2
INSERTINTO[EmployeeInfo] ([Code], [FullName], [WorkingYears]) VALUES(@Code, @FullName, @WorkingYears);
SELECTSCOPE_IDENTITY()

UpdateEmployeeInfoByCode()

1
2
3
UPDATEEmployeeInfo
SETFullName = @FullName, WorkingYears = @WorkingYears
WHERE(Code = @Original_Code);
  • Bước 7: quay lại form FormMain, code như bên dưới:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.OleDb;
namespaceImportExcel
{
    publicpartialclassFormMain : Form
    {
        publicFormMain()
        {
            InitializeComponent();
            btnBrowse.Click += newEventHandler(btnBrowse_Click);
            btnImportExcel.Click += newEventHandler(btnImportExcel_Click);
        }
        voidbtnBrowse_Click(objectsender, EventArgs e)
        {
            // Browse đến file cần import
            OpenFileDialog ofd = newOpenFileDialog();
            // Lấy đường dẫn file import vừa chọn
            txtFilePath.Text = ofd.ShowDialog() == DialogResult.OK ? ofd.FileName : "";
        }
        voidbtnImportExcel_Click(objectsender, EventArgs e)
        {
            if(!ValidInput())
                return;
            // Đọc dữ liệu từ tập tin excel trả về DataTable
            DataTable data = ReadDataFromExcelFile();
            // Import dữ liệu đọc được vào database
            ImportIntoDatabase(data);
            // Lấy hết dữ liệu import từ database hiển thị lên gridView
            ShowData();
        }
        privateboolValidInput()
        {
            if(txtFilePath.Text.Trim() == "")
            {
                MessageBox.Show("Xin vui lòng chọn tập tin excel cần import");
                returnfalse;
            }
            returntrue;
        }
        privateDataTable ReadDataFromExcelFile()
        {
            stringconnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ txtFilePath.Text.Trim() + ";Extended Properties=Excel 8.0";
            // Tạo đối tượng kết nối
            OleDbConnection oledbConn = newOleDbConnection(connectionString);
            DataTable data = null;
            try
            {
                // Mở kết nối
                oledbConn.Open();
                // Tạo đối tượng OleDBCommand và query data từ sheet có tên "Sheet1"
                OleDbCommand cmd = newOleDbCommand("SELECT * FROM [Sheet1$]", oledbConn);
                // Tạo đối tượng OleDbDataAdapter để thực thi việc query lấy dữ liệu từ tập tin excel
                OleDbDataAdapter oleda = newOleDbDataAdapter();
                oleda.SelectCommand = cmd;
                // Tạo đối tượng DataSet để hứng dữ liệu từ tập tin excel
                DataSet ds = newDataSet();
                // Đổ đữ liệu từ tập excel vào DataSet
                oleda.Fill(ds);
                data = ds.Tables[0];
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                // Đóng chuỗi kết nối
                oledbConn.Close();
            }
            returndata;
        }
        privatevoidImportIntoDatabase(DataTable data)
        {
            if(data == null|| data.Rows.Count == 0)
            {
                MessageBox.Show("Không có dữ liệu để import");
                return;
            }
            HumanResourceTableAdapters.EmployeeInfoTableAdapter adapter = newHumanResourceTableAdapters.EmployeeInfoTableAdapter();
            stringcode = "", fullName = "";
            intworkingYears = 0;
            try
            {
                for(inti = 0; i < data.Rows.Count; i++)
                {
                    code = data.Rows[i]["Code"].ToString().Trim();
                    fullName = data.Rows[i]["FullName"].ToString().Trim();
                    workingYears = int.Parse(data.Rows[i]["WorkingYears"].ToString().Trim());
                    HumanResource.EmployeeInfoDataTable existingEmployee = adapter.GetEmployeeInfoByCode(code);
                    // Nếu nhân viên chưa tồn tại trong DB thì thêm mới
                    if(existingEmployee == null|| existingEmployee.Rows.Count == 0)
                    {
                        adapter.InsertEmployee(code, fullName, workingYears);
                    }
                    // Ngược lại, nhân viên đã tồn tại trong DB thì update
                    else
                    {
                        adapter.UpdateEmployeeInfoByCode(fullName, workingYears, code);
                    }
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            MessageBox.Show("Kết thúc import");
        }
        privatevoidShowData()
        {
            HumanResourceTableAdapters.EmployeeInfoTableAdapter adapter = newHumanResourceTableAdapters.EmployeeInfoTableAdapter();
            dgvData.DataSource = adapter.GetData();
        }
    }
}

Bước 8: Build và chạy chương trình, thu được kết quả như hình 1 bên trên

//

int i = 2; // Với i là Sheet cần load của file Excel đó.
string query = String.Format(“select * from [Sheet{0}$]”, i);// Ở đây lấy dữ liệu của Sheet2

How to use resolve the zkemkeeper embedd issue?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using iTimeService.dsitimeTableAdapters;
using System.IO;

namespace iTimeService
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }
        public zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
        private bool bIsConnected = false;//the boolean value identifies 
whether the device is connected
        private int iMachineNumber = 1;//the serial number of the device.
After connecting the device ,this value will be changed.
        TENTERTableAdapter tenteradapter = new TENTERTableAdapter();
        T012_GATETableAdapter gateadapter = new T012_GATETableAdapter();
    }
}


Answer: click on the reference you have, I think for that specific project
that would be ‘zkemkeeper’ then on its properties just set the ‘Embed Interop Type’
to ‘False’ I hope this would help.

Generate an XML Document Rogrammatically Using DOM: Part I

//Create a new xmlDataDocument

XmlDataDocument myDoc = new XmlDataDocument();

//The familie

XmlElement Familie = myDoc.CreateElement(“Familie”);

//The elements wrapper

XmlElement wrapper = myDoc.CreateElement(“xml”);

//Create attributes

XmlAttribute version = myDoc.CreateAttribute(“version”);

XmlAttribute encoding = myDoc.CreateAttribute(“encoding”);

//Add values to attributes

version.Value = “1.0”;

encoding.Value = “utf-8”;

//Append attributes to their correspondent element

wrapper.Attributes.Append(version);

wrapper.Attributes.Append(encoding);

//The Father

XmlElement Father = myDoc.CreateElement(“Father”);

//Create attributes

XmlAttribute FatherName = myDoc.CreateAttribute(“Name”);

XmlAttribute FatherAge = myDoc.CreateAttribute(“Age”);

//Add values to attributes

FatherName.Value = “My father”;

FatherAge.Value = “65”;

//Append attributes to their correspondent element

Father.Attributes.Append(FatherName);

Father.Attributes.Append(FatherAge);

//Add the element to the Familie node

Familie.AppendChild(Father);

//The mother

XmlElement Mother = myDoc.CreateElement(“Mother”);

//Create attributes

XmlAttribute MotherName = myDoc.CreateAttribute(“Name”);

XmlAttribute MotherAge = myDoc.CreateAttribute(“Age”);

//Add values to attributes

MotherName.Value = “My mother”;

MotherAge.Value = “60”;

//Append attributes to their correspondent element

Mother.Attributes.Append(MotherName);

Mother.Attributes.Append(MotherAge);

//Add the element to the Familie node

Familie.AppendChild(Mother);

//The sister

XmlElement Sister = myDoc.CreateElement(“Sister”);

//Create attributes

XmlAttribute SisterName = myDoc.CreateAttribute(“Name”);

XmlAttribute SisterAge = myDoc.CreateAttribute(“Age”);

//Add values to attributes

SisterName.Value = “My sister”;

SisterAge.Value = “20”;

//Append attributes to their correspondent element

Sister.Attributes.Append(SisterName);

Sister.Attributes.Append(SisterAge);

//Add the element to the Familie node

Familie.AppendChild(Sister);

//The brother

XmlElement Brother = myDoc.CreateElement(“Brother”);

//Create attributes

XmlAttribute BrotherName = myDoc.CreateAttribute(“Name”);

XmlAttribute BrotherAge = myDoc.CreateAttribute(“Age”);

//Add values to attributes

BrotherName.Value = “My brother”;

BrotherAge.Value = “21”;

//Append attributes to their correspondent element

Brother.Attributes.Append(BrotherName);

Brother.Attributes.Append(BrotherAge);

//Add the element to the Familie node

Familie.AppendChild(Brother);

//wrapp all elements nodes in wrapper node

wrapper.AppendChild(Familie);

//Add the entire node in to the docuement

myDoc.AppendChild(wrapper);

//Save the xml document

myDoc.Save(@”C:\myFamilie.xml”);

//Give a signal that all gonna be all right

Console.WriteLine(“Document is generated successfully!!”);
Console.Read();

Lớp trừu tượng (abstract class)

Lớp trừu tượng là một trong những khái niệm quan trọng trên nền tảng .NET. Thường, bạn muốn tạo ra các lớp mà chỉ làm lớp gốc (base class – lớp đầu tiên trong cây thừa kế hay còn gọi là lớp tổ tiên), và dĩ nhiên, bạn sẽ không muốn người khác tạo ra đối tượng cho các lớp này. Chúng ta có thể sử dụng khái niệm lớp trừu tượng để cài đặt chức năng này trong C# sử dụng từ khóa ‘abstract‘.
Một lớp trừu tượng có nghĩa là không khởi tạo được đối tượng của lớp này, nhưng cho phép thừa kế để tạo ra lớp con.
Khai báo lớp trừu tượng trong C#:

1
2
3
abstractclasstên_lớp_trừu_tượng
{
}

Ví dụ:

1
2
3
abstractclassWindow
{
}

Phương thức trừu tượng (abstract method)

Trong thiết kế hướng đối tượng, khi các bạn thiết kế ra một base class, và các bạn mong muốn rằng người khác khi thừa kế lớp này thì phải ghi đè (override) lên các phương thức xác định trước. Trong trường hợp người khác thừa kế lớp của các bạn mà không ghi đè lên những phương thức này thì trình biên dịch sẽ báo lỗi. Khái niệm phương thức trừu tượng sẽ giúp các bạn trong tình huống này.

Một lớp trừu tượng có thể chứa cả phương thức trừu tượng (phương thức không có phần thân) và phương thức bình thường (phương thức có phần thân hay phương thức thàdow
public class ListBox : Window
{
// Khởi dựng có tham số
public ListBox(int top, int left, string theContents)
: base(top, left) // gọi khởi dựng của lớp cơ sở
{
mListBoxContents = theContents;
}

public override void DrawWindow()
{
Console.WriteLine(“ListBox write: {0}”, mListBoxContents);
}
// biến thành viên private
private string mListBoxContents;
public override string Content
{
set { mListBoxContents = value; }
get { return mListBoxContents; }
}
}
[/code]
Trong ví dụ trên, các bạn thấy thuộc tính (property) Content được khai báo trong lớp Window, nhưng không có biến chứa dữ liệu cho nó không được khai báo trong lớp này. Do đó nó được cài đặt kiểu abstract.

Thuộc tính Content được override trong lớp con ListBox, và biến chứa dữ liệu cho nó là mListBoxContents.

Một số quy tắc áp dụng cho lớp trừu tượng

– Một lớp trừu tượng không thể là một sealed class. Khai báo như ví dụ dưới đây là sai:

1
2
3
4
// Khai báo sai
abstractsealedclassWindow
{
}

– Phương thức trừu tượng chỉ khai báo trong lớp trừu tượng.

– Một phương thức trừu tượng không sử dụng chỉ định từ truy xuất là private.

1
2
3
4
5
// Khai báo sai
abstractclassWindow
{
    privateabstractvoidDrawWindow();
}

Chỉ định từ truy xuất của phương thức trừu tượng phải giống nhau trong phần khai báo ở lớp cha lẫn lớp con. Nếu bạn đã khai báo chỉ định từ truy xuất protected cho phương thức trừu tượng ở lớp cha thì trong lớp con bạn cũng phải sử dụng chỉ định từ truy xuất protected. Nếu chỉ định từ truy xuất không giống nhau thì trình biên dịch sẽ báo lỗi.

– Một phương thức trừu tượng không sử dụng chỉ định từ truy xuất virtual. Bởi vì bản thân phương thức trừu tượng đã bao hàm khái niệm virtual.

1
2
3
4
5
// Khai báo sai
abstractclassWindow
{
    privateabstractvirtualvoidDrawWindow();
}

– Một phương thức trừu tượng không thể là phương thức static.

1
2
3
4
5
// Khai báo sai
abstractclassWindow
{
    privateabstractstaticvoidDrawWindow();
}

Lớp trừu tượng (abstract class) và giao diện (interface)

Trong lớp trừu tượng chứa cả phương thức trừu tượng lẫn phương thức thành viên. Nhưng trong interface thì chỉ chứa phương thức trừu tượng và lớp con khi thừa kế từ interface cần phải ghi đè (override) lên các phương thức này.

1
2
3
4
5
interfaceIFile
{
    voidSave();
    voidLoad();
}

Các phương thức trừu tượng khai báo trong interface không sử dụng chỉ định từ truy xuất, mặc định sẽ là public.

Một lớp chỉ có thể thừa kế từ một lớp cha, nhưng có thể thừa kế từ nhiều interface.

 

RESOURCE: INTERNET

Chuyển tiếng Việt có dấu sang không dấu trong Microsoft SQL Server

Đây là một function giúp bạn chuyển tiếng Việt có dấu sang không dấu trong SQL

T-SQL Code:
  1. CREATE FUNCTION [dbo].[fChuyenCoDauThanhKhongDau](@inputVar NVARCHAR(MAX) )
  2. RETURNS NVARCHAR(MAX)
  3. AS
  4. BEGIN    
  5.     IF (@inputVar IS NULL OR @inputVar = ”)  RETURN ”
  6.    
  7.     DECLARE @RT NVARCHAR(MAX)
  8.     DECLARE @SIGN_CHARS NCHAR(256)
  9.     DECLARE @UNSIGN_CHARS NCHAR (256)
  10.  
  11.     SET @SIGN_CHARS = N’ăâđêôơưàảãạáằẳẵặắầẩẫậấèẻẽẹéềểễệếìỉĩịíòỏõọóồổỗộốờởỡợớùủũụúừửữựứỳỷỹỵýĂÂĐÊÔƠƯÀẢÃẠÁẰẲẴẶẮẦẨẪẬẤÈẺẼẸÉỀỂỄỆẾÌỈĨỊÍÒỎÕỌÓỒỔỖỘỐỜỞỠỢỚÙỦŨỤÚỪỬỮỰỨỲỶỸỴÝ’ + NCHAR(272) + NCHAR(208)
  12.     SET @UNSIGN_CHARS = N’aadeoouaaaaaaaaaaaaaaaeeeeeeeeeeiiiiiooooooooooooooouuuuuuuuuuyyyyyAADEOOUAAAAAAAAAAAAAAAEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOUUUUUUUUUUYYYYYDD’
  13.  
  14.     DECLARE @COUNTER int
  15.     DECLARE @COUNTER1 int
  16.    
  17.     SET @COUNTER = 1
  18.     WHILE (@COUNTER <= LEN(@inputVar))
  19.     BEGIN  
  20.         SET @COUNTER1 = 1
  21.         WHILE (@COUNTER1 <= LEN(@SIGN_CHARS) + 1)
  22.         BEGIN
  23.             IF UNICODE(SUBSTRING(@SIGN_CHARS, @COUNTER1,1)) = UNICODE(SUBSTRING(@inputVar,@COUNTER ,1))
  24.             BEGIN          
  25.                 IF @COUNTER = 1
  26.                     SET @inputVar = SUBSTRING(@UNSIGN_CHARS, @COUNTER1,1) + SUBSTRING(@inputVar, @COUNTER+1,LEN(@inputVar)-1)      
  27.                 ELSE
  28.                     SET @inputVar = SUBSTRING(@inputVar, 1, @COUNTER-1) +SUBSTRING(@UNSIGN_CHARS, @COUNTER1,1) + SUBSTRING(@inputVar, @COUNTER+1,LEN(@inputVar)- @COUNTER)
  29.                 BREAK
  30.             END
  31.             SET @COUNTER1 = @COUNTER1 +1
  32.         END
  33.         SET @COUNTER = @COUNTER +1
  34.     END
  35.     — SET @inputVar = replace(@inputVar,’ ‘,’-‘)
  36.     RETURN @inputVar
  37. END

Cách cài đặt:
– Mở Microsoft SQL Management Tool hoặc bất cứ công cụ nào cho phép Execute Query
– Đưa đoạn code SQL trên vào và nhấn Execute Query

Cách sử dụng:
Ví dụ 1: Lựa chọn một trường không dấu ta viết, ví dụ trường Diachi từ bảng Account

T-SQL Code:
  1. SELECT dbo.fChuyenCoDauThanhKhongDau(Diachi) FROM Account

Ví dụ 2: Tìm kiếm không dấu, tìm tất cả các tên có chứa ‘C Viet’ trong bảng Account

T-SQL Code:
  1. SELECT Ten, Diachi FROM Account WHERE dbo.fChuyenCoDauThanhKhongDau(Ten) LIKE ‘%C Viet%’

Đối với dân lập trình SQL, SQL Desinger, … thì function SQL này cực kỳ hữu ích. Nhưng đối với những nhà phát triển phần mềm thì đây là điều không mấy hứng thú. Trong bài viết tới,  sẽ đưa ra một phương pháp cho những nhà phát triển phần mềm.

–Source: Internet–

Tôn giáo Việt Nam phân chia theo dân số và giới tính

STT Tên Tôn Giáo Tổng (người) Nam (người) Nữ (người)
Cả nước 15.651.467 7.509.832 8.141.635
1 Phật giáo 6.812.318 3.172.576 3.629.742
2 Công giáo 5.677.086 2.783.619 2.893.167
3 Hòa Hảo 1.433.252 717.191 716.061
4 Hồi Giáo 75.268 34.445 37.823
5 Cao Đài 807.915 384.204 423.711
6 Minh Sư Đạo 709 328 381
7 Minh Lý Đạo 366 173 193
8 Tin Lành 734.168 354.696 379.472
9 Tịnh độ cư sĩ Phật hội Việt Nam 11.093 5.295 5.798
10 Đạo Tứ ấn hiếu nghĩa 41.280 20.633 20.647
11 Bửu sơn Kỳ hương 10.824 5.510 5.314
12 Bahá’í 731 361 370
13 Bà La Môn 56.427 27.791 28.636

Các dân tộc Việt Nam theo số dân

STT Dân tộc Dân số Thời điểm
thống kê
 % so với
dân số
Việt Nam
 Việt Nam 90.493.352 04/2014[3] 100 %
 Việt Nam 85.846.997 01/04/2009
1 Kinh 73.594.427 01/04/2009 85,7274%
2 Tày 1.626.392 01/04/2009 1,8945%
3 Thái 1.550.423 01/04/2009 1,806%
4 Mường 1.268.963 01/04/2009 1,4782%
5 Khơ Me 1.260.640 01/04/2009 1,4685%
6 H’Mông 1.068.189 01/04/2009 1,2443%
7 Nùng 968.800 01/04/2009 1,1285%
8 Hoa 823.071 01/04/2009 0,9588%
9 Dao 751.067 01/04/2009 0,8749%
10 Gia Rai 411.275 01/04/2009 0,4791%
11 Ê Đê 331.194 01/04/2009 0,3858%
12 Ba Na 227.716 01/04/2009 0,2653%
13 Xơ Đăng 169.501 01/04/2009 0,1974%
14 Sán Chay 169.410 01/04/2009 0,1973%
15 Cơ Ho 166.112 01/04/2009 0,1935%
16 Chăm 161.729 01/04/2009 0,1884%
17 Sán Dìu 146.821 01/04/2009 0,171%
18 Hrê 127.420 01/04/2009 0,1484%
19 Ra Glai 122.245 01/04/2009 0,1424%
20 M’Nông 102.741 01/04/2009 0,1197%
21 X’Tiêng 85.436 01/04/2009 0,0995%
22 Bru-Vân Kiều 74.506 01/04/2009 0,0868%
23 Thổ 74.458 01/04/2009 0,0867%
24 Khơ Mú 72.929 01/04/2009 0,085%
25 Cơ Tu 61.588 01/04/2009 0,0717%
26 Giáy 58.617 01/04/2009 0,0683%
27 Giẻ Triêng 50.962 01/04/2009 0,0594%
28 Tà Ôi 43.886 01/04/2009 0,0511%
29 Mạ 41.405 01/04/2009 0,0482%
30 Co 33.817 01/04/2009 0,0394%
31 Chơ Ro 26.855 01/04/2009 0,0313%
32 Xinh Mun 23.278 01/04/2009 0,0271%
33 Hà Nhì 21.725 01/04/2009 0,0253%
34 Chu Ru 19.314 01/04/2009 0,0225%
35 Lào 14.928 01/04/2009 0,0174%
36 Kháng 13.840 01/04/2009 0,0161%
37 La Chí 13.158 01/04/2009 0,0153%
38 Phú Lá 10.944 01/04/2009 0,0127%
39 La Hủ 9.651 01/04/2009 0,0112%
40 La Ha 8.177 01/04/2009 0,0095%
41 Pà Thẻn 6.811 01/04/2009 0,0079%
42 Chứt 6.022 01/04/2009 0,007%
43 Lự 5.601 01/04/2009 0,0065%
44 Lô Lô 4.541 01/04/2009 0,0053%
45 Mảng 3.700 01/04/2009 0,0043%
46 Cờ Lao 2.636 01/04/2009 0,0031%
47 Bố Y 2.273 01/04/2009 0,0026%
48 Cống 2.029 01/04/2009 0,0024%
49 Ngái 1.035 01/04/2009 0,0012%
50 Si La 709 01/04/2009 0,0008%
51 Pu Péo 687 01/04/2009 0,0008%
52 Rơ măm 436 01/04/2009 0,0005%
53 Brâu 397 01/04/2009 0,0005%
54 Ơ Đu 376 01/04/2009 0,0004%
55(*) Thành phần khác 2.134 01/04/2009 0,0025%