<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>sql-server-2000 &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/sql-server-2000/</link>
	<description>Feed of posts on WordPress.com tagged "sql-server-2000"</description>
	<pubDate>Sat, 11 Oct 2008 03:24:12 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[SQL Server 2000 vs SQL Server 2005 queries]]></title>
<link>http://scmay.wordpress.com/?p=76</link>
<pubDate>Fri, 10 Oct 2008 02:53:52 +0000</pubDate>
<dc:creator>scmay</dc:creator>
<guid>http://scmay.pt-br.wordpress.com/2008/10/10/sql-server-2000-vs-sql-server-2005-queries/</guid>
<description><![CDATA[This gives an example of SQL queries between SQL Server 2000  and SQL Server 2005
http://www.mssqlt]]></description>
<content:encoded><![CDATA[<p>This gives an example of SQL queries between SQL Server 2000  and SQL Server 2005</p>
<p><a href="http://www.mssqltips.com/tip.asp?tip=1015">http://www.mssqltips.com/tip.asp?tip=1015</a></p>
<p>Bumped into this while looking for  IGNORE_DUP_KEY</p>
<p> </p>
<p>Also realized you can't put this as part of a table creation unlike SQL Server 2005.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Automatic Script Generation for SQL Server Objects]]></title>
<link>http://chonglongchoo.wordpress.com/?p=197</link>
<pubDate>Sun, 05 Oct 2008 07:55:31 +0000</pubDate>
<dc:creator>chonglongchoo</dc:creator>
<guid>http://chonglongchoo.pt-br.wordpress.com/2008/10/05/sqlautoscript/</guid>
<description><![CDATA[To produce scripts for every object and configuration in a SQL Server.
DOWNLOAD
]]></description>
<content:encoded><![CDATA[<p>To produce scripts for every object and configuration in a SQL Server.</p>
<p><a href="http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4179&#38;lngWId=10" target="_blank">DOWNLOAD</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Document SQL Server Configurations and Objects]]></title>
<link>http://chonglongchoo.wordpress.com/?p=195</link>
<pubDate>Sun, 05 Oct 2008 07:53:53 +0000</pubDate>
<dc:creator>chonglongchoo</dc:creator>
<guid>http://chonglongchoo.pt-br.wordpress.com/2008/10/05/sqlanalyzer/</guid>
<description><![CDATA[To document configurations and objects in Microsost SQL Server 97 and 2000.
DOWNLOAD
]]></description>
<content:encoded><![CDATA[<p>To document configurations and objects in Microsost SQL Server 97 and 2000.</p>
<p><a href="http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3070&#38;lngWId=10" target="_blank">DOWNLOAD</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Generating Random Passwords in SQL Server]]></title>
<link>http://dacosta9.wordpress.com/?p=20</link>
<pubDate>Sat, 04 Oct 2008 05:10:23 +0000</pubDate>
<dc:creator>dacosta9</dc:creator>
<guid>http://dacosta9.pt-br.wordpress.com/2008/10/04/generating-random-passwords-in-sql-server/</guid>
<description><![CDATA[From time to time I generate the password for new database users, here is the code I use. This works]]></description>
<content:encoded><![CDATA[<p>From time to time I generate the password for new database users, here is the code I use. This works on SQL 2000 and SQL 2005 and SQL Server 2008.</p>
<p>If the user wants a more friendly password I just issue an sp_password to put a more memorable password.<br />
<code><br />
/* To avoid disclosure of passwords, the password is generated in script. */<br />
declare @idx as int<br />
declare @randomPwd as nvarchar(64)<br />
declare @rnd as float<br />
select @idx = 0<br />
select @randomPwd = N''<br />
select @rnd = rand((@@CPU_BUSY % 100) + ((@@IDLE % 100) * 100) +<br />
(DATEPART(ss, GETDATE()) * 10000) + ((cast(DATEPART(ms, GETDATE()) as int) % 100) * 1000000))<br />
while @idx &#60; 64<br />
begin<br />
select @randomPwd = @randomPwd + char((cast((@rnd * 83) as int) + 43))<br />
select @idx = @idx + 1<br />
select @rnd = rand()<br />
end<br />
SELECT CAST(@randomPwd AS NVARCHAR(8))<br />
</code></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[SQL Server Dictionary Search]]></title>
<link>http://dacosta9.wordpress.com/?p=18</link>
<pubDate>Sat, 04 Oct 2008 03:20:57 +0000</pubDate>
<dc:creator>dacosta9</dc:creator>
<guid>http://dacosta9.pt-br.wordpress.com/2008/10/04/sql-server-dictionary-search/</guid>
<description><![CDATA[Sometimes I am thrown into a situation where I need to find a column of parameter in tables, stored ]]></description>
<content:encoded><![CDATA[<p>Sometimes I am thrown into a situation where I need to find a column of parameter in tables, stored procedures and other objects. For the most part it may be a quick and dirty treasure hunting mission where I need to find all the different places a field such as "emailAddress" is found.</p>
<p>I would simply search for the column name using the following dictionary query that i wrote.</p>
<p>DECLARE @SearchString VARCHAR(100)<br />
SET @SearchString = 'email'<br />
SELECT<br />
o.id [Object Id]<br />
,o.type<br />
,CASE o.type<br />
WHEN 'C'   THEN 'CHECK CONSTRAINT                    '<br />
WHEN 'D'   THEN 'DEFAULT OR DEFAULT CONSTRAINT       '<br />
WHEN 'F'   THEN 'FOREIGN KEY CONSTRAINT              '<br />
WHEN 'K'   THEN 'PRIMARY KEY OR UNIQUE CONSTRAINT    '<br />
WHEN 'L'   THEN 'LOG                                 '<br />
WHEN 'P'   THEN 'STORED PROCEDURE                    '<br />
WHEN 'R'   THEN 'RULE                                '<br />
WHEN 'RF'  THEN 'REPLICATION FILTER STORED PROCEDURE '<br />
WHEN 'S'   THEN 'SYSTEM TABLE                        '<br />
WHEN 'TR'  THEN 'TRIGGER                             '<br />
WHEN 'U'   THEN 'USER TABLE                          '<br />
WHEN 'V'   THEN 'VIEW                                '<br />
WHEN 'X'   THEN 'EXTENDED STORED PROCEDURE           '<br />
ELSE o.type<br />
END [Object Type]<br />
,o.name [Object Name]<br />
,c.name [Column Name]<br />
,c.colOrder<br />
,t.name [Column Type]<br />
,CASE<br />
WHEN t.xtype IN (175,239,231,167) THEN '('+ CAST(c.length AS VARCHAR) +')'<br />
WHEN t.xtype IN  (106,60,108,59) AND c.scale IS NOT NULL THEN '('+CAST(c.prec AS VARCHAR)+','+ CAST(c.scale AS VARCHAR)+')'<br />
ELSE '' END [Length]<br />
FROM<br />
dbo.sysColumns c WITH(NOLOCK) INNER JOIN<br />
dbo.sysObjects o WITH(NOLOCK) ON (o.id = c.id) INNER JOIN<br />
dbo.sysTypes t WITH(NOLOCK) ON (t.xtype = c.xtype)<br />
WHERE<br />
1 = 1<br />
--AND o.type IN ('P','S','U','V')<br />
--</p>
<p>AND o.type IN ('U')<br />
-- AND c.name  LIKE '%'+@SearchString+'%'<br />
AND ( c.name  LIKE '%'+@SearchString+'%' OR o.name  LIKE '%'+@SearchString+'%')<br />
ORDER BY<br />
o.type, o.name,c.colOrder</p>
<p>/*</p>
<p>WHEN 'C'   THEN 'CHECK CONSTRAINT                    '<br />
WHEN 'D'   THEN 'DEFAULT OR DEFAULT CONSTRAINT       '<br />
WHEN 'F'   THEN 'FOREIGN KEY CONSTRAINT              '<br />
WHEN 'K'   THEN 'PRIMARY KEY OR UNIQUE CONSTRAINT    '<br />
WHEN 'L'   THEN 'LOG                                 '<br />
WHEN 'P'   THEN 'STORED PROCEDURE                    '<br />
WHEN 'R'   THEN 'RULE                                '<br />
WHEN 'RF'  THEN ' REPLICATION FILTER STORED PROCEDURE'<br />
WHEN 'S'   THEN 'SYSTEM TABLE                        '<br />
WHEN 'TR'  THEN ' TRIGGER                            '<br />
WHEN 'U'   THEN 'USER TABLE                          '<br />
WHEN 'V'   THEN 'VIEW                                '<br />
WHEN 'X'   THEN 'EXTENDED STORED PROCEDURE           '</p>
<div>*/</div>
<div>I have recently created a 2nd Dictionary search which I use a lot to find objects that reference a particular table or object. Its simply a search through source code in the database.  While really simple, these queries are particularly useful and should be kept within easy reach.</div>
<div>DECLARE @SearchString VARCHAR(100)<br />
SET @SearchString = '%object_name%'<br />
SELECT<br />
o.[name]<br />
,o.[id]<br />
,o.[xtype]<br />
,c.[text]<br />
FROM<br />
[dbo].[sysobjects] o INNER JOIN<br />
[dbo].[syscomments] c ON (o.id = c.id)<br />
WHERE<br />
c.[text] LIKE @SearchString</div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[RAISERROR en UDF ---&gt; NOT!]]></title>
<link>http://juanda2.wordpress.com/?p=94</link>
<pubDate>Thu, 18 Sep 2008 17:27:15 +0000</pubDate>
<dc:creator>juanda</dc:creator>
<guid>http://juanda2.pt-br.wordpress.com/2008/09/18/raiserror-en-udf-not/</guid>
<description><![CDATA[Recien descubro que en SQL Server 2000 no se puede usar RAISERROR dentro de una UDF. Asi que no qued]]></description>
<content:encoded><![CDATA[<p>Recien descubro que en SQL Server 2000 no se puede usar RAISERROR dentro de una UDF. Asi que no queda más que convertir la función en un SP o retornar NULL o algo parecido. Osea... una cagada.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Exception handling in Sql server 2000]]></title>
<link>http://chkiran.wordpress.com/?p=42</link>
<pubDate>Thu, 18 Sep 2008 06:11:38 +0000</pubDate>
<dc:creator>kcherupa</dc:creator>
<guid>http://chkiran.pt-br.wordpress.com/2008/09/18/exception-handling-in-sql-server-2000/</guid>
<description><![CDATA[When I was working on a project, I had written a sproc which runs in sql server 2005. I had used Try]]></description>
<content:encoded><![CDATA[<p>When I was working on a project, I had written a sproc which runs in sql server 2005. I had used Try Catch blocks to handle the exceptions and roll back the transaction for any exception. My script was working fine with sql-2005. But when I had to deploy on production, I noticed that we had sql server 2000 on which our legacy database was sitting. When I ran my script it was failing to create the sproc due to try catch blocks. After doing a while research on it I found that sql server 2000 deals with exceptions in different way.</p>
<p>When any exception is raised then @@ERROR will be set to a non zero value. If you want to check whether exception has araised you should check</p>
<p>@@ERROR &#60;&#62;0      -&#62; Exception occurred</p>
<p>@@ERROR =0        -&#62; No Exception</p>
<p>To handle exceptions in sql server 2000 we need to check the condition @@ERROR &#60;&#62;0 for every insert/update/delete statement and based on that we need to roll back the transaction if used.</p>
<p>Example:</p>
<p>BEGIN TRAN</p>
<p>DELETE EMP WHERE EmployeeType = 'ProjectManager'</p>
<p>IF (@@ERROR &#60;&#62;0)</p>
<p>GOTO HandleError;</p>
<p>UPDATE EMP SET Salary = Salary * 1.30, EmployeeType = 'ProjectManager' WHERE EmployeeType = 'TeamLead'</p>
<p>IF (@@ERROR &#60;&#62;0)</p>
<p>GOTO HandleError;</p>
<p>COMMIT TRANS</p>
<p>RETURN;</p>
<p>HandleError:</p>
<p>ROLLBACK TRAN</p>
<p>RETURN;</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[[VB6] Como crear una conexión a SQL Server 2000]]></title>
<link>http://lags80.wordpress.com/?p=10</link>
<pubDate>Mon, 18 Aug 2008 14:38:19 +0000</pubDate>
<dc:creator>lags80</dc:creator>
<guid>http://lags80.pt-br.wordpress.com/2008/08/18/vb6-como-crear-una-conexion-a-sql-server-2000/</guid>
<description><![CDATA[En nuestro proyecto de VB6 debemos agregar la Referencia: &#8220;Microsoft ActiveX Data Objects 2.6 ]]></description>
<content:encoded><![CDATA[<p>En nuestro proyecto de VB6 debemos agregar la Referencia: "Microsoft ActiveX Data Objects 2.6 Library.  Después declaramos un módulo donde pondremos una variable Pública de tipo "Connection"</p>
<p><span style="color:#3366ff;">Public conn As Connection</span></p>
<p>Posteriormente declaramos una función Pública que contendrá la cadena de conexión a nuestra BD en SQL Server 2000</p>
<p><span style="color:#3366ff;">Public Sub ConectaBD()</span></p>
<p><span style="color:#3366ff;"> Set conn = New ADODB.Connection<br />
conn.CursorLocation = adUseClient<br />
conn.ConnectionString = "Driver={SQL Server};Server=SERVIDOR;Database=BD;Uid=user;Pwd=password;"<br />
conn.Open<br />
End Sub</span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Comparando text / ntext]]></title>
<link>http://diariodba.wordpress.com/?p=57</link>
<pubDate>Mon, 18 Aug 2008 14:13:31 +0000</pubDate>
<dc:creator>Mendes</dc:creator>
<guid>http://diariodba.pt-br.wordpress.com/2008/08/18/comparando-text-ntext/</guid>
<description><![CDATA[ 
No SQL Server 2005 temos os novos campos do tipo VAR&#8230;(MAX) que vieram aliviar o trabalho de]]></description>
<content:encoded><![CDATA[<p style="margin:0 0 10pt;"> </p>
<p style="margin:0 0 10pt;">No SQL Server 2005 temos os novos campos do tipo VAR...(MAX) que vieram aliviar o trabalho de muita gente. Um dos problemas mais comuns na versão anterior (2000) é quando precisamos comparar dados de campos do tipo text ou ntext, aí nos deparamos com um erro do tipo:</p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="color:#ff0000;">Server: Msg 306, Level 16, State 1, Line 1</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="color:#ff0000;">The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.</span></p>
<p style="margin:0 0 10pt;">Eu já vivi essa situação algumas vezes e deixo aqui a forma como tentei resolver (Se tiverem outras sugestões fiquem a vontade para expor, ok?).</p>
<p style="margin:0 0 10pt;">(Não fiz testes de perfomance nessa solução, o foco está somente em comparar as colunas tipo text / ntext.)</p>
<p style="margin:0 0 10pt;">Imagine que eu tenha duas tabelas:</p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="color:#0000ff;">CREATE TABLE #tb_msg_tela<br />
(id INT IDENTITY(1,1), texto TEXT)</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="color:#0000ff;">GO</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="color:#0000ff;">CREATE TABLE #tb_msg_impressao<br />
(id INT IDENTITY(1,1), texto TEXT)</span></p>
<p style="margin:0 0 10pt;">Com os seguintes dados:</p>
<p style="margin:0 0 10pt;"><span style="color:#0000ff;">INSERT INTO #tb_msg_tela VALUES <span style="color:#ff0000;">(NULL)<br />
</span>INSERT INTO #tb_msg_tela VALUES ('Campo text')<br />
INSERT INTO #tb_msg_tela VALUES ('Teste <span style="color:#ff0000;">comparação</span>')<br />
INSERT INTO #tb_msg_tela VALUES ('Se ca<span style="color:#ff0000;">í</span>sse para o e<span style="color:#ff0000;">x</span>terior, <span style="color:#ff0000;">para </span>o limite do universo, encontraria uma perto e pôsteres que indicassem BECO SEM SAÍDA?')</span></p>
<p style="margin:0 0 10pt;"><span style="color:#0000ff;">INSERT INTO #tb_msg_impressao VALUES <span style="color:#ff0000;">('')<br />
</span>INSERT INTO #tb_msg_impressao VALUES ('Campo text')<br />
INSERT INTO #tb_msg_impressao VALUES ('Teste <span style="color:#ff0000;">comparacao</span>')<br />
INSERT INTO #tb_msg_impressao VALUES ('Se ca<span style="color:#ff0000;">i</span>sse para o e<span style="color:#ff0000;">s</span>terior, <span style="color:#ff0000;">p/</span> o limite do universo, encontraria uma perto e pôsteres que indicassem BECO SEM SAÍDA?')</span></p>
<p style="margin:0 0 10pt;">Observe que existem diferenças em alguns textos (em vermelho).</p>
<p style="margin:0 0 10pt;">Para realizar o relacionamento das duas tabelas e encontrar os campos diferentes não podemos simplesmente utilizar:</p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="color:#0000ff;">SELECT * FROM #tb_msg_tela a, #tb_msg_impressao b<br />
WHERE a.id = b.id AND <span style="color:#ff0000;">a.texto &#60;&#62; b.texto</span></span></p>
<p style="margin:0 0 10pt;">Essa consulta retornará um erro porque estamos comparando os campos text utilizando o &#60;&#62;.</p>
<p style="margin:0 0 10pt;">Então o primeiro passo é encontrar o maior texto nessa coluna, para isso podemos usar as funções DATALENGHT e MAX:</p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="color:#0000ff;">SELECT MAX(DATALENGTH(texto)) FROM #tb_msg_tela<br />
SELECT MAX(DATALENGTH(texto)) FROM #tb_msg_impressao</span></p>
<p style="margin:0 0 10pt;">O resultado será:</p>
<p style="margin:0 0 10pt;">-----------</p>
<p style="margin:0 0 10pt;">658</p>
<p style="margin:0 0 10pt;">-----------</p>
<p style="margin:0 0 10pt;">656</p>
<p style="margin:0 0 10pt;">Então sabemos que o maior texto dessa coluna não ultrapassa 700 caracteres, logo, podemos utilizar esse número como apoio no próximo passo, onde utilizaremos a função SUBSTRING:</p>
<p class="MsoNormal" style="line-height:normal;margin:0 0 10pt;"><span style="color:#0000ff;">SELECT<br />
                *<br />
FROM  <br />
                #tb_msg_tela a,<br />
                #tb_msg_impressao b<br />
WHERE<br />
                a.id = b.id<br />
                AND ISNULL(SUBSTRING(a.texto, 0, 700),'') &#60;&#62; ISNULL(SUBSTRING(b.texto, 0, 700),'') </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0 0 10pt;"><span lang="EN-US"> </span></p>
<p style="line-height:normal;margin:0 0 10pt;">A função <strong>ISNULL</strong> é importante pois sem ela os campos Nulos serão ignorados.</p>
<p style="line-height:normal;margin:0 0 10pt;">Veja que a consulta só ira retornar os campos com as diferenças.</p>
<p class="MsoNormal" style="margin:0 0 10pt;">É um processo simples, mas que pode dar dor de cabeça por conta das limitações do tipo de dados. Pra quem ta iniciando o desenvolvimento utilizando o SQL Server 2005 a recomendação é: substitua os datatypes <em>ntext</em>, <em>text</em>, <em>image</em> por <em>nvarchar(Max), varchar(Max)</em> e <em>varbinary(Max).</em> Além de outras vantagens, com os novos datatypes não existem as antigas diferenças entre varchar e text.</p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:Calibri;"><span style="font-family:Calibri;"> </span></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[SQL Server 2000: Error 14274: Cannot delete a job that originated from an MSX server]]></title>
<link>http://dotnetengineer.wordpress.com/?p=36</link>
<pubDate>Wed, 09 Jul 2008 00:58:32 +0000</pubDate>
<dc:creator>Brandon Ryan</dc:creator>
<guid>http://dotnetengineer.pt-br.wordpress.com/2008/07/08/sql-server-2000-error-14274-cannot-delete-a-job-that-originated-from-an-msx-server/</guid>
<description><![CDATA[I don&#8217;t work much with older versions of SQL server, but I came across the following error tod]]></description>
<content:encoded><![CDATA[<p>I don't work much with older versions of SQL server, but I came across the following error today when trying to disable a scheduled SQL 2000 job while trying to backup a SharePoint Portal Server 2003 database.</p>
<p><em>Error 14274: Cannot delete a job that originated from an MSX server</em></p>
<p>This error message has two possible causes: either</p>
<ol>
<li><strong>the SQL server is not a standalone server, and this message is appropriate</strong>, or</li>
<li><strong>the name of the SQL server has changed since the scheduled job was created</strong>.</li>
</ol>
<p>In my case, the scheduled job had been around for over 6 years, and the server had been renamed about 5 years ago.  The job has continued to run and noone needed to make changes to it.</p>
<p>I looked in the <strong>sysjobs</strong> table in the <strong>msdb</strong> database and noticed that in the <strong>originating_server</strong> field, the old server name was still there.  I updated each of them with the following statement:</p>
<pre>UPDATE sysjobs SET originating_server='yourNewServerName'</pre>
<p>and all was well.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Microsoft SQL Server 2000 Virtual Server Basic Setup, Maintenance, and Service Pack Installation]]></title>
<link>http://hptv04.wordpress.com/?p=471</link>
<pubDate>Thu, 03 Jul 2008 15:53:11 +0000</pubDate>
<dc:creator>hptv</dc:creator>
<guid>http://hptv04.pt-br.wordpress.com/2008/07/03/microsoft-sql-server-2000-virtual-server-basic-setup-maintenance-and-service-pack-installation/</guid>
<description><![CDATA[This is an entry-level walkthrough on the installation of a named-instance SQL Server 2000 virtual s]]></description>
<content:encoded><![CDATA[<p style="text-align:justify;">This is an entry-level walkthrough on the installation of a named-instance SQL Server 2000 virtual server. Topics covered will include: MS DTC installation on a server cluster; base SQL Server 2000 virtual server installation; virtual SQL 2000 server service pack installation; virtual SQL 2000 server maintenance mode walkthrough; virtual SQL 2000 server uninstall; and basic SQL Server security recommendations.</p>
<p style="text-align:justify;">...download here: <a href="http://hptv04.files.wordpress.com/2008/07/mssqlserver2000_setup_maintenance.pdf">mssqlserver2000_setup_maintenance</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Move SQL Server 2000 database to 2005]]></title>
<link>http://twinklekumar.wordpress.com/?p=9</link>
<pubDate>Sun, 29 Jun 2008 20:02:06 +0000</pubDate>
<dc:creator>twinklekumar</dc:creator>
<guid>http://twinklekumar.pt-br.wordpress.com/2008/06/29/move-sql-server-2000-database-to-2005/</guid>
<description><![CDATA[Introduction
This discussion details how to move a MS SQL 2000 database to SQL 2005 database using b]]></description>
<content:encoded><![CDATA[<p><strong>Introduction</strong><br />
This discussion details how to move a MS SQL 2000 database to SQL 2005 database using backup and restore functionality.</p>
<p><strong>Scope</strong><br />
The scope of this discussion describes if a user wants to move a database resides in MS SQL 2000 to MS SQL 2005 by backing up a database in MS SQL 2000 and restore it in MS SQL 2005. Along with the database backup which specific configurations and settings pertaining to a database, needs to backup and restore, will determined by the user.</p>
<p><strong>Intended Audience</strong><br />
The intended audiences for this discussion are a technical group or a user who is willing to perform this task and having basic knowledge of MS SQL Server.</p>
<p><strong>Moving Database</strong><br />
Moving a particular database from MS SQL 2000 to 2005 can be performed in following two steps.<br />
1. Backup a database from SQL 2000<br />
2. Restore a backup copy into SQL 2005</p>
<p>Let's see one by one.</p>
<p>Backup a database from SQL 2000<br />
Backing up a database can be further divided into two steps.</p>
<p>• Locate a database<br />
• Backup the actual database</p>
<p><strong>Locate a database</strong><br />
To locate a database in SQL 2000 open the enterprise manager by performing following steps</p>
<p>1. Go to Start in the windows OS<br />
2. Select Programs<br />
3. Locate Microsoft Sql Server<br />
4. Once sub menu pops up click on the Enterprise Manager</p>
<p><a href="http://twinklekumar.files.wordpress.com/2008/06/locatedatabase.png"><img class="alignnone size-medium wp-image-10" src="http://twinklekumar.wordpress.com/files/2008/06/locatedatabase.png?w=300" alt="Locate SQL Server 2000 within the system" width="300" height="206" /></a></p>
<p>5. Once Enterprise Manager Window opens, expand the tree and select Databases and then select your application specific database as shown below.</p>
<p><a href="http://twinklekumar.files.wordpress.com/2008/06/locatedatabase1.png"><img class="alignnone size-full wp-image-11" src="http://twinklekumar.wordpress.com/files/2008/06/locatedatabase1.png" alt="Locating database " width="510" height="342" /></a></p>
<p><strong>Backup the actual database</strong><br />
To backup the actual database now execute following steps</p>
<ol>1. Right click on the database located in the above steps<br />
2. Select All tasks &#62;&#62; Backup database as shown in above image<br />
3. SQL Server backup window will open &#62;&#62; Select Complete in backup<br />
4. For the Destination click on Add button<br />
5. The Destination window will open to give the file name and to decide the location of the backup file. Generally it should be C:\Program Files\Microsoft SQL Server\MSSQL\Backup<br />
6. Click on the button with ellipsis “…” which will open to select the folder and to give a name to the backup file (Here In the image I have selected the default Backup folder path of Sql server)<br />
7. Give the backup file name. Generally it should be &#60;&#62;Give .bak as an extension to the file (All the steps shown below in the image). One can decide its own backup copy name.<br />
8. Click OK twice<br />
9. Select Overwrite option (Whether to append or overwrite)<br />
10. Now on the top select Options tab and check the necessary options for your database<br />
11. Click OK to backup the database<br />
12. Once the message comes which shows the backup operation has been completed successfully, click OK.</ol>
<p><a href="http://twinklekumar.files.wordpress.com/2008/06/backup.png"><img class="alignnone size-full wp-image-12" src="http://twinklekumar.wordpress.com/files/2008/06/backup.png" alt="Backing up the database" width="510" height="351" /></a></p>
<p><strong>Restore backup copy to SQL 2005</strong><br />
Restoring the database can be divided into following steps</p>
<p>•	Moving a backup copy<br />
•	Open SQL 2005 and Restore</p>
<p><strong>Moving a backup copy</strong><br />
Now we have backup copy of our SQL 2000 database and its time to move it to a server where SQL 2005 has installed or to the desired location from where you can restore the database in SQL 2005. Generally it is recommended to move it to the backup folder of SQL 2005 installation which is by default C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup</p>
<p><strong>Open SQL 2005 and Restore</strong><br />
Follow these steps to open and start restoration</p>
<ol>
1. Go to Start in the windows OS<br />
2. Select Programs &#62;&#62; Microsoft Sql Server 2005 &#62;&#62; Sql Server Management Studio<br />
3. It may ask the authentication details based on the installation configuration, please provide it<br />
4. Once it connects to the Sql server expand the tree and select Databases<br />
5. Now right click on the Databases and click Restore Database<br />
6. The Restore Database window will open<br />
7. Give the database name by which you want to restore it (Here I have given Northwind Generally it would be same because the connection string in the application refers this name)<br />
8. Select From devices as to locate the source and backup copy<br />
9. Click ellipsis “…” button it will open the window to specify backup<br />
10. Click Add button to specify backup copy and location<br />
11. Select the .bak file as shown in the image<br />
12. Click OK twice</ol>
<p><a href="http://twinklekumar.files.wordpress.com/2008/06/restore.png"><img src="http://twinklekumar.wordpress.com/files/2008/06/restore.png" alt="Restore database" width="510" height="333" class="alignnone size-full wp-image-13" /></a></p>
<ol>
13. Now the in the restore list you can see one row with empty check box<br />
14. Check the box and select the options as shown in the image<br />
15. Check the particular restore options which suites your needs<br />
16. You can change the path of the database to restore at particular location<br />
17. Select one of the Recovery state<br />
18. Click OK and wait for restoration (It may take time based on the size of the database)<br />
19. One green progress bar at the bottom left will show the progress of restoration in %<br />
20. Once it will restore the database it will show you the confirmation message, click OK<br />
21. Now under database tree you can see the Northwind database restored successfully</ol>
<p><a href="http://twinklekumar.files.wordpress.com/2008/06/restore1.png"><img src="http://twinklekumar.wordpress.com/files/2008/06/restore1.png" alt="" width="510" height="351" class="alignnone size-full wp-image-14" /></a></p>
<p><strong>Users and permissions</strong><br />
Once you restore the database it may require inserting users or giving specific permission to a particular user.<br />
To insert new user specific to a database</p>
<ol>
1. Expand the database<br />
2. Selects users &#62;&#62; Right click and add new user<br />
3. While creating user you can choose the its role </ol>
<p>To insert new user at the SQL server level</p>
<ol>
1. Select Security folder<br />
2. Select and expand logins &#62;&#62; Double click on particular user and set its role</ol>
<p><strong>Potential problems</strong><br />
When a user move the database from 2000 to 2005 user dose not have to write any scripts for if it is doing backup and restore because it will move everything tables, stored procedures, views, user defined functions to 2005.<br />
User need not to write another connection string to connect to Sql 2005.<br />
To insert IIS_WPG user follow these steps</p>
<ol>
1. Login to Sql 2005<br />
2. Locate the application specific database<br />
3. Expand the database tree node and select security &#62;&#62; Users<br />
4. Right click the Users and click New User<br />
5. Give the name of the user to IIS_WPG</ol>
<p>Note : - If user can not found IIS_WPG group while adding as a database user first insert it in the Sql Server security &#62;&#62; logins and then try to add specific to database</p>
<ol>
6. Click on ellipsis button which will open the Select login window<br />
7. Now use browse button or Advance to locate IIS_WPG group or user and select it<br />
8. Once IIS_WPG is selected give the Schema (application specific Database) and Membership to db_Owner</ol>
<p>IIS_WPG is a group not a user and basically it includes following three users</p>
<ol>
1. NT AUTHORITY\NETWORK SERVICE<br />
2. NT AUTHORITY\SERVICE<br />
3. NT AUTHORITY\SYSTEM</ol>
<p>Basically moving database from Sql 2000 to 2005 is wide topic which can’t fit in single discussion but backup and restore is easy to use technique for quick results.</p>
<p>Link which helps to better understand the movement from Sql 2000 to 2005</p>
<p><a href="http://www.aspfree.com/c/a/MS-SQL-Server/Moving-Data-from-SQL-Server-2000-to-SQL-Server-2005/"></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Dica SQL SERVER 2000]]></title>
<link>http://mgasparin.wordpress.com/?p=16</link>
<pubDate>Fri, 13 Jun 2008 01:08:15 +0000</pubDate>
<dc:creator>mgasparin</dc:creator>
<guid>http://mgasparin.pt-br.wordpress.com/2008/06/13/dica-sql-server-2000/</guid>
<description><![CDATA[Caso o Banco de Dados Sql Server, depois de instalado, começar a ter comportamento estranho ou apre]]></description>
<content:encoded><![CDATA[<p>Caso o Banco de Dados Sql Server, depois de instalado, começar a ter comportamento estranho ou apresentar erro de conexão via rede. A dica é instale os Service Pack de atualizações, hoje (12/06/2008) o Service Pack 4 é o mais atual para o Sql Server 2000.</p>
<p>Onde achar:</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?displaylang=pt-br&#38;FamilyID=8e2dfc8d-c20e-4446-99a9-b7f0213f8bc5" target="_blank">http://www.microsoft.com/downloads/details.aspx?displaylang=pt-br&#38;FamilyID=8e2dfc8d-c20e-4446-99a9-b7f0213f8bc5</a></p>
<p>Att.</p>
<p>Marcelo Gasparin.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Recuperare solo la data da un campo DateTime]]></title>
<link>http://mrdevelopment.wordpress.com/?p=7</link>
<pubDate>Mon, 09 Jun 2008 09:40:45 +0000</pubDate>
<dc:creator>marcore</dc:creator>
<guid>http://mrdevelopment.pt-br.wordpress.com/2008/06/09/recuperare-solo-la-data-da-un-campo-datetime/</guid>
<description><![CDATA[Per recuperare solo la parte data da un campo di tipo datetime:
select DATEDIFF(D, 0, [campoDateTime]]></description>
<content:encoded><![CDATA[<p>Per recuperare solo la parte data da un campo di tipo datetime:</p>
<p>select DATEDIFF(D, 0, [campoDateTime]) From [Tabella]</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[How do I use GETDATE() within a User-Defined Function (UDF)?]]></title>
<link>http://baurdotnet.wordpress.com/?p=99</link>
<pubDate>Thu, 22 May 2008 08:38:41 +0000</pubDate>
<dc:creator>Bauyrzhan</dc:creator>
<guid>http://baurdotnet.pt-br.wordpress.com/2008/05/22/how-do-i-use-getdate-within-a-user-defined-function-udf/</guid>
<description><![CDATA[SQL Server 2000 added the support for user-defined functions, but there are a few limitations which ]]></description>
<content:encoded><![CDATA[<p style="text-align:justify;">SQL Server 2000 added the support for user-defined functions, but there are a few limitations which can be roadblocks at first. One is that you cannot use a non-deterministic function within a UDF, e.g. GETDATE(). So, let's say you are trying to create a function that returns this moment, but a day in the future (e.g. tomorrow at this exact time). You would think about it this way:<br />
<code>CREATE FUNCTION dbo.addDay()<br />
RETURNS DATETIME<br />
AS<br />
BEGIN<br />
DECLARE @dt DATETIME<br />
SET @dt = DATEADD(DAY, 1, GETDATE())<br />
RETURN @dt<br />
END</code></p>
<p style="text-align:justify;">But you will get this error message:<br />
<code>Server: Msg 443, Level 16, State 1, Procedure addDay, Line 6<br />
Invalid use of 'getdate' within a function.</code></p>
<p><!--more--></p>
<p style="text-align:justify;">So, instead, you should handle it so that you pass non-deterministic values into the function, for example:<br />
<code>CREATE FUNCTION dbo.addDay<br />
(<br />
@dt DATETIME<br />
)<br />
RETURNS DATETIME<br />
AS<br />
BEGIN<br />
SET @dt = DATEADD(DAY, 1, @dt)<br />
RETURN @dt<br />
END</code></p>
<p style="text-align:justify;">Then you can call it like this:<br />
<code>DECLARE @dt DATETIME<br />
SET @dt = GETDATE() -- or CURRENT_TIMESTAMP<br />
SELECT dbo.addDay(GETDATE())</code></p>
<p style="text-align:justify;">Another idea is to use OPENQUERY as follows:<br />
<code>CREATE FUNCTION dbo.addDay()<br />
RETURNS DATETIME<br />
AS<br />
BEGIN<br />
DECLARE @dt DATETIME<br />
SELECT @dt = dt + 1<br />
FROM OPENQUERY<br />
(<br />
YourServer,<br />
'SELECT dt = GETDATE()'<br />
)<br />
RETURN @dt<br />
END<br />
GO</code></p>
<p style="text-align:justify;">If YourServer is not configured for Data Access, you will get this error:<br />
<code>Server: Msg 7411, Level 16, State 1, Procedure addDay, Line 6<br />
Server 'YourServer' is not configured for DATA ACCESS.</code></p>
<p style="text-align:justify;">You will need to set the local linked server to allow data access in order to accept calls through OPENQUERY. You can do this using sp_serveroption:<br />
<code>EXEC sp_serveroption 'YourServer', 'DATA ACCESS', TRUE</code></p>
<p style="text-align:justify;">A less efficient (and less accurate) workaround is to use an intermediate view. This simplifies your coding a bit, since you no longer have to pass GETDATE() into the function. First, create the view:<br />
<code>CREATE VIEW dbo.vGETDATE<br />
AS<br />
BEGIN<br />
SELECT vGETDATE = GETDATE()<br />
END</code></p>
<p style="text-align:justify;">Then, create the function:<br />
<code>CREATE FUNCTION dbo.addDay()<br />
RETURNS DATETIME<br />
AS<br />
BEGIN<br />
DECLARE @dt DATETIME<br />
SELECT @dt = [vgetdate]+1 FROM vGETDATE<br />
RETURN @dt<br />
END</code></p>
<p style="text-align:justify;">And you can call it like this:<br />
<code>PRINT dbo.addDay()</code></p>
<p style="text-align:justify;">However, this has been proven to produce inconsistent results, such as this issue that Tibor Karaszi has pointed out:<br />
<code>USE Northwind<br />
GO<br />
CREATE VIEW dbo.vCurrentDateTime<br />
AS<br />
SELECT gd = GETDATE()<br />
GO<br />
CREATE FUNCTION dbo.getFromView()<br />
RETURNS DATETIME<br />
AS<br />
BEGIN<br />
RETURN (SELECT gd FROM vCurrentDateTime)<br />
END<br />
GO<br />
CREATE FUNCTION dbo.getFromSelf()<br />
(<br />
@dt DATETIME<br />
)<br />
RETURNS DATETIME<br />
AS<br />
BEGIN<br />
RETURN @dt<br />
END<br />
GO<br />
DECLARE @dt datetime<br />
SET @dt = GETDATE()<br />
SELECT DISTINCT dbo.getFromView()<br />
FROM Orders o<br />
INNER JOIN [Order Details] od<br />
ON o.OrderId = od.OrderID<br />
SELECT DISTINCT dbo.getFromSelf(@dt)<br />
FROM Orders o<br />
INNER JOIN [Order Details] od<br />
ON o.OrderId = od.OrderID<br />
GO<br />
DROP FUNCTION dbo.getFromView(), dbo.getFromSelf()<br />
DROP VIEW vCurrentDateTime</code></p>
<p style="text-align:justify;">On my machine, the first query produced anywhere from 8 to 10 rows (and this changed with every refresh), while the second query *always* produced exactly one. This is because using a non-deterministic function within the view leads to GETDATE() being evaluated multiple times as the query runs. Now, this is a contrived example, and is unlikely to resemble anything you're doing in the real world; however, I wanted to include this discrepancy for completeness, and in support of using other methods to getting GETDATE() passed into your function. My preference is to use a local variable and pass it into the function from the calling script...<br />
The difference between a deterministic and non-deterministic function is that the former always produces the same output (given the same input), whereas the latter can produce a different output each time they are called (again, with the same input). This is why system functions like GETDATE() are non-deterministic; they will produce different results each time you call them.</p>
<p><a href="http://sqlserver2000.databases.aspfaq.com/how-do-i-use-getdate-within-a-user-defined-function-udf.html" target="_blank">article source</a></p>
<p><span style="color:#ff0000;">update: </span><span style="color:#000000;">here real sample</span></p>
<p><code>USE aspg<br />
go<br />
if exists(select name from sysobjects where name='_ufn_Since' and type = 'FN')<br />
drop function dbo._ufn_Since<br />
go<br />
create function dbo._ufn_Since(@today datetime, @fromdate datetime) returns varchar(100)<br />
as<br />
begin<br />
declare @since Nvarchar(100)<br />
select @since = 'С момента регистрации: '+ case when datediff(mi,@fromdate,@today) &#60; 60 then cast(datediff(mi,@fromdate,@today) as varchar ) + ' [мин]'<br />
when datediff(mi,@fromdate,@today) &#60; 1440 then cast(datediff(mi,@fromdate,@today)/60 as varchar ) + ' [час] ' +<br />
cast(datediff(mi,@fromdate,@today)%60 as varchar ) + ' [мин]'<br />
when datediff(mi,@fromdate,@today) &#62; 1440 then cast(datediff(dd,@fromdate,@today) as varchar ) + ' [день] ' +<br />
cast(datediff(hh,@fromdate,@today)%24 as varchar) + ' [час] ' +<br />
cast(datediff(mi,@fromdate,@today)%60 as varchar ) + ' [мин]'<br />
else ''<br />
END<br />
if (@since='') set @since = 'error'<br />
return  @since<br />
end<br />
go<br />
select dbo._ufn_Since(getdate(),data) from reg<br />
go</code></p>
<p><span style="color:#0000ff;">result set looks like as:</span></p>
<p>С момента регистрации: 48 [день] 5 [час] 39 [мин]<br />
С момента регистрации: 48 [день] 5 [час] 39 [мин]<br />
С момента регистрации: 18 [день] 4 [час] 22 [мин]<br />
С момента регистрации: 18 [день] 4 [час] 5 [мин]<br />
С момента регистрации: 18 [день] 4 [час] 5 [мин]<br />
С момента регистрации: 18 [день] 4 [час] 4 [мин]<br />
С момента регистрации: 7 [день] 3 [час] 57 [мин]<br />
С момента регистрации: 4 [час] 31 [мин]<br />
С момента регистрации: 3 [час] 59 [мин]<br />
С момента регистрации: 3 [час] 13 [мин]</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Paginazione in sql server 2000 (per chi lo usa ancora)]]></title>
<link>http://mrdevelopment.wordpress.com/?p=6</link>
<pubDate>Tue, 20 May 2008 15:08:12 +0000</pubDate>
<dc:creator>marcore</dc:creator>
<guid>http://mrdevelopment.pt-br.wordpress.com/2008/05/20/paginazione-in-sql-server-2000-per-chi-lo-usa-ancora/</guid>
<description><![CDATA[Se voglio i 50 record a partire dal 30 record in sql server 2000 posso usare la sqguente sintassi:
S]]></description>
<content:encoded><![CDATA[<p>Se voglio i 50 record a partire dal 30 record in sql server 2000 posso usare la sqguente sintassi:</p>
<p><strong>SELECT<br />
	BB.*<br />
FROM<br />
(<br />
	SELECT TOP 50<br />
		AA.*<br />
	FROM<br />
	(<br />
		SELECT TOP 80<br />
			*<br />
		FROM<br />
                                 Foo.dbo.Bar<br />
		ORDER BY<br />
			ColonnaA ASC<br />
	) AA<br />
	ORDER BY AA.ColonnaA  DESC<br />
) BB<br />
ORDER BY BB.ColonnaA ASC</strong></p>
<p>M.R.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[SharePoint 2003/MOSS 2007: Take back up of content database in SQL Server 2000 and SQL Server 2005 ]]></title>
<link>http://farhanfaiz.wordpress.com/?p=73</link>
<pubDate>Fri, 16 May 2008 22:07:15 +0000</pubDate>
<dc:creator>Farhan Faiz</dc:creator>
<guid>http://farhanfaiz.pt-br.wordpress.com/2008/05/16/sharepoint-2003moss-2007-take-back-up-of-content-database-in-sql-server-2000-and-sql-server-2005/</guid>
<description><![CDATA[ 
The content database of SharePoint Portal Server 2003 ends with 1_SITE like Abc1_SITE and for MOS]]></description>
<content:encoded><![CDATA[<p class="MsoNormal" style="text-align:justify;margin:0;"> </p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">The content database of SharePoint Portal Server 2003 ends with 1_SITE like Abc1_SITE and for MOSS 2007 the convention is WSS_Content_ (followed by large string of numbers).</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">In order to take the backup of this database either it is in SQL Server 2000 or SQL Server 2005 follows the steps:</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><a name="_Toc161812450"><span style="font-family:Verdana;"><span style="font-size:small;">For SQL Server 2000</span></span></a></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">1.<span>     </span>On your database server, click Start, point to All Programs, point to Microsoft SQL Server, and then click Enterprise Manager.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">2.<span>     </span>In SQL Server Enterprise Manager, click the plus sign next to Microsoft SQL Servers.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">3.<span>     </span>Click the plus sign next to SQL Server Group.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">4.<span>     </span>Click the plus sign next to (local) (Windows NT).</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">5.<span>     </span>Click the plus sign next to Databases.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">6.<span>     </span>Right-click the database you want to back up, point to All Tasks, and then click Backup Database.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">7.<span>     </span>In the SQL Server Backup dialog box, in the Name box, specify a name for the backup, and then in the Backup area, select Database - complete.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">8.<span>     </span>In the Destination area, either select an existing destination, or:</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">a.<span>     </span>Click Add.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">b.<span>     </span>In the Select Backup Destination box, select File Name, and then next to the File Name box, click the Browse button.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">c.<span>      </span>In the Backup Device Location - (local) dialog box, in the File name box, type a file name, and then click OK.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">d.<span>     </span>Click OK again to close the Select Backup Destination dialog box.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">9.<span>     </span>Click OK to start the backup process.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">10.<span>    </span>Click OK to acknowledge that the backup process has completed.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">Repeat these steps to back up the databases that are used by SharePoint Portal Server 2003 in your environment, except for the configuration and component settings (search) databases.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><a name="_Toc161812451"><span style="font-family:Verdana;"><span style="font-size:small;"> </span></span></a></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span><span style="font-family:Verdana;"><span style="font-size:small;"> </span></span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-size:small;"><span><span style="font-family:Verdana;">For SQL Server 2005</span></span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">1.<span>     </span>On your database server, click Start, point to All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Management Studio.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">2.<span>     </span>In the Connect to Server box, fill in the connection information, and then click Connect.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">3.<span>     </span>After connecting to the appropriate instance of the SQL Server 2005 Database Engine, in Object Explorer, click the server name to expand the server tree.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">4.<span>     </span>Expand Databases, right-click the database you want to back up, point to Tasks, and then click Back Up. The Back Up Database dialog box appears.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">5.<span>     </span>In the Source section, in the Database box, verify the database name.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">6.<span>     </span>In the Backup type box, select Full.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">7.<span>     </span>Under Backup component, click Database.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">8.<span>     </span>In the Name text box, either accept the default backup set name that is suggested or type a different name for the backup set.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">9.<span>     </span>In the Destination section, choose the type of backup destination by clicking Disk or Tape, and then select a destination. To create a different destination, click Add.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;">10.<span>    </span>Click OK to start the backup process.</span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="text-align:justify;margin:0;"><span style="font-family:Verdana;"><a href="http://office.microsoft.com/download/afile.aspx?AssetID=AM101638521033"><span style="font-size:small;">http://office.microsoft.com/download/afile.aspx?AssetID=AM101638521033</span></a><span style="font-size:small;"> </span></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Bài giảng SQL Server 2000 Tiếng Việt]]></title>
<link>http://bupbegiandon.wordpress.com/?p=61</link>
<pubDate>Tue, 06 May 2008 00:28:29 +0000</pubDate>
<dc:creator>bupbegiandon</dc:creator>
<guid>http://bupbegiandon.pt-br.wordpress.com/2008/05/06/bai-gi%e1%ba%a3ng-sql-server-2000-ti%e1%ba%bfng-vi%e1%bb%87t/</guid>
<description><![CDATA[Đây là tài liệu của Trung Tâm Tin Học ĐH Khoa Học Tự Nhiên-TP.HCM
Download: http://]]></description>
<content:encoded><![CDATA[<p>Đây là tài liệu của Trung Tâm Tin Học ĐH Khoa Học Tự Nhiên-TP.HCM</p>
<p>Download:<strong> <a href="http://www.mediafire.com/?pgxybwmjjnm">http://www.mediafire.com/?pgxybwmjjnm</a></strong></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[SQL Server 2000 (tiếng Việt)]]></title>
<link>http://bupbegiandon.wordpress.com/?p=59</link>
<pubDate>Tue, 06 May 2008 00:24:54 +0000</pubDate>
<dc:creator>bupbegiandon</dc:creator>
<guid>http://bupbegiandon.pt-br.wordpress.com/2008/05/06/sql-server-2000-ti%e1%ba%bfng-vi%e1%bb%87t/</guid>
<description><![CDATA[Hướng dẫn cách làm việc với SQL Server 2000 (Tài liệu từ VDC Media eBooks)
Download:]]></description>
<content:encoded><![CDATA[<p>Hướng dẫn cách làm việc với SQL Server 2000 (Tài liệu từ VDC Media eBooks)</p>
<p>Download: <strong><a href="http://www.mediafire.com/?441dqnhx2jh">http://www.mediafire.com/?441dqnhx2jh</a></strong></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Giới thiệu cơ bản về SQL]]></title>
<link>http://bupbegiandon.wordpress.com/?p=57</link>
<pubDate>Tue, 06 May 2008 00:13:27 +0000</pubDate>
<dc:creator>bupbegiandon</dc:creator>
<guid>http://bupbegiandon.pt-br.wordpress.com/2008/05/06/gi%e1%bb%9bi-thi%e1%bb%87u-c%c6%a1-b%e1%ba%a3n-v%e1%bb%81-sql/</guid>
<description><![CDATA[SQL Server 2000 được tối ưu để có thể chạy trên môi trường cơ sở dữ liệu ]]></description>
<content:encoded><![CDATA[<p>SQL Server 2000 được tối ưu để có thể chạy trên môi trường cơ sở dữ liệu rất lớn (Very Large Database Environment) lên đến Tera-Byte và có thể phục vụ cùng lúc cho hàng ngàn user. SQL Server 2000 có thể kết hợp "ăn ý" với các server khác như Microsoft Internet Information Server (IIS), E-Commerce Server, Proxy Server....<br />
Nói tóm tắt lại như sau :<br />
* SQL là ngôn ngữ được sử dụng cho các hệ quản trị cơ sở dữ liệu (CSDL)<br />
* SQL cho phép thao tác với CSDL<br />
* SQL là ngôn ngữ chuẩn được đưa ra bởi ANSI (American National Standards Institude)<br />
* SQL có thể thực thi câu truy vấn với CSDL<br />
* SQL có thể lấy dữ liệu ra từ CSDL<br />
* SQL có thể chèn những bản ghi vào CSDL<br />
* SQL có thể xóa những bản ghi trong CSDL<br />
* SQL có thể cập nhật thêm những bản ghi vào CSDL<br />
* SQL rất dễ học</p>
<p><strong>-) SQL Database Tables</strong><br />
Lý thuyết cơ bản:</p>
<p>SQL Data Manipulation Language (DML)<br />
Những ngôn ngữ thao tác dữ liệu :</p>
<p>* SELECT - Hiển thị dữ liệu từ bảng trong CSDL<br />
* UPDATE - Cập nhật dữ liệu vào các bảng trong CSDL<br />
* DELETE - Xóa dữ liệu từ các bảng trong CSDL<br />
* INSERT INTO - Thêm dữ liệu mới vào trong một bảng CSDL<br />
* WHERE - Chỉ rõ đối tượng cần chọn</p>
<p>SQL Data Definition Language (DDL)<br />
Ngôn ngữ định nghĩa dữ liệu :</p>
<p>* CREATE TABLE - Tạo một bảng mới trong CSDL<br />
* ALTER TABLE - Sửa một bảng trong CSDL<br />
* DROP TABLE - Xóa một bảng trong CSDL<br />
* CREATE INDEX - Tạo index (dùng để search key)<br />
* DROP INDEX - Xóa index</p>
<p>Định nghĩa về PRIMARY KEY , FOREIGN KEY và UNIQUE :<br />
(Cái này sẽ gặp trong phần sau)</p>
<p><strong>PRIMARY KEY Constraint :</strong></p>
<p>Một table thường có một hay nhiều cột có giá trị mang tính duy nhất để xác định một hàng bất kỳ trong table. Ta thường gọi là Primary Key và được tạo ra khi ta Create hay Alter một table với Primary Key Constraint.</p>
<p>Một table chỉ có thể có một Primary Key constraint. Có thể có nhiều cột tham gia vào việc tạo nên một Primary Key, các cột này không thể chứa Null và giá trị trong các cột thành viên có thể trùng nhau nhưng giá trị của tất cả các cột tạo nên Primary Key phải mang tính duy nhất.</p>
<p><strong>Còn FOREIGN KEY là gì :</strong></p>
<p>Foreign Key là một cột hay một sự kết hợp của nhiều cột được sử dụng để áp đặt mối liên kết data giữa hai table. Foreign key của một table sẽ giữ giá trị của Primary key của một table khác và chúng ta có thể tạo ra nhiều Foreign key trong một table.</p>
<p>Foreign key có thể reference (tham chiếu) vào Primary Key hay cột có Unique Constraints. Foreign key có thể chứa Null. Mặc dù mục đích chính của Foreign Key Constraint là để kiểm soát data chứa trong table có Foreign key (tức table con) nhưng thực chất nó cũng kiểm soát luôn cả data trong table chứa Primary key (tức table cha). Ví dụ nếu ta delete data trong table cha thì data trong table con trở nên "mồ côi" (orphan) vì không thể reference ngược về table cha. Do đó Foreign Key constraint sẽ đảm bảo điều đó không xảy ra. Nếu bạn muốn delete data trong table cha thì trước hết bạn phải drop hay disable Foreign key trong table con trước.</p>
<p>Các ràng buộc FOREIGN KEY được sử dụng kết hợp với các ràng buộc PRIMARY KEY và UNIQUE nhằm đảm bảo tính toàn vẹn tham chiếu giữa các bảng được chỉ định.</p>
<p><strong>UNIQUE Constraint :</strong></p>
<p>Bạn có thể tạo Unique Constraint để đảm bảo giá trị của một cột nào đó không bị trùng lập. Tuy Unique Constraint và Primary Key Constraint đều đảm bảo tính duy nhất nhưng bạn nên dùng Unique Constraint trong những trường hợp sau:<br />
• Nếu một cột (hay một sự kết hợp giữa nhiều cột) không phải là primary key. Nên nhớ chỉ có một Primary Key Constraint trong một table trong khi ta có thể có nhiều Unique Constraint trên một table.<br />
• Nếu một cột cho phép chứa Null. Unique constraint có thể áp đặt lên một cột chứa giá trị Null trong khi primary key constraint thì không.<br />
Cách tạo ra Unique Constraint cũng tương tự như Primary Key Constraint chỉ việc thay chữ Primary Key thành Unique. SQL Server sẽ tự động tạo ra một non-clustered unique index khi ta tạo một Unique Constraint.</p>
<div class="cssDefaultSupportLinks" style="height:24px;padding-right:5px;"><em>Theo</em> <strong>.NET Việt Nam</strong></div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Học SQL Server 2000]]></title>
<link>http://bupbegiandon.wordpress.com/?p=49</link>
<pubDate>Mon, 05 May 2008 23:09:51 +0000</pubDate>
<dc:creator>bupbegiandon</dc:creator>
<guid>http://bupbegiandon.pt-br.wordpress.com/2008/05/06/h%e1%bb%8dc-sql-server-2000/</guid>
<description><![CDATA[I. Tổng quan
1. Câu lệnh SQL
SQL chuẩn bao gồm 40 câu lệnh. Sau đây là danh sách cá]]></description>
<content:encoded><![CDATA[<h1><span style="font-size:13pt;font-family:&#34;color:#c00000;">I. Tổng quan</span></h1>
<h2><span style="font-size:13pt;font-family:&#34;">1. Câu lệnh SQL</span></h2>
<p class="MsoNormal" style="text-indent:0.5in;"><span style="font-size:13pt;line-height:115%;font-family:&#34;">SQL<span> </span>chuẩn bao gồm 40 câu lệnh. Sau đây là danh sách các câu lệnh thường được sử dụng nhất trong số các câu lệnh SQL</span></p>
<table class="MsoNormalTable" style="border:medium none;border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border:1pt solid windowtext;width:221.4pt;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><span style="font-size:13pt;font-family:&#34;">Câu lệnh</span></strong></p>
</td>
<td style="width:221.4pt;border:1pt 1pt 1pt medium solid solid solid none windowtext windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><span style="font-size:13pt;font-family:&#34;">Chức năng</span></strong></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><span style="font-size:13pt;font-family:&#34;">Thao tác dữ liệu</span></strong></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;"> </span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">SELECT</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Truy xuất   dữ liệu</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">INSERT</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Bổ sung   dữ liệu</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">UPDATE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Cập nhật   dữ liệu</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">DELETE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Xoá dữ   liệu</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">TRUNCATE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Xóa toàn   bộ dữ liệu trong bảng</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><span style="font-size:13pt;font-family:&#34;">Định nghĩa dữ liệu</span></strong></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;"> </span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">CREATE   TABLE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Tạo bảng</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">DROP   TABLE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Xóa bảng</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">ALTER   TABLE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Sửa đổi   bảng</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">CREATE   VIEW</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Tạo   khung nhìn</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">ALTER   VIEW</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Sửa đổi   khung nhìn</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">DROP   VIEW</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Xóa   khung nhìn</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">CREATE   INDEX</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Tạo chỉ   mục</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">DROP   INDEX</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Xóa chỉ   mục</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">CREATE   SCHEMA</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Tạo lược   đồ csdl</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">DROP   SCHEMA</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Xóa lược   đồ csdl</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">CREATE   PROCEDURE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Tạo thủ   tục lưu trữ</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">ALTER   PROCEDURE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Sửa đổi   thủ tục lưu trữ</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">DROP   PROCEDURE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Xóa thủ   tục lưu trữ</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">CREATE   FUNCTION</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Tạo hàm</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">ALTER   FUNCTION</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Sửa đổi   hàm</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">DROP   FUNCTION</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Xóa hàm</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">CREATE   TRIGGER</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Tạo   trigger</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">ALTER   TRIGGER</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Sửa đổii   trigger</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">DROP   TRIGGER</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Xóa   trigger</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><span style="font-size:13pt;font-family:&#34;">Điểu khiển truy cập</span></strong></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;"> </span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">GRANT</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Cấp phát   quyền cho người sử dụng</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">REVOKE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Thu hồi   quyền từ người sử dụng</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><span style="font-size:13pt;font-family:&#34;">Quản lý giao tác</span></strong></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;"> </span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">COMMIT</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Ủy   thác(kết thúc thành công) giao tác</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">ROLLBACK</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Quay lui   giao tác</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">SAVE   TRANSACTION</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Đánh dấu   một điểm trong giao tác</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><span style="font-size:13pt;font-family:&#34;">Lập trình</span></strong></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;"> </span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">DECLARE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Khai báo   biến hoặc định nghĩa con trỏ</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">OPEN</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Mở một   con trỏ để truy xuất kết quả truy vấn</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">FETCH</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Đọc một   dòng trong kết quả truy vấn(sử dụng con trỏ)</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">CLOSE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Đóng một   con trỏ</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">EXECUTE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Thực thi   một câu lệnh SQL</span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"> </span></p>
<h1><span style="font-size:13pt;font-family:&#34;">2. Kiểu dữ liệu</span></h1>
<table class="MsoNormalTable" style="border:medium none;border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border:1pt solid windowtext;width:221.4pt;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Tên kiểu</span></p>
</td>
<td style="width:221.4pt;border:1pt 1pt 1pt medium solid solid solid none windowtext windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Mô tả</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">CHAR (n)</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Kiểu chuỗi   với độ dài cố định</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">NCHAR   (n)</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Kiếu chuỗi   với độ dài cố định hỗ trợ UNICODE</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">VARCHAR   (n)</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Kiểu chuỗi   với độ dài chính<span> </span>xác</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">NVARCHAR   (n)</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Kiểu chuỗi   với độ dài chính<span> </span>xác hỗ trợ UNICODE</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">INTEGER</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Số   nguyên có giá trị từ -231 đến 231 – 1</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">INT</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Như kiểu   Integer</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">TINYTINT</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Số   nguyên có giá trị từ 0 đến 255.</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">SMALLINT</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Số   nguyên có giá trị từ -215<span> </span>đến 215 – 1</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">BIGINT</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Số   nguyên có giá trị từ -263<span> </span>đến 263-1</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">NUMERIC   (p,s)</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Kiểu số   với độ chính xác cố định</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">DECIMAL   (p,s)</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Tương tự   kiểu Numeric</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">FLOAT</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Số thực   có giá trị từ -1.79E+308 đến 1.79E+308</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">REAL</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Số thực   có giá trị từ -3.40E + 38 đến 3.40E + 38</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">MONEY</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Kiểu tiền   tệ</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">BIT</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Kiểu bit   (có giá trị 0 hoặc 1)</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">DATETIME</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Kiểu   ngày giờ (chính xác đến phần trăm của giây)</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">SMALLDATETIME</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Kiểu   ngày giờ (chính xác đến phút)</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">TIMESTAMP</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;text-indent:0.5in;line-height:normal;"><span style="font-size:13pt;font-family:&#34;"> </span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">BINARY</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Dữ liệu   nhị phân với độ dài cố định (tối đa 8000 bytes)</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">VARBINARY</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Dữ liệu   nhị phân với độ dài chính xác (tối đa 8000 bytes)</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">IMAGE</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Dữ liệu   nhị phân với độ dài chính xác (tối đa 2,147,483,647 bytes)</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">TEXT</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Dữ liệu   kiếu chuỗi với độ dài lớn (tối đa 2,147,483,647 ký tự)</span></p>
</td>
</tr>
<tr>
<td style="width:221.4pt;border:medium 1pt 1pt none solid solid 0 windowtext windowtext;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">NTEXT</span></p>
</td>
<td style="width:221.4pt;border:medium 1pt 1pt medium none solid solid none 0 windowtext windowtext 0;padding:0 5.4pt;" width="295" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">Dữ liệu   kiếu chuỗi với độ dài lớn và hỗ trợ UNICODE (tối </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;">đa   1,073,741,823 ký tự)</span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"> </span></p>
<h2><span style="font-size:13pt;font-family:&#34;">Giá trị NULL<span> </span></span></h2>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>Một cơ sở dữ liệu là sự phản ánh của một hệ thống trong thế giới thực, do đó </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">các giá trị dữ liệu tồn tại trong cơ sở dữ liệu có thể không xác định được. Một giá trị </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">không xác định được xuất hiện trong cơ sở dữ liệu có thể do một số nguyên nhân sau: </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Giá trị đó có tồn tại nhưng không biết. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Không xác định được giá trị đó có tồn tại hay không. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Tại một thời điểm nào đó giá trị chưa có nhưng rồi có thể sẽ có. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Giá trị bị lỗi do tính toán (tràn số, chia cho không,...) </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Những giá trị không xác định được biểu diễn trong cơ sở dữ liệu quan hệ bởi </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">các giá trị NULL. Đây là giá trị đặc biệt và không nên nhầm lẫn với chuỗi rỗng (đối </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">với dữ liệu kiểu chuỗi) hay giá trị không (đối với giá trị kiểu số). Giá trị NULL đóng </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">một vai trò quan trọng trong các cơ sở dữ liệu và hầu hết các hệ quản trị cơ sở dữ liệu </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">quan hệ hiện nay đều hỗ trợ việc sử dụng giá trị này.</span></p>
<p class="MsoNormal"><strong><span style="font-size:13pt;line-height:115%;font-family:&#34;color:#c00000;">II. NGÔN NGỮ THAO TÁC DỮ LIỆU</span></strong></p>
<h1><em><span style="font-size:13pt;font-family:&#34;">1. Truy xuất dữ liệu với câu lệnh SELECT </span></em></h1>
<p class="MsoNormal" style="text-indent:0.5in;"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Cú pháp chung của câu lệnh SELECT có dạng:<span> </span></span></p>
<table class="MsoNormalTable" style="border:medium none;border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border:1pt solid windowtext;width:6.15in;padding:0 5.4pt;" width="590" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;"><span> </span><strong><em><span style="color:#3366ff;">SELECT [ALL &#124;   DISTINCT][TOP n] danh_sách_chọn<span> </span></span></em></strong></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><em><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[INTO tên_bảng_mới] </span></em></strong></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><em><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>FROM<span> </span>danh_sách_bảng/khung_nhìn </span></em></strong></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><em><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[WHERE<span> </span>điều_kiện] </span></em></strong></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><em><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[GROUP BY<span> </span>danh_sách_cột] </span></em></strong></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><em><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[HAVING điều_kiện] </span></em></strong></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><em><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[ORDER BY<span> </span>cột_sắp_xếp] </span></em></strong></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><em><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[COMPUTE<span> </span>danh_sách_hàm_gộp [BY danh_sách_cột]]</span></em></strong><span style="font-size:13pt;font-family:&#34;"></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="text-align:center;" align="center"><span style="font-size:13pt;line-height:115%;font-family:&#34;"> </span></p>
<p class="MsoNormal" style="text-indent:0.5in;"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Điều cần lưu ý đầu tiên đối với câu lệnh này là các thành phần trong câu lệnh </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">SELECT nếu được sử dụng phải tuân theo đúng thứ tự như trong cú pháp. Nếu không, </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">câu lệnh sẽ được xem là không hợp lệ. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>Câu lệnh SELECT được sử dụng để tác động lên các bảng dữ liệu và kết quả </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">của câu lệnh cũng được hiển thị dưới dạng bảng, tức là một tập hợp các dòng và các </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">cột (ngoại trừ trường hợp sử dụng câu lệnh SELECT với mệnh đề COMPUTE).</span></p>
<h2><span style="font-size:13pt;font-family:&#34;">2 Bổ sung, cập nhật và xoá dữ liệu<span> </span></span></h2>
<h3><span style="font-family:&#34;">2.1 Bổ sung dữ liệu</span></h3>
<p class="MsoNormal" style="margin-left:0.5in;"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Bổ sung từng dòng dữ liệu với mỗi câu lệnh INSERT. Đây là các sử dụng </span></p>
<p class="MsoNormal" style="margin-left:0.5in;"><span style="font-size:13pt;line-height:115%;font-family:&#34;">thường gặp nhất trong giao tác SQL. </span></p>
<p class="MsoNormal" style="margin-left:0.5in;"><span style="font-size:13pt;line-height:115%;font-family:&#34;color:#3366ff;"><span> </span>INSERT<span> </span>INTO tên_bảng[(danh_sách_cột)] <span> </span><span> </span>VALUES(danh_sách_trị)</span></p>
<p class="MsoNormal" style="margin-left:0.5in;"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Bổ sung nhiều dòng dữ liệu bằng cách truy xuất dữ liệu từ các bảng dữ liệu </span></p>
<p class="MsoNormal" style="margin-left:0.5in;"><span style="font-size:13pt;line-height:115%;font-family:&#34;">khác.<span> </span><span style="color:#3366ff;"></span></span></p>
<p class="MsoNormal" style="margin-left:0.5in;"><span style="font-size:13pt;line-height:115%;font-family:&#34;color:#3366ff;"><span> </span>INSERT<span> </span>INTO tên_bảng[(danh_sách_cột)] câu_lệnh_SELECT</span></p>
<h3><span style="font-family:&#34;">2.2 Cập nhật dữ liệu </span></h3>
<p class="MsoNormal" style="text-indent:0.5in;"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Câu lệnh này có cú pháp như sau: </span></p>
<table class="MsoNormalTable" style="border:medium none;border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border:1pt solid windowtext;width:6.15in;padding:0 5.4pt;" width="590" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>UPDATE tên_bảng </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>SET<span> </span>tên_cột = biểu_thức </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[, ...,   tên_cột_k = biểu_thức_k] </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[FROM<span> </span>danh_sách_bảng] </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[WHERE điều_kiện]</span><span style="font-size:13pt;font-family:&#34;"></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"> </span></p>
<h3><span style="font-family:&#34;">2.3 Xoá dữ liệu </span></h3>
<p class="MsoNormal" style="text-indent:0.5in;"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Cú pháp :<span style="color:#3366ff;"></span></span></p>
<table class="MsoNormalTable" style="border:medium none;border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border:1pt solid windowtext;width:6.15in;padding:0 5.4pt;" width="590" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;">DELETE FROM tên_bảng </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[FROM danh_sách_bảng] </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[WHERE điều_kiện] </span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;color:#3366ff;"> </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>Trong câu lệnh này, tên của bảng cần xoá dữ liệu được chỉ định sau DELETE FROM. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Mệnh đề WHERE trong câu lệnh được sử dụng để chỉ định điều kiện đối với các dòng </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">dữ liệu cần xoá. Nếu câu lệnh DELETE không có mệnh đề WHERE thì toàn bộ các </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">dòng dữ liệu trong bảng đều bị xoá.</span></p>
<p class="MsoNormal"><strong><span style="font-size:13pt;line-height:115%;font-family:&#34;">Xoá dữ liệu khi điều kiện liên quan đến nhiều bảng </span></strong></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Nếu điều kiện<span> </span>trong<span> </span>câu<span> </span>lệnh DELETE liên quan đến<span> </span>các<span> </span>bảng không phải<span> </span>là </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">bảng cần xóa dữ liệu, ta phải sử dụng thêm mệnh đề FROM và sau đó là danh sách tên </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">các bảng đó. Trong trường hợp này, trong mệnh đề WHERE ta chỉ định thêm điều kiện </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">nối giữa các bảng </span></p>
<h1><span style="font-size:13pt;font-family:&#34;color:#c00000;">III. NGÔN NGỮ ĐỊNH NGHĨA DỮ LIỆU</span></h1>
<h2><span style="font-size:13pt;font-family:&#34;">3.1 Tạo bảng dữ liệu </span></h2>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Câu lệnh CREATE TABLE có cú pháp như sau </span></p>
<table class="MsoNormalTable" style="border:medium none;border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border:1pt solid windowtext;width:6.15in;padding:0 5.4pt;" width="590" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;">CREATE TABLE tên_bảng </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;">(<span> </span>tên_cột<span> </span>thuộc_tính_cột<span> </span>các_ràng_buộc </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[,... </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>,tên_cột_n thuộc_tính_cột_n<span> </span>các_ràng_buộc_cột_n] </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[,các_ràng_buộc_trên_bảng] </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>) </span><span style="font-size:13pt;font-family:&#34;"></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"> </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Trong đó: </span></p>
<p class="MsoNormal"><strong><span style="font-size:13pt;line-height:115%;font-family:&#34;">tên_bảng : </span></strong><span style="font-size:13pt;line-height:115%;font-family:&#34;">Tên của bảng cần tạo. Tên phải tuân theo qui tắc định danh và </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">không được vượt quá 128 ký tự. </span></p>
<p class="MsoNormal"><strong><span style="font-size:13pt;line-height:115%;font-family:&#34;">tên_cột</span></strong><span style="font-size:13pt;line-height:115%;font-family:&#34;">: là tên<span> </span>của<span> </span>cột<span> </span>(trường)<span> </span>cần<span> </span>định<span> </span>nghĩa,<span> </span>tên<span> </span>cột<span> </span>phải<span> </span>tuân<span> </span>theo </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">qui<span> </span>tắc<span> </span>định<span> </span>danh<span> </span>và<span> </span>không<span> </span>được<span> </span>trùng<span> </span>nhau<span> </span>trong<span> </span>mỗi<span> </span>một bảng.<span> </span>Mỗi một bảng phải có ít nhất một cột. Nếu bảng có nhiều cột<span> </span>thì<span> </span>định<span> </span>nghĩa<span> </span>của<span> </span>các<span> </span>cột<span> </span>(tên<span> </span>cột,<span> </span>thuộc<span> </span>tính<span> </span>và<span> </span>các<span> </span>ràng buộc) phải phân cách nhau bởi dấu phẩy. </span></p>
<p class="MsoNormal"><strong><span style="font-size:13pt;line-height:115%;font-family:&#34;">thuộc_tính_cột:</span></strong><span style="font-size:13pt;line-height:115%;font-family:&#34;"> Mỗi một cột trong một bảng ngoài tên cột còn có các thuộc tính </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">bao gồm: </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Kiểu dữ liệu của cột. Đây là thuộc tính bắt buộc phải có đối với mỗi cột. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Giá trị mặc định của cột: là giá trị được tự động gán cho<span> </span>cột<span> </span>nếu<span> </span>như<span> </span>người<span> </span>sử<span> </span>dụng<span> </span>không<span> </span>nhập<span> </span>dữ<span> </span>liệu cho cột một cách tường minh. Mỗi một cột chỉ có thể </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">có nhiều nhất một giá trị mặc định. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Cột có tính chất IDENTITY hay không? tức là giá trị của cột có được tự động tăng mỗi khi có bản ghi mới được bổ sung hay không. Tính chất này chỉ có thể sử </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">dụng đối với các trường kiểu số. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Cột có chấp nhận giá trị NULL hay không</span></p>
<p class="MsoNormal"><strong><span style="font-size:13pt;line-height:115%;font-family:&#34;">các_ràng_buộc:</span></strong><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span></span></p>
<h3><span style="font-family:&#34;">3.1.1 Ràng buộc CHECK </span></h3>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>Ràng buộc CHECK được sử dụng nhằm chỉ định điều kiện hợp lệ đối với dữ </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">liệu. Mỗi khi có sự thay đổi dữ liệu trên bảng (INSERT, UPDATE), những ràng buộc </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">này sẽ<span> </span>được sử dụng nhằm kiểm tra xem dữ liệu mới có hợp lệ hay không.<span> </span></span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>Ràng buộc CHECK được khai báo theo cú pháp như sau: </span></p>
<table class="MsoNormalTable" style="border:medium none;border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border:1pt solid windowtext;width:6.15in;padding:0 5.4pt;" width="590" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;"><span> </span>[<span style="color:#3366ff;">CONSTRAINT   tên_ràng_buộc] </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>CHECK (điều_kiện)</span><span style="font-size:13pt;font-family:&#34;"></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"> </span></p>
<h3><span style="font-family:&#34;">3.1.2 Ràng buộc PRIMARY KEY </span></h3>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>Ràng buộc PRIMARY KEY được sử dụng để định nghĩa khoá chính của bảng. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Khoá chính của một bảng là một hoặc một tập nhiều cột mà giá trị của chúng là duy </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">nhất<span> </span>trong<span> </span>bảng.<span> </span>Hay<span> </span>nói<span> </span>cách<span> </span>khác,<span> </span>giá<span> </span>trị<span> </span>của<span> </span>khoá<span> </span>chính<span> </span>sẽ<span> </span>giúp<span> </span>cho<span> </span>ta<span> </span>xác<span> </span>định được duy nhất một dòng (bản ghi) trong bảng dữ liệu. Mỗi một bảng chỉ có thể có duy nhất<span> </span>một<span> </span>khoá<span> </span>chính<span> </span>và<span> </span>bản<span> </span>thân<span> </span>khoá<span> </span>chính<span> </span>không<span> </span>chấp<span> </span>nhận<span> </span>giá<span> </span>trị<span> </span>NULL.<span> </span>Ràng buộc PRIMARY KEY là cơ sở cho việc đảm bảo tính toàn vẹn thực thể cũng như toàn vẹn tham chiếu.<span> </span></span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Để khai báo một ràng buộc PRIMARY KEY, ta sử dụng cú pháp như sau: <span style="color:#3366ff;"><span> </span></span></span></p>
<table class="MsoNormalTable" style="border:medium none;border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border:1pt solid windowtext;width:6.15in;padding:0 5.4pt;" width="590" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;">[CONSTRAINT tên_ràng_buộc] </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>PRIMARY KEY   [(danh_sách_cột)]</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"> </span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;color:#3366ff;"> </span></p>
<h3><span style="font-family:&#34;">3.1.3 Ràng buộc UNIQUE </span></h3>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>Trên một bảng chỉ có thể có nhiều nhất một khóa chính nhưng có thể có nhiều </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">cột hoặc tập các cột có tính chất như khoá chính, tức là giá trị của chúng là duy nhất </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">trong bảng. Tập một hoặc nhiều cột có giá trị duy nhất và không được chọn làm khoá </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">chính được gọi là khoá phụ (khoá dự tuyển) của bảng. Như vậy, một bảng chỉ có nhiều </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">nhất một khoá chính nhưng có thể có nhiều khoá phụ. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>Ràng<span> </span>buộc<span> </span>UNIQUE<span> </span>được<span> </span>sử<span> </span>dụng<span> </span>trong<span> </span>câu<span> </span>lệnh<span> </span>CREATE<span> </span>TABLE để<span> </span>định nghĩa khoá phụ cho bảng và được khai báo theo cú pháp sau đây: </span></p>
<table class="MsoNormalTable" style="border:medium none;border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border:1pt solid windowtext;width:6.15in;padding:0 5.4pt;" width="590" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span></span><span style="font-size:13pt;font-family:&#34;color:#3366ff;">[CONSTRAINT tên_ràng_buộc]<span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>UNIQUE [(danh_sách_cột)]</span><span style="font-size:13pt;font-family:&#34;"></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"> </span></p>
<h3><span style="font-family:&#34;">3.1.4 Ràng buộc FOREIGN KEY </span></h3>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>Ràng buộc FOREIGN KEY được sử dụng trong định nghĩa bảng dữ liệu nhằm </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">tạo nên mối quan hệ giữa các bảng trong một cơ sở dữ liệu. Một hay một tập các cột </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">trong một bảng được gọi là khoá ngoại, tức là có ràng buộc FOREIGN KEY, nếu giá </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">trị của nó được xác định từ khoá chính (PRIMARY KEY) hoặc khoá phụ (UNIQUE) </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">của một bảng dữ liệu khác.</span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Ràng buộc FOREIGN KEY được định nghĩa theo cú pháp dưới đây: </span></p>
<table class="MsoNormalTable" style="border:medium none;border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border:1pt solid windowtext;width:6.15in;padding:0 5.4pt;" width="590" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;">[CONSTRAINT tên_ràng_buộc] </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>FOREIGN KEY   [(danh_sách_cột)] </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>REFERENCES tên_bảng_tham_chiếu(danh_sách_cột_tham_chiếu) </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[ON DELETE CASCADE &#124; NO   ACTION &#124; SET NULL &#124; SET DEFAULT] </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:13pt;font-family:&#34;color:#3366ff;"><span> </span>[ON UPDATE CASCADE &#124; NO   ACTION &#124; SET NULL &#124; SET DEFAULT]</span><span style="font-size:13pt;font-family:&#34;"></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"> </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">Việc định nghĩa một ràng buộc FOREIGN KEY bao gồm các yếu tố sau: </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Tên<span> </span>cột<span> </span>hoặc<span> </span>danh<span> </span>sách<span> </span>cột<span> </span>của<span> </span>bảng<span> </span>được<span> </span>định<span> </span>nghĩa<span> </span>tham<span> </span>gia<span> </span>vào<span> </span>khoá </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">ngoài. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Tên<span> </span>của<span> </span>bảng được<span> </span>tham<span> </span>chiếu<span> </span>bởi<span> </span>khoá<span> </span>ngoài<span> </span>và<span> </span>danh<span> </span>sách<span> </span>các<span> </span>cột<span> </span>được </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">tham chiếu đến trong bảng tham chiếu. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Cách thức xử lý đối với các bản ghi trong bảng được định nghĩa trong trường </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">hợp<span> </span>các<span> </span>bản<span> </span>ghi<span> </span>được<span> </span>tham<span> </span>chiếu<span> </span>trong<span> </span>bảng<span> </span>tham<span> </span>chiếu<span> </span>bị<span> </span>xoá<span> </span>(ON </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">DELETE) hay cập nhật (ON UPDATE). SQL chuẩn đưa ra 4 cách xử lý: </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>CASCADE: Tự động xoá (cập nhật) nếu bản ghi được tham chiếu </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">bị xoá (cập nhật). </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>NO<span> </span>ACTION:<span> </span>(Mặc<span> </span>định)<span> </span>Nếu<span> </span>bản<span> </span>ghi<span> </span>trong<span> </span>bảng<span> </span>tham<span> </span>chiếu </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">đang<span> </span>được<span> </span>tham<span> </span>chiếu<span> </span>bởi<span> </span>một<span> </span>bản<span> </span>ghi<span> </span>bất<span> </span>kỳ<span> </span>trong<span> </span>bảng<span> </span>được </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">định nghĩa thì bàn ghi đó không được phép xoá hoặc cập nhật (đối </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">với cột được tham chiếu).<span> </span></span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>SET<span> </span>NULL:<span> </span>Cập<span> </span>nhật<span> </span>lại<span> </span>khoá<span> </span>ngoài<span> </span>của<span> </span>bản<span> </span>ghi<span> </span>thành<span> </span>giá<span> </span>trị </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">NULL (nếu cột cho phép nhận giá trị NULL). </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>SET DEFAULT: Cập nhật lại khoá ngoài của bản ghi nhận giá trị </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">mặc định (nếu cột có qui định giá trị mặc định).</span></p>
<h2><span style="font-size:13pt;font-family:&#34;">3.2 Sửa đổi định nghĩa bảng </span></h2>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;"><span> </span>Một bảng sau khi đã được định nghĩa bằng câu lệnh CREATE TABLE có thể </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">được<span> </span>sửa<span> </span>đổi<span> </span>thông<span> </span>qua<span> </span>câu<span> </span>lệnh<span> </span>ALTER<span> </span>TABLE.<span> </span>Câu<span> </span>lệnh<span> </span>này<span> </span>cho<span> </span>phép<span> </span>chúng<span> </span>ta thực hiện được các thao tác sau: </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-family:&#34;">•<span> </span>Bổ sung một cột vào bảng. </span></p>
<p class="MsoNormal"><span style="font-size:13pt;line-height:115%;font-f