<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>LUTI @ Microsoft</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/luti/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/luti/feed.xml</link>
    <description>Another SQL Server geek at Microsoft</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:13:05 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Uniqueifier details in SQL Server</title>
      <link>https://docs.microsoft.com/archive/blogs/luti/uniqueifier-details-in-sql-server</link>
      <pubDate>Fri, 16 Feb 2018 19:22:52 GMT</pubDate>
      <dc:creator><![CDATA[Luciano Moreira]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/luti/?p=1625</guid>
      <description><![CDATA[This is a follow up post for...]]></description>
      <content:encoded><![CDATA[This is a follow up post for <a href="https://blogs.msdn.microsoft.com/psssql/2018/02/16/uniqueifier-cons…ns-and-error-666/">https://blogs.msdn.microsoft.com/psssql/2018/02/16/uniqueifier-cons…ns-and-error-666/</a>, for the ones that want to delve into the subject.

First a quick background on uniqueifiers...

A uniqueifier (or uniquifier as reported by SQL Server internal tools) is a 4-byte value used to make each key unique in a clustered index that allow duplicate key values. This uniqueness is required because each clustering key must point to exactly one record, without the uniqueifier a non-unique clustering key could relate to two or more records.

Since those values are not public exposed, we need to rely on undocumented/unsupported commands to check the details of it (for instance, DBCC PAGE - <a href="https://blogs.msdn.microsoft.com/sqlserverstorageengine/2006/06/10/how-to-use-dbcc-page/">https://blogs.msdn.microsoft.com/sqlserverstorageengine/2006/06/10/how-to-use-dbcc-page/</a>)

You can use the script 01 to check uniqueifier values for different keys, adjusting it to your environment. Please note that you need a way to identify the most recent records inserted, adding a tiebreaker to get the latest uniqueifier used.

&nbsp;

<em>Script 01 – Checking uniqueifier values</em>
<pre>-- CREATE DATABASE UNIQUIFIER

USE UNIQUIFIER
GO

IF OBJECT_ID('dbo.UniqTable') IS NOT NULL
  DROP TABLE dbo.UniqTable
go

CREATE TABLE dbo.UniqTable
(SystemCode INT NOT NULL DEFAULT (1)
, SampleEntry CHAR(2000) NOT NULL
, RecordDate DATETIME DEFAULT (SYSDATETIME()))
GO

CREATE CLUSTERED INDEX idxSystemCode
ON dbo.UniqTable(SystemCode)
GO

-- INSERT Rows
INSERT INTO dbo.UniqTable (SystemCode, SampleEntry)
SELECT TOP 10 1, mc.type
FROM sys.dm_os_memory_clerks AS MC
WAITFOR DELAY '00:00:00.100'

INSERT INTO dbo.UniqTable (SystemCode, SampleEntry)
SELECT TOP 10 2, mc.type
FROM sys.dm_os_memory_clerks AS MC
WAITFOR DELAY '00:00:00.100'
GO 5

INSERT INTO dbo.UniqTable (SystemCode, SampleEntry)
SELECT TOP 10 1, mc.type
FROM sys.dm_os_memory_clerks AS MC
GO

-- Checking pages with latest records
SELECT *, sys.fn_physlocformatter(%%PHYSLOC%%)
FROM dbo.UniqTable AS UT
ORDER BY UT.RecordDate, UT.SystemCode
GO

/*
Last entry for each SystemCode
1      MEMORYCLERK_SQLSTORENG     2018-01-29 12:01:40.700    (1:525:2)
2      MEMORYCLERK_SQLSTORENG     2018-01-29 12:01:40.583    (1:522:2)
*/

-- Checking uniqueifiers on each page:
DBCC TRACEON(3604)
DBCC PAGE ('UNIQUIFIER', 1, 525, 3)
GO

/*
Slot 2 Column 0 Offset 0x7e7 Length 4 Length (physical) 4
UNIQUIFIER = 59
Slot 2 Column 1 Offset 0x4 Length 4 Length (physical) 4
SystemCode = 1
*/

DBCC PAGE ('UNIQUIFIER', 1, 522, 3)
/*
Slot 2 Column 0 Offset 0x7e7 Length 4 Length (physical) 4
UNIQUIFIER = 49
Slot 2 Column 1 Offset 0x4 Length 4 Length (physical) 4
SystemCode = 2
*/</pre>
&nbsp;

If some records are deleted from the table, is possible to notice gaps in the UNIQUEIFIER sequence, and a REBUILD ALL ONLINE will reset those uniqueifiers (see script 02).

It is also important to point out one specific aspect that Paul Randal blogged some time ago, related to uniqueifiers changes from SQL Server 2000 to 2005: <a href="https://blogs.msdn.microsoft.com/sqlserverstorageengine/2007/06/07/what-happens-to-non-clustered-indexes-when-the-table-structure-is-changed/">https://blogs.msdn.microsoft.com/sqlserverstorageengine/2007/06/07/what-happens-to-non-clustered-indexes-when-the-table-structure-is-changed/</a>
<p style="padding-left: 30px"><em>"Aha! This is different from SQL Server 2000. SQL Server 2005 will RE-USE the old uniqueifier values so the cluster keys don’t change. This means that non-clustered indexes are NOT rebuilt in this case – that’s very cool!"</em></p>
As of February 2018, the design goal for the storage engine is to not reset uniqueifiers during REBUILDs. As such, rebuild of the index ideally would not reset uniquifiers and issue would continue to occur while inserting new data with key value for which the uniquifiers were exhausted. But current engine behavior is different for one specific case, if you use the statement <em>ALTER INDEX ALL ON &lt;TABLE&gt; REBUILD WITH (ONLINE = ON)</em>, it will reset the uniqueifiers (across all version starting SQL Server 2005 to SQL Server 2017).
<p style="padding-left: 30px"><em>Important:</em> <em>This is something that is not documented and can change in future versions, so our recommendation is that you should review table design to avoid relying on it.</em></p>
&nbsp;

<em>Script 02 – Resetting uniqueifier values</em><em> </em>
<pre>-- Adding some gaps to the sequence:
;WITH C AS (
SELECT *, ROW_NUMBER()  OVER(PARTITION BY SystemCode ORDER BY RecordDate ASC) AS Ord FROM dbo.UniqTable
)
DELETE FROM C
WHERE (C.Ord % 2) = 1
GO

-- Checking pages with latest records
SELECT *, sys.fn_physlocformatter(%%PHYSLOC%%)
FROM dbo.UniqTable AS UT
ORDER BY UT.RecordDate, UT.SystemCode
GO

-- Checking uniqueifiers on each page:
DBCC PAGE ('UNIQUIFIER', 1, 537, 3)
/*
Slot 0 Column 0 Offset 0x20b Length 4 Length (physical) 4
UNIQUIFIER = 53
Slot 0 Column 1 Offset 0x4 Length 4 Length (physical) 4
SystemCode = 1

... next entry ...

Slot 1 Column 0 Offset 0x20b Length 4 Length (physical) 4
UNIQUIFIER = 55
Slot 1 Column 1 Offset 0x4 Length 4 Length (physical) 4
SystemCode = 1

... next entry ...

Slot 2 Column 0 Offset 0x20b Length 4 Length (physical) 4
UNIQUIFIER = 57
Slot 2 Column 1 Offset 0x4 Length 4 Length (physical) 4
SystemCode = 1
*/

DBCC PAGE ('UNIQUIFIER', 1, 536, 3)

/*
Slot 0 Column 0 Offset 0x20b Length 4 Length (physical) 4
UNIQUIFIER = 35
Slot 0 Column 1 Offset 0x4 Length 4 Length (physical) 4
SystemCode = 2

... next entry ...

Slot 1 Column 0 Offset 0x20b Length 4 Length (physical) 4
UNIQUIFIER = 37
Slot 1 Column 1 Offset 0x4 Length 4 Length (physical) 4
SystemCode = 2

... next entry ...

Slot 2 Column 0 Offset 0x20b Length 4 Length (physical) 4
UNIQUIFIER = 39
Slot 2 Column 1 Offset 0x4 Length 4 Length (physical) 4
SystemCode = 2
*/

-- TRIGGER uniquifier reset
ALTER INDEX ALL ON dbo.UniqTable REBUILD WITH(ONLINE = ON)
GO

-- Checking pages with latest records
SELECT *, sys.fn_physlocformatter(%%PHYSLOC%%)
FROM dbo.UniqTable AS UT
ORDER BY UT.RecordDate, UT.SystemCode
GO

/*
Last entry for each SystemCode
1      MEMORYCLERK_SQLSTORENG     2018-01-29 12:40:50.357    (1:554:14)
2      MEMORYCLERK_SQLSTORENG     2018-01-29 12:40:50.243    (1:556:9)
*/

-- Checking uniqueifiers on each page:
DBCC PAGE ('UNIQUIFIER', 1, 554, 3)
/*
-- Now maximum uniquifier value is:
Slot 14 Column 0 Offset 0x20b Length 4 Length (physical) 4
UNIQUIFIER = 29
Slot 14 Column 1 Offset 0x4 Length 4 Length (physical) 4
SystemCode = 1
*/

DBCC PAGE ('UNIQUIFIER', 1, 556, 3)
/*
-- Now maximum uniquifier value is:
Slot 9 Column 0 Offset 0x20b Length 4 Length (physical) 4
UNIQUIFIER = 24
Slot 9 Column 1 Offset 0x4 Length 4 Length (physical) 4
SystemCode = 2
*/</pre>
&nbsp;

To help identifying table candidates that are using uniqueifiers (heavily or not), you can leverage the following query:
<pre>SELECT OBJECT_NAME(I.object_id) AS ObjectName
, I.object_id
, I.name AS IndexName
, I.is_unique
, C.name AS ColumnName
, T.name AS TypeName
, C.max_length
, C.precision
, C.scale
, P.partition_id
, P.partition_number
, P.rows
FROM sys.indexes AS I
INNER JOIN sys.index_columns AS IC
ON I.index_id = IC.index_id
AND I.object_id = IC.object_id
INNER JOIN sys.columns AS C
ON IC.column_id = C.column_id
AND IC.object_id = C.object_id
INNER JOIN sys.types AS T
ON C.system_type_id = T.system_type_id
INNER JOIN sys.partitions AS P
ON P.object_id = I.object_id
AND P.index_id = I.index_id
WHERE I.is_unique = 0 AND I.index_id = 1
ORDER BY I.object_id, C.column_id DESC</pre>
&nbsp;

For a specific database it will list the non-unique cluster indexes ordered by number of rows descending, with columns and its types. So even not showing the number of repeated rows for each cluster value, it is a good starting point to check tables starting from the ones with more records, going thru all the objects with a similar design.

Without resetting the uniqueifier, sometimes you can reach its limit in a sliding window scenario, with fewer rows than the value limit of 2,147,483,648. For example: a table keep records for the past 10 days, with daily insert of 20 million records and deleting oldest 20 million, which will cause the uniqueifier to be constantly growing and reach its limit with only 200 million rows in the table (sample in script 03 for a general idea).

&nbsp;

<em>Script 03 – Sliding window scenario</em><em> </em>
<pre>USE UNIQUIFIER
GO

IF OBJECT_ID('dbo.UniqSliding') IS NOT NULL
  DROP TABLE dbo.UniqSliding
go

CREATE TABLE dbo.UniqSliding
(ID INT IDENTITY(1,1) NOT NULL
, IDNonUnique SMALLINT NOT NULL   DEFAULT (1)
, RecordDate DATETIME DEFAULT (SYSDATETIME()))
GO

CREATE CLUSTERED INDEX idxCL_NonUnique
ON dbo.UniqSliding (IDNonUnique)
GO

-- Use Itzik Ben-Gan GetNums function
-- Reference: https://tsql.solidq.com/SourceCodes/GetNums.txt
IF OBJECT_ID('dbo.GetNums') IS NOT NULL
  DROP FUNCTION dbo.GetNums;
GO

CREATE FUNCTION dbo.GetNums(@n AS BIGINT) RETURNS TABLE
AS
RETURN
WITH
L0   AS(SELECT 1 AS c UNION ALL SELECT 1),
L1   AS(SELECT 1 AS c FROM L0 AS A CROSS JOIN L0 AS B),
L2   AS(SELECT 1 AS c FROM L1 AS A CROSS JOIN L1 AS B),
L3   AS(SELECT 1 AS c FROM L2 AS A CROSS JOIN L2 AS B),
L4   AS(SELECT 1 AS c FROM L3 AS A CROSS JOIN L3 AS B),
L5   AS(SELECT 1 AS c FROM L4 AS A CROSS JOIN L4 AS B),
Nums AS(SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) AS n FROM L5)
SELECT n FROM Nums WHERE n &lt;= @n;
GO

INSERT INTO dbo.UniqSliding (IDNonUnique)
SELECT 1
FROM dbo.GetNums(20000);
go

INSERT INTO dbo.UniqSliding (IDNonUnique)
SELECT 1
FROM dbo.GetNums(20000);
DELETE TOP (20000)
FROM dbo.UniqSliding
GO 10

select count(*) from dbo.UniqSliding;
-- 20000 rows

-- Checking pages with latest records
SELECT TOP 10 *, sys.fn_physlocformatter(%%PHYSLOC%%)
FROM dbo.UniqSliding
ORDER BY ID DESC
GO

-- 220000     1      2018-01-29 13:51:40.623    (1:6916:237)

DBCC TRACEON (3604)
DBCC PAGE ('UNIQUIFIER', 1, 6916, 3)
-- Current UNIQUEIFIER value = 219999 for 20000 rows

/*
Slot 237 Column 0 Offset 0x19 Length 4 Length (physical) 4
UNIQUIFIER = 219999
Slot 237 Column 2 Offset 0x4 Length 2 Length (physical) 2
IDNonUnique = 1
Slot 237 Column 1 Offset 0x6 Length 4 Length (physical) 4
ID = 220000
*/</pre>
&nbsp;

The goal for this post is to give insight on how uniqueifier works and allow you to manually check for potential issues in your environment, avoiding error 666.

Hope you find this article interesting and helpful.

Best Regards,

&nbsp;

Luciano Caixeta Moreira - {Luti}

<a href="mailto:luticm79@hotmail.com">luticm79@hotmail.com</a>

<a href="https://www.linkedin.com/in/luticm">https://www.linkedin.com/in/luticm</a>

<a href="https://www.twitter.com/luticm">www.twitter.com/luticm</a>]]></content:encoded>
    </item>
    <item>
      <title>AUDIT does not respect the MAX_ROLLOVER_FILES configuration</title>
      <link>https://docs.microsoft.com/archive/blogs/luti/audit-does-not-respect-the-max_rollover_files-configuration</link>
      <pubDate>Tue, 25 Jul 2017 17:05:04 GMT</pubDate>
      <dc:creator><![CDATA[Luciano Moreira]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/luti/?p=1586</guid>
      <description><![CDATA[In one of the cases that I worked in the past months, customer reported that the SQL Server audit...]]></description>
      <content:encoded><![CDATA[In one of the cases that I worked in the past months, customer reported that the SQL Server audit mechanism wasn´t respecting the option MAX_ROLLOVER_FILES.
The context is:
<ol>
 	<li>Many SQL Server instances with had AUDIT configured, writing events to files locally.</li>
 	<li>A view was created in each instance to access the audit files and maintain a standard nomenclature.</li>
 	<li>A product from another company keeps reading all the data from those files to centralize them in another repository.</li>
 	<li>When querying the data the tool always specify a timestamp, filtering the data to get only new records since the last time it was executed.
<ol>
 	<li>E.g.: "SELECT * FROM dbo.vw_Audit WHERE event_time &gt; '2016-11-30 18:54:00'"
The issue here is that customer defined a maximum of 20 rollover files, but at some point they could find 50 or 100 files in the path, consuming all disk space.</li>
</ol>
</li>
</ol>
The issue here is that customer defined a maximum of 20 rollover files, but at some point they could find 50 or 100 files in the path, consuming all disk space.

To simulate the scenario and understand SQL behavior, I created a new database and using the following instructions (not the complete set), configured an audit.
<pre style="padding-left: 30px">CREATE SERVER AUDIT Reg3843
TO FILE
(FILEPATH = 'C:\Temp\Audit',
 MAXSIZE= 25MB,
  MAX_ROLLOVER_FILES = 5,
 RESERVE_DISK_SPACE = OFF)
WITH (ON_FAILURE = CONTINUE, QUEUE_DELAY = 1000)
GO

CREATE DATABASE AUDIT SPECIFICATION dbauditest
FOR SERVER AUDIT Reg3843
ADD (SELECT ON dbo.TabelaBase by public) 
GO

CREATE VIEW dbo.vw_Audit
as
    SELECT * 
    FROM sys.fn_get_audit_file('C:\temp\Audit\*',default,default)
GO</pre>
After generating some load to fill up audit files, I executed the query  "select * FROM dbo.vw_Audit WHERE event_time &gt; '2016-11-30 18:54:00' ", that is supposed only to access data in the last audit file.

Using PROCMON from SysInternals (<a target="_blank" href="https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx" rel="noopener noreferrer">https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx</a>) I was able to see that SQL Server open a handle for each audit file. It only read metadata for the first ones and when it comes to the last (which has the data related to the timestamp), actual content is read from the file, as you can see the offset changing (image 01). The interesting thing to notice here is that the handle for all the files is only released at the end, showed as CloseFile in image 02.
<p style="text-align: center"><a href="https://msdnshared.blob.core.windows.net/media/2017/07/AuditRollover_Image01.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/07/AuditRollover_Image01-1024x496.png" alt="" class="aligncenter wp-image-1605 size-large" width="1024" height="496" /></a>(Image 01)</p>
<p style="text-align: center"><a href="https://msdnshared.blob.core.windows.net/media/2017/07/AuditRollover_Image02.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/07/AuditRollover_Image02-1024x217.png" alt="" class="aligncenter wp-image-1596 size-large" width="1024" height="217" /></a>(Image 02)</p>
<p style="text-align: left;padding-left: 30px">For reference:</p>
<p style="text-align: left;padding-left: 60px">CreateFile (<a target="_blank" href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx" rel="noopener noreferrer">https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx</a>): The function returns a handle that can be used to access the file or device for various types of I/O depending on the file or device and the flags and attributes specified.
The file is actually closed when CloseHandle is invoked (<a target="_blank" href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms724211(v=vs.85).aspx" rel="noopener noreferrer">https://msdn.microsoft.com/en-us/library/windows/desktop/ms724211(v=vs.85).aspx</a>).</p>
<p style="text-align: left;padding-left: 30px">At this point we have a probable cause of the issue, so to simulate it you need to keep constantly querying the audit view, while adding a load to generate entries in the audit file. While this happens you can use PROCMON to capture data and observe the behavior.
In image 03 we can see thread 36612 writing data to the audit files (this is the thread that is recording the audit events). At some point it reaches end of file (due to 25 MB limit), faces a sharing violation when accessing existing files, and then creates a new audit file, continuing to write from offset 0.</p>
<p style="text-align: left;padding-left: 30px">On Image 04, I just filtered out the SUCCESS events and let threads 33612 and 25632, so you can see the concurrency aspect of it. 25632 is the one with open handles to all the files while is reading the data from the last audit file, and when 36612 try to access the file with "<span style="color: #ff0000">Desired Access: Generic Write, Read Attributes,</span> ...", the door is closed for this thread (sharing violation).</p>
<p style="padding-left: 30px;text-align: center"><a href="https://msdnshared.blob.core.windows.net/media/2017/07/AuditRollover_Image03.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/07/AuditRollover_Image03-1024x394.png" alt="" class="aligncenter wp-image-1607 size-large" width="1024" height="394" /></a>(Image 03)</p>
<p style="padding-left: 30px;text-align: center"><a href="https://msdnshared.blob.core.windows.net/media/2017/07/AuditRollover_Image04.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/07/AuditRollover_Image04-1024x431.png" alt="" class="alignnone wp-image-1606 size-large" width="1024" height="431" /></a>
(Image 04)</p>
<p style="padding-left: 30px;text-align: left">Reading the documentation (why not do it first?!) we can see the exact moments that SQL Server tries to delete the older files (<a target="_blank" href="https://msdn.microsoft.com/en-us/library/cc280448.aspx" rel="noopener noreferrer">https://msdn.microsoft.com/en-us/library/cc280448.aspx</a>):</p>
<p style="padding-left: 30px;text-align: left">    MAX_ROLLOVER_FILES ={ integer | UNLIMITED }
Specifies the maximum number of files to retain in the file system in addition to the current file. The MAX_ROLLOVER_FILES value must be an integer or UNLIMITED. The default value is UNLIMITED. T<span style="color: #ff0000">his parameter is evaluated whenever the audit restarts (which can happen when the instance of the Database Engine restarts or when the audit is turned off and then on again) or when a new file is needed because the MAXSIZE has been reached.</span> When MAX_ROLLOVER_FILES is evaluated, if the number of files exceeds the MAX_ROLLOVER_FILES setting, the oldest file is deleted. As a result, when the setting of MAX_ROLLOVER_FILES is 0 a new file is created each time the MAX_ROLLOVER_FILES setting is evaluated. Only one file is automatically deleted when MAX_ROLLOVER_FILES setting is evaluated, so when the value of MAX_ROLLOVER_FILES is decreased, the number of files will not shrink unless old files are manually deleted. The maximum number of files that can be specified is 2,147,483,647.</p>
<p style="padding-left: 30px;text-align: left">This clearly explains the behavior: when that thread receives a SHARING VIOLATION, it cannot delete the files that are beyond the MAX_ROLLOVER_FILES limit. But since this keeps happening all the time, due to the process querying audit files, it seems for the DBA that SQL Server is not respecting the configuration, which is not true.</p>
<p style="padding-left: 30px;text-align: left">As you should have anticipated by now, the suggested approach to avoid this issues is to query the file which holds the current timestamp, to avoid having open handles to files that are not necessary and just have old audit entries, something similar to the query below (if you use PROCMON, will see only this file being accessed):</p>

<pre style="padding-left: 60px;text-align: left">SELECT * FROM sys.fn_get_audit_file('C:\temp\Audit\Reg3843_7BE85D55-C73F-4C5A-8FAE-BC7F83B17E5C_0_131250056119510000.sqlaudit',default,default) WHERE event_time &gt; '2016-11-30 18:54:00'</pre>
<p style="padding-left: 30px;text-align: left">An important thing to notice is that this is not a product bug, since it does exactly what the documentation states and is intended by product group.</p>
<p style="padding-left: 30px;text-align: left">More important than this audit scenario, is that you should feel comfortable with a lot of tools (like the ones in SysInternals suite) when troubleshooting issues, that can help you to pinpoint the problem faster.</p>
<p style="padding-left: 30px;text-align: left">Luciano Caixeta Moreira -  [ Luti ]
<a href="mailto:luciano.moreira@srnimbus.com.br">luticm79@hotmail.com</a>
<a target="_blank" href="https://www.linkedin.com/in/luticm" rel="noopener noreferrer">https://www.linkedin.com/in/luticm </a>
<a href="https://www.twitter.com/luticm">www.twitter.com/luticm</a></p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server is using only one processor/CPU</title>
      <link>https://docs.microsoft.com/archive/blogs/luti/sql-server-is-using-only-one-processorcpu</link>
      <pubDate>Fri, 21 Jul 2017 19:10:54 GMT</pubDate>
      <dc:creator><![CDATA[Luciano Moreira]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/luti/?p=1565</guid>
      <description><![CDATA[Recently I have collaborated in some cases with the same symptom: customer reported that is using...]]></description>
      <content:encoded><![CDATA[Recently I have collaborated in some cases with the same symptom: customer reported that is using SQL Server and noticed that in the machine only one CPU hit 100% utilization, while the utilization of the other CPUs didn´t have a sustained usage of more than 10%.

The scenarios have the same characteristic: using a SQL Server Express in a virtualized environment.

DBAs should be thinking about affinity mask and hard binding behavior, but this is not the case here, and the explanation is much simpler than that: product limit.

If you check the documentation, for instance, Features Supported by the Editions of SQL Server 2014 (<a target="_blank" href="https://msdn.microsoft.com/en-us/library/cc645993(v=SQL.120).aspx" rel="noopener noreferrer">https://msdn.microsoft.com/en-us/library/cc645993(v=SQL.120).aspx</a>), you will notice:

Maximum Compute Capacity Used by a Single Instance (SQL Server Database Engine) -&gt; Express -&gt; <strong>Limited to lesser of 1 Socket or 4 cores</strong>

SQL Server express support up to 4 cores in the <strong>SAME</strong> socket, so the virtual machine definition matters a lot.

In the following image you can see that the virtual machine is being defined by having 12 sockets with a single core per socket, so a SQL Server Express in this machine would only use one core.

<a href="https://msdnshared.blob.core.windows.net/media/2017/07/VM_SocketCpu_Config.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/07/VM_SocketCpu_Config.png" alt="" class="aligncenter wp-image-1585 size-full" width="755" height="310" /></a>
This is really common for deployments that use SQL Server Express, like Skype for business (former Lync), that being smaller VMs, sometimes we don´t give proper attention to its configuration, as we would for a VM that would host SQL Server Enterprise.

A similar scenario can also happens for SQL Server Standard, but in this case using only 4 processors in a 16 socket virtual machine (Limited to lesser of 4 Sockets or 16 cores).

To avoid performance issues related to NUMA / vNUMA definition, our recommendation is to have the same virtual layout as the one defined in your physical processor architecture.

This scenario should be really straightforward to DBAs, but sometimes the organization doesn´t have a DBA involved when using SQL Server express, so hopefully this post can help someone.

Luciano Caixeta Moreira -  [ Luti ]
<a href="mailto:luciano.moreira@srnimbus.com.br">luticm79@hotmail.com</a>
<a target="_blank" href="https://www.linkedin.com/in/luticm" rel="noopener noreferrer">https://www.linkedin.com/in/luticm </a>
<a href="https://www.twitter.com/luticm">www.twitter.com/luticm</a>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server offline after applying service pack</title>
      <link>https://docs.microsoft.com/archive/blogs/luti/sql-server-offline-after-applying-service-pack</link>
      <pubDate>Wed, 17 May 2017 12:22:16 GMT</pubDate>
      <dc:creator><![CDATA[Luciano Moreira]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/luti/?p=1537</guid>
      <description><![CDATA[In this post I´ll review two cases that you may bump into when applying service packs in SQL...]]></description>
      <content:encoded><![CDATA[In this post I´ll review two cases that you may bump into when applying service packs in SQL Server.

<strong>Case 1</strong>

You need to install a SQL Server service pack, so you plan, test and got everything ready to apply it in production. You run the installation executable and it finishes successfully. Almost there... when SQL Server service starts it suddenly became offline... What happened? With fingers crossed you try again, same thing.

The next logical step is to check logs, so you find something similar to:
<pre> 2017-03-21 22:29:04.18 spid6s Database 'master' is upgrading script 'sqlagent100_msdb_upgrade.sql' from level 0 to level 2.
 2017-03-21 22:29:04.18 spid6s ----------------------------------------
 2017-03-21 22:29:04.18 spid6s Starting execution of PREINSTMSDB100.SQL
 2017-03-21 22:29:04.18 spid6s ----------------------------------------
 2017-03-21 22:29:04.23 spid6s Error: 15002, Severity: 16, State: 1.
 2017-03-21 22:29:04.23 spid6s <span style="color: #ff0000"><strong>The procedure 'sys.sp_dbcmptlevel' cannot be executed within a transaction.</strong></span>
 2017-03-21 22:29:04.25 spid6s Configuration option 'allow updates' changed from 0 to 1. Run the RECONFIGURE statement to install.
 2017-03-21 22:29:04.25 spid6s Configuration option 'allow updates' changed from 0 to 1. Run the RECONFIGURE statement to install.
 2017-03-21 22:29:04.25 spid6s Error: 574, Severity: 16, State: 0.
 2017-03-21 22:29:04.25 spid6s CONFIG statement cannot be used inside a user transaction.
 2017-03-21 22:29:04.25 spid6s Error: 912, Severity: 21, State: 2.
 2017-03-21 22:29:04.25 spid6s Script level upgrade for database 'master' failed because upgrade step 'sqlagent100_msdb_upgrade.sql' encountered error 574, state 0, severity 16. This is a serious error condition which might interfere with regular operation and the database will be taken offline. If the error happened during upgrade of the 'master' database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion.
 2017-03-21 22:29:04.25 spid6s Error: 3417, Severity: 21, State: 3.
 2017-03-21 22:29:04.25 spid6s Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. For more information about how to rebuild the master database, see SQL Server Books Online.
 2017-03-21 22:29:04.25 spid6s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.</pre>
What transaction? I don´t know the details about scripts executed by the service pack!
Even if you enable other trace flags trying to check what script is doing, it will give little clue in this case.

Then you recall of a nice instance configuration called "implicit transactions". Check/change this configuration seems a good action plan, but how to do it if the instance is offline?

One approach is to use trace flag 902 to bypass execution of database upgrade script when installing a Cumulative Update or Service Pack, so you can have a chance to check configuration and makes changes to instance.

&nbsp;

Please read careful the documentation with info about TF 902: <a target="_blank" href="https://msdn.microsoft.com/en-US/library/ms188396.aspx">https://msdn.microsoft.com/en-US/library/ms188396.aspx</a>

<em>"Bypasses execution of database upgrade script when installing a Cumulative Update or Service Pack. If you encounter an error during script upgrade mode, it is recommended to contact Microsoft SQL Customer Service and Support (CSS) for further guidance. For more information, see this Microsoft Support article.</em>

<em>WARNING: This trace flag is meant for troubleshooting of failed updates during script upgrade mode, and it is not supported to run it continuously in a production environment. Database upgrade scripts needs to execute successfully for a complete install of Cumulative Updates and Service Packs. Not doing so can cause unexpected issues with your SQL Server instance."</em>

&nbsp;

OK? So let's continue...

Checking the instance properties you can see that default connection options has implicit transactions set. You disable the option and now need to verify if this was the culprit of the problem. Then you need to REMOVE trace flag 902, so upgrade scripts can run, restart SQL Server instance and check the outcome of it.

<a href="https://msdnshared.blob.core.windows.net/media/2017/05/TF902_01.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/05/TF902_01-300x159.png" alt="tf902_01" class=" wp-image-1555 aligncenter" width="342" height="181" /></a>

Congratulations! Now all the scripts were successfully executed and your instance has the patch applied, so you can reconfigure "implicit transactions" if this is what you desire for you instance.

<strong>Case 2
</strong>

Following a similar line of troubleshooting, suppose you are applying another patch, the setup wizard goes successfully and when the instance starts, it goes offline. Checking ERRORLOG now you see:
<pre><strong> 2017-03-22 17:48:51.06 spid5s Error: 9002, Severity: 17, State: 4.</strong>
<strong> 2017-03-22 17:48:51.06 spid5s <span style="color: #ff0000">The transaction log for database 'tempdb' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases</span></strong>
<strong> 2017-03-22 17:48:52.08 spid5s Error: 912, Severity: 21, State: 2.</strong>
<strong> 2017-03-22 17:48:52.08 spid5s <span style="color: #ff0000">Script level upgrade for database 'master' failed because upgrade step 'sqlagent100_msdb_upgrade.sql' encountered error 9002, state 4, severity 17.</span></strong><span style="color: #ff0000"> This is a serious error condition which might interfere with regular operation and the database will be taken offline. If the error happened during upgrade of the 'master' database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion.</span>
 2017-03-22 17:48:52.08 spid5s Error: 3417, Severity: 21, State: 3.
 2017-03-22 17:48:52.08 spid5s Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. For more information about how to rebuild the master database, see SQL Server Books Online.
 2017-03-22 17:48:52.08 spid5s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.</pre>
Alright, now TempDB transaction log is full, so you double check the files and see that it has only 512 KB, the same size of modellog.mdf (what a coincidence!). But why didn´t the transaction log didn´t grow? Maybe someone wanted to guaranteed that all the data files keep with the same size and by mistake disabled transaction log auto growth, so when SQL Server resized the file following model database, it does not have room to even process the upgrade scripts.

<a href="https://msdnshared.blob.core.windows.net/media/2017/05/TF902_02.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/05/TF902_02-300x108.png" alt="tf902_02" class=" wp-image-1545 aligncenter" width="420" height="151" /></a>

Trace flag 902 again! Add it, start SQL Server instance, reconfigure TempDB transaction log to growth, stop instance, remove TF 902 and restart SQL Server instance again and... great! Everything is up and running.

<strong>Conclusion</strong>

Above I provided some examples involving issues with upgrade scripts and key messages are:
<ol>
 	<li>ALWAYS check what is going on using SQL Server ERRORLOG
a. Without any error information, how will you troubleshoot the issue</li>
 	<li>When dealing with upgrade scripts issues, trace flag 902 can be your friend.
a. Remember the docs and know what are you doing: <a href="https://msdn.microsoft.com/en-US/library/ms188396.aspx">https://msdn.microsoft.com/en-US/library/ms188396.aspx</a></li>
 	<li>Test you upgrade process in other environments, production SQL Server is not a great place to be the first time you apply a patch or will be using a different trace flag.</li>
</ol>
More than the issues per se, I hope this will help you to think clearly when facing an issue and consider your troubleshooting steps, that may be the difference between solving it or not.

Luciano Caixeta Moreira -  [ Luti ]
<a href="mailto:luciano.moreira@srnimbus.com.br">luticm79@hotmail.com</a>
<a target="_blank" href="https://www.linkedin.com/in/luticm">https://www.linkedin.com/in/luticm </a>
<a href="https://www.twitter.com/luticm">www.twitter.com/luticm</a>]]></content:encoded>
    </item>
    <item>
      <title>LUTI @ Microsoft - Blogging again...</title>
      <link>https://docs.microsoft.com/archive/blogs/luti/luti-microsoft-blogging-again</link>
      <pubDate>Wed, 01 Mar 2017 19:22:40 GMT</pubDate>
      <dc:creator><![CDATA[Luciano Moreira]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/luti/?p=1535</guid>
      <description><![CDATA[==================================== EN-US ====================================
Since March 2009...]]></description>
      <content:encoded><![CDATA[<p style="margin: 0in;font-family: Calibri;font-size: 11.0pt">==================================== EN-US ====================================</p><br />
<p style="margin: 0in;font-family: Calibri;font-size: 11.0pt">Since March 2009 this blog was inactive due to the fact that I decided to leave the company back then. Situation that changed last year, when I accepted the challenge of a new position at Microsoft, starting on August 2016 as a Senior Support Engineer for the Data Platform/BI team in Latin America (LATAM).</p>
<p style="margin: 0in;font-family: Calibri;font-size: 11.0pt">The last few months have been busy, first learning about the new role, processes and adapting again to work for Microsoft. But besides continually learning from the job, I also want to share a little bit about the technology that I work daily, so hopefully this can be useful to you someday.</p>
<p style="margin: 0in;font-family: Calibri;font-size: 11.0pt">I really don´t know if I will continue to write in English, Portuguese or it will be a mix, but surely I´ll discover it along the way.</p>
<p style="margin: 0in;font-family: Calibri;font-size: 11.0pt">Hope you like it and help me to continue improve the content published here.</p><br />
<p style="margin: 0in;font-family: Calibri;font-size: 11.0pt">==================================== PT-BR ====================================</p><br />
<p style="margin: 0in;font-family: Calibri;font-size: 11.0pt" lang="pt-BR">Desde março de 2009 este blog estava inativo devido ao fato de que eu decidi deixar a empresa na época. Situação que mudou no ano passado, quando aceitei o desafio uma nova posição na Microsoft, começando em agosto de 2016 como um Senior Support Engineer para o time Data Platform/BI - Latin America (LATAM).</p>
<p style="margin: 0in;font-family: Calibri;font-size: 11.0pt" lang="pt-BR">Os últimos meses tem sido corrido, primeiro aprendendo sobre o novo papel, processos e me adaptando novamente a trabalhar para a Microsoft. Porém além de continuar aprendendo continuamente com o trabalho, eu também quero tentar compartilhar um pouco sobre a tecnologia que trabalho diariamente, que esperançosamente será útil para alguém no futuro.</p>
<p style="margin: 0in;font-family: Calibri;font-size: 11.0pt" lang="pt-BR">Eu ainda não sei se vou continuar a escrever em inglês, português ou um misto, mas com certeza vou encontrar a melhor abordagem pelo caminho.</p>
<p style="margin: 0in;font-family: Calibri;font-size: 11.0pt" lang="pt-BR">Espero que você goste e me ajude a continuar melhorando o conteúdo publicado aqui.</p>]]></content:encoded>
    </item>
    <item>
      <title>Contatos e novo domínio</title>
      <link>https://docs.microsoft.com/archive/blogs/luti/contatos-e-novo-domnio</link>
      <pubDate>Fri, 20 Mar 2009 14:01:05 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/luti/2009/03/20/contatos-e-novo-domnio/</guid>
      <description><![CDATA[Oi pessoal, conforme dito no post anterior, hoje é meu último dia na Microsoft. Espero que vocês...]]></description>
      <content:encoded><![CDATA[<p>Oi pessoal, conforme dito no post anterior, hoje é meu último dia na Microsoft. Espero que vocês tenham gostado do conteúdo que foi disponibilizado aqui e que o meu próximo blog também atenda a expectativa de vocês.</p>  <p>Já estou com o domínio devidamente registrado, mas ainda estou criando o conteúdo que será publicado na semana que vêm. Com relação ao blog, estou decidindo qual ferramenta vou utilizar (estou analisando o WordPress e Blogger, sugestões?) e publicarei o endereço no meu site.</p>  <p>Fica aqui meus contatos:</p>  <p>E-mail: <a href="mailto:luticm79@hotmail.com">luticm79@hotmail.com</a></p>  <p>Skype: luticm</p>  <p>Twiiter: luticm</p>  <p>URL: <a href="https://www.lucianomoreira.com">https://www.lucianomoreira.com</a></p>  <p>&#160;</p>  <p>Até o próximo post…</p>  <p>[]s    <br />Luciano Caixeta Moreira     <br /><a href="mailto:luciano.moreira@microsoft.com">luciano.moreira@microsoft.com</a>     <br />===============================================     <br />This post is provided &quot;AS IS&quot; and confers no right     <br />===============================================</p>]]></content:encoded>
    </item>
    <item>
      <title>Notícia quente! Últimos dias de atividade neste blog…</title>
      <link>https://docs.microsoft.com/archive/blogs/luti/notcia-quente-ltimos-dias-de-atividade-neste-blog</link>
      <pubDate>Wed, 18 Mar 2009 18:44:45 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/luti/2009/03/18/notcia-quente-ltimos-dias-de-atividade-neste-blog/</guid>
      <description><![CDATA[Olá queridos leitores deste blog. Esse post é mais um que chega sem aviso prévio e muda um pouco as...]]></description>
      <content:encoded><![CDATA[<p>Olá queridos leitores deste blog. Esse post é mais um que chega sem aviso prévio e muda um pouco as regras do jogo…</p>  <p>A próxima sexta-feira marca o meu último dia de trabalho na Microsoft Brasil. Depois de mais de três anos trabalhando nessa empresa fantástica, decidi que era hora de seguir algumas de minhas aspirações de carreira e partir para outras frentes de trabalho.</p>  <p>Me desligar da Microsoft não foi uma escolha fácil, muito pelo contrário, a idéia vem me acompanhando durante alguns meses de muita reflexão e análise. A empresa sempre me ofereceu excelentes condições de trabalho, grandes desafios e bons amigos, algo difícil de se encontrar em muitas outras empresas.</p>  <p>Se por um lado fica um grande pesar, por outro fica renovada as ambições e metas deste que vos escreve. Mudanças sempre dão aquele friozinho na barriga, mas pode ser que o resultado seja espetacular.</p>  <p>O que esse post significa para você que está acostumado a gastar alguns minutos do seu dia comigo? Não falarei mais sobre SQL Server? Não continuarei colaborando com a comunidade? Longe disso… Trabalhar com a comunidade, blogar e, claro, brincar com o SQL Server e .NET, está no meu sangue e continuarei a fazer tudo isso, como já fazia antes de entrar na MS. O que irá mudar é meu e-mail e url do blog, mas o Luti continuará sendo o mesmo.</p>  <p>E que diabos eu vou fazer da vida?</p>  <p>Parte da minha agenda estará voltada para um novo projeto, onde trabalharei de perto com a computação na nuvem (o Azure está na lista, claro!) e com a outra parte do meu tempo estarei conduzindo consultorias e treinamentos, focados em SQL Server e .NET. Além disso, continuarei com as colaborações para o MSDN/TechNet, artigos em revistas, reuniões técnicas e o que mais aparecer.</p>  <p>Se você quiser entrar em contato, fique à vontade para utilizar o e-mail: <a href="mailto:luticm79@hotmail.com">luticm79@hotmail.com</a>. Até sexta-feira eu publico o endereço do meu novo blog e mais informações, pois a saga continua.</p>  <p>Espero que nosso caminhos continuem sempre se cruzando, seja através do meu próximo blog, uma eventual consultoria, treinamento ou evento.</p>  <p>Sentirei saudades deste blog…</p>  <p>[]s    <br />Luciano Caixeta Moreira     <br /><a href="mailto:luciano.moreira@microsoft.com">luciano.moreira@microsoft.com</a>     <br />===============================================     <br />This post is provided &quot;AS IS&quot; and confers no right     <br />===============================================</p>]]></content:encoded>
    </item>
    <item>
      <title>Webcast amanhã! SQL Server x cenários de aplicação</title>
      <link>https://docs.microsoft.com/archive/blogs/luti/webcast-amanh-sql-server-x-cenrios-de-aplicao</link>
      <pubDate>Tue, 17 Mar 2009 08:51:43 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/luti/2009/03/17/webcast-amanh-sql-server-x-cenrios-de-aplicao/</guid>
      <description><![CDATA[Oi pessoal, amanhã eu estou de volta com mais um webcast, onde vou tentar tirar algumas dúvidas com...]]></description>
      <content:encoded><![CDATA[<p>Oi pessoal, amanhã eu estou de volta com mais um webcast, onde vou tentar tirar algumas dúvidas com relação ao SQL Server, suas edições e cenários de aplicação. Minha proposta é discutir como podemos usar os diversos recursos do SQL Server de acordo com tipos específicos de aplicações, minimizando o custo para você e sua empresa. </p>  <p>Após a primeira parte teórica, vamos abrir a sessão para um painel de perguntas e respostas, onde quero ouvir de vocês dúvidas sobre como montar/planejar sua aplicação, questionamentos sobre o SQL Server e como podemos tirar o máximo do produto. </p>  <p>Gostou da idéia? Ficou com vontade de discutir sobre o assunto?</p>  <p>Então tire alguns minutos do seu dia e participe! </p>  <p>&#160;</p>  <p><a href="https://www112.livemeeting.com/cc/_XML/microsoft/join?id=S2P4BM&amp;role=attend">MSDN Webcast: Saiba qual edição do SQL Server escolher para cada cenário de aplicação</a>     <br />URL: <a title="https://www112.livemeeting.com/cc/_XML/microsoft/join?id=S2P4BM&amp;role=attend" href="https://www112.livemeeting.com/cc/_XML/microsoft/join?id=S2P4BM&amp;role=attend">https://www112.livemeeting.com/cc/_XML/microsoft/join?id=S2P4BM&amp;role=attend</a>     <br />Neste Webcast, serão apresentado diversos cenários comuns de aplicações e analisado qual edição do SQL Server melhor se encaixa no seu projeto e bolso. Após a primeira parte, será aberto um painel para debate sobre o assunto em questão.     <br /><b>Início: 18/3/2009 12:00:00 (Brasília)      <br />Duração: 60 minutos</b>     <br />- Luciano Moreira</p>  <p>   <br />[]s     <br />Luciano Caixeta Moreira     <br /><a href="mailto:luciano.moreira@microsoft.com">luciano.moreira@microsoft.com</a>     <br />===============================================     <br />This post is provided &quot;AS IS&quot; and confers no right     <br />===============================================</p>]]></content:encoded>
    </item>
    <item>
      <title>ADO.NET Data Services V1.5 – CTP1 está próximo…</title>
      <link>https://docs.microsoft.com/archive/blogs/luti/ado-net-data-services-v1-5-ctp1-est-prximo</link>
      <pubDate>Mon, 02 Mar 2009 14:02:15 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/luti/2009/03/02/ado-net-data-services-v1-5-ctp1-est-prximo/</guid>
      <description><![CDATA[Ontem foi anunciado que o CTP1 do ADO.NET Data Services v1.5 (antes conhecido como Astoria) está a...]]></description>
      <content:encoded><![CDATA[<p>Ontem foi anunciado que o CTP1 do ADO.NET Data Services v1.5 (antes conhecido como Astoria) está a caminho! Isso é uma uma ótima notícia, pois muito se tem falado sobre soluções com arquitetura REST, onde o ADO.NET Data Services se encaixa como uma luva, expondo serviços de dados que podem ser consumidos facilmente por diversos clientes, escrito por exemplo, em WPF ou Silverlight.</p>  <p>Também temos discutido isto recentemente dentro da Microsoft, sendo uma abordagem interessante para desenvolvimento rápido de soluções leves, onde não precisamos de todos os recursos (e alguns overheads) trazidos pelo SOAP.</p>  <p>Para entender melhor sobre o assunto, recomendo:</p>  <p>- Anúncio oficial: <a title="https://blogs.msdn.com/astoriateam/archive/2009/03/01/announcing-ado-net-data-services-v1-5-ctp1.aspx" href="https://blogs.msdn.com/astoriateam/archive/2009/03/01/announcing-ado-net-data-services-v1-5-ctp1.aspx">https://blogs.msdn.com/astoriateam/archive/2009/03/01/announcing-ado-net-data-services-v1-5-ctp1.aspx</a>     <br />- Post do Otavio sobre RESTFul: <a title="https://blogs.msdn.com/otavio/archive/2009/02/24/restful-or-not-restful.aspx" href="https://blogs.msdn.com/otavio/archive/2009/02/24/restful-or-not-restful.aspx">https://blogs.msdn.com/otavio/archive/2009/02/24/restful-or-not-restful.aspx</a>     <br />- Dev center do ADO.NET Data Services: <a title="https://msdn.microsoft.com/pt-br/data/bb931106(en-us).aspx" href="https://msdn.microsoft.com/pt-br/data/bb931106(en-us).aspx">https://msdn.microsoft.com/pt-br/data/bb931106(en-us).aspx</a>     <br />- Webcasts:     <br />&#160;&#160;&#160;&#160;&#160; ADO.NET Data Services (Astoria) - <a title="https://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=pt-BR&amp;EventID=1032382239&amp;CountryCode=BR" href="https://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=pt-BR&amp;EventID=1032382239&amp;CountryCode=BR">https://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=pt-BR&amp;EventID=1032382239&amp;CountryCode=BR</a>     <br />&#160;&#160;&#160;&#160;&#160; Integrando ASP.NET Ajax com o ADO.NET Data Services - <a title="https://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=pt-BR&amp;EventID=1032403816&amp;CountryCode=BR" href="https://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=pt-BR&amp;EventID=1032403816&amp;CountryCode=BR">https://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=pt-BR&amp;EventID=1032403816&amp;CountryCode=BR</a></p>  <p>Agora vamos torcer para que o CTP1 fique disponível logo!</p>  <p>[]s    <br />Luciano Caixeta Moreira     <br /><a href="mailto:luciano.moreira@microsoft.com">luciano.moreira@microsoft.com</a>     <br />===============================================     <br />This post is provided &quot;AS IS&quot; and confers no right     <br />===============================================    </p>]]></content:encoded>
    </item>
    <item>
      <title>Configurando o BD do Development Storage – Azure SDK</title>
      <link>https://docs.microsoft.com/archive/blogs/luti/configurando-o-bd-do-development-storage-azure-sdk</link>
      <pubDate>Thu, 26 Feb 2009 09:21:54 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/luti/2009/02/26/configurando-o-bd-do-development-storage-azure-sdk/</guid>
      <description><![CDATA[Vamos brincar um pouco com o Azure?  Depois que você instala o SDK do Azure...]]></description>
      <content:encoded><![CDATA[<p>Vamos brincar um pouco com o Azure?</p>  <p>Depois que você instala o SDK do Azure (<a title="https://www.microsoft.com/downloads/details.aspx?FamilyID=80e3eabf-0507-4560-aeb6-d31e9a70a0a6&amp;displaylang=en" href="https://www.microsoft.com/downloads/details.aspx?FamilyID=80e3eabf-0507-4560-aeb6-d31e9a70a0a6&amp;displaylang=en">https://www.microsoft.com/downloads/details.aspx?FamilyID=80e3eabf-0507-4560-aeb6-d31e9a70a0a6&amp;displaylang=en</a>) pode disparar o processo do Development Storage, responsável por simular os diferentes modelos de armazenamento existentes na fundação do Azure (blobs, queues e tables). Mas se você não leu a documentação antes de disparar o processo, pode ser que você veja o seguinte erro:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/luti/WindowsLiveWriter/Azure_9C9D/DevStorage%20error.png" original-url="https://blogs.msdn.com/blogfiles/luti/WindowsLiveWriter/Azure_9C9D/DevStorage%20error.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="DevStorage error" border="0" alt="DevStorage error" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/luti/WindowsLiveWriter/Azure_9C9D/DevStorage%20error_thumb.png" original-url="https://blogs.msdn.com/blogfiles/luti/WindowsLiveWriter/Azure_9C9D/DevStorage%20error_thumb.png" width="514" height="178" /></a>&#160;</p>  <p>Explico: por padrão o processo do Development Storage vai tentar criar o banco de dados com a estrutura necessária para fazer os três tipos de armazenamento em uma instância nomeada do SQL Server Express, a “<em>localhost\SQLExpress</em>”. </p>  <p>Mas e se você não possui essa instância do SQL Server Express configurada ou quer usar uma outra instância já instalada, seja ela express ou não? A documentação oficial não nos entrega nenhum “how-to”, então resolvi fazer alguns testes e descrevo aqui o resultado.</p>  <p>   <br /><strong><u>Alterando a configuração do Development Storage</u></strong>&#160;</p>  <p>Partindo do pressuposto que a instância do SQL Server (2005 ou 2008) está instalada, primeiramente vamos disparar o “Windows Azure SDK Command Prompt”.<em> Nota:</em> para este e os próximos passos, eu estou executando-os com elevação de privilégio (run as administrator), por falta de pesquisa para definição das permissões necessárias. Sabe quais são? Deixe um comentário…</p>  <p>Através da documentação vejo que existe o comando DSInit (Development Storage Init), que é bem sugestivo, então executo o comando “DSInit /Server: &lt;instância&gt;” no <em>command prompt </em>aberto, onde “&lt;instância&gt;” é o nome da sua instância, ok? Aqui está o resultado:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/luti/WindowsLiveWriter/Azure_9C9D/DSInit.png" original-url="https://blogs.msdn.com/blogfiles/luti/WindowsLiveWriter/Azure_9C9D/DSInit.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="DSInit" border="0" alt="DSInit" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/luti/WindowsLiveWriter/Azure_9C9D/DSInit_thumb.png" original-url="https://blogs.msdn.com/blogfiles/luti/WindowsLiveWriter/Azure_9C9D/DSInit_thumb.png" width="637" height="419" /></a> </p>  <p>&#160;</p>  <p>Nota: O DSInit é chamado automaticamente quando o Development Storage é iniciado, caso não exista um ambiente já configurado, então você não precisaria fazer esse passo manualmente (a documentação até recomenda não fazer), mas eu preferi fazer tudo passo a passo para entender melhor. :-)</p>  <p>É visível na figura acima que o usuário responsável por executar o DSInit precisa ter acesso ao SQL Server e as permissões necessárias para criar um banco de dados. Usando o Management Studio é possível ver a estrutura criada (abaixo).</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/luti/WindowsLiveWriter/Azure_9C9D/DevStorageDB.png" original-url="https://blogs.msdn.com/blogfiles/luti/WindowsLiveWriter/Azure_9C9D/DevStorageDB.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="DevStorageDB" border="0" alt="DevStorageDB" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/luti/WindowsLiveWriter/Azure_9C9D/DevStorageDB_thumb.png" original-url="https://blogs.msdn.com/blogfiles/luti/WindowsLiveWriter/Azure_9C9D/DevStorageDB_thumb.png" width="353" height="305" /></a> </p>  <p>Uma vez criado o banco de dados DevelopmentStorageDb eu inicializei o processo do DevStorage e recebi o mesmo erro da primeira figura, indicando que não existe o banco de dados “<em>.\SQLExpress</em>”, então ainda é preciso configurar mais alguma coisa.</p>  <p>Navegue até o diretório <em>bin</em> no caminho de instalação do SDK (“<em>C:\Program Files\Windows Azure SDK\v1.0\bin</em>”, por padrão) e faça uma cópia de segurança do arquivo “<em>DevelopmentStorage.exe.config</em>”. Depois abra o arquivo para editá-lo, configurando o servidor a ser utilizado. Nota: por restrições de segurança, talvez seja melhor copiá-lo para outro local, alterá-lo e depois substituir o arquivo original.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/luti/WindowsLiveWriter/Azure_9C9D/DevStorage%20config.png" original-url="https://blogs.msdn.com/blogfiles/luti/WindowsLiveWriter/Azure_9C9D/DevStorage%20config.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="DevStorage config" border="0" alt="DevStorage config" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/luti/WindowsLiveWriter/Azure_9C9D/DevStorage%20config_thumb.png" original-url="https://blogs.msdn.com/blogfiles/luti/WindowsLiveWriter/Azure_9C9D/DevStorage%20config_thumb.png" width="800" height="312" /></a> </p>  <p>Eu editei o arquivo nos dois lugares marcados em amarelo, substituindo-os pelo nome da instância utilizada. Fiz isso porque além do development storage eu também quero colocar os bancos/tabelas criadas no mesmo servidor SQL Server.</p>  <p>Feito isso você pode disparar o processo do Development Storage e notar que ele será executando sem problema, conforme figura abaixo.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/luti/WindowsLiveWriter/Azure_9C9D/image_2.png" original-url="https://blogs.msdn.com/blogfiles/luti/WindowsLiveWriter/Azure_9C9D/image_2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/luti/WindowsLiveWriter/Azure_9C9D/image_thumb.png" original-url="https://blogs.msdn.com/blogfiles/luti/WindowsLiveWriter/Azure_9C9D/image_thumb.png" width="648" height="213" /></a> </p>  <p>Pronto, se você chegou até aqui está com o Development Storage apontando para a instância do SQL Server que você escolheu!    <br /></p>  <p><strong><u>Configurando os exemplos</u></strong></p>  <p>Junto com o SDK do Azure também estão disponíveis uma série de exemplos para você se divertir, sendo necessário usar o “rundevstore.cmd” para fazer o build dos projetos e configurar o development storage com a estrutura das tabelas utilizadas por um dos exemplos.</p>  <p>Quando executei o cmd diretamente, o processo estava indo bem até aparecer um problema relacionado com o acesso ao SQL Server. Dei uma olhada nos arquivos existentes e editei o arquivo “<em>MSBuild\Microsoft.Samples.ServiceHosting.targets</em>”, adicionando o “<em>/Server:&lt;instância&gt;</em>” no local marcado em amarelo (abaixo).</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/luti/WindowsLiveWriter/Azure_9C9D/SamplesConfig.png" original-url="https://blogs.msdn.com/blogfiles/luti/WindowsLiveWriter/Azure_9C9D/SamplesConfig.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="SamplesConfig" border="0" alt="SamplesConfig" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/luti/WindowsLiveWriter/Azure_9C9D/SamplesConfig_thumb.png" original-url="https://blogs.msdn.com/blogfiles/luti/WindowsLiveWriter/Azure_9C9D/SamplesConfig_thumb.png" width="684" height="106" /></a></p>  <p>Depois disso o processo de montagem dos exemplos foi executado com sucesso.</p>  <p>   <br />Que venha toda a plataforma Azure…    <br /></p>  <p>[]s    <br />Luciano Caixeta Moreira     <br /><a href="mailto:luciano.moreira@microsoft.com">luciano.moreira@microsoft.com</a>     <br />===============================================     <br />This post is provided &quot;AS IS&quot; and confers no right     <br />===============================================</p>]]></content:encoded>
    </item>
  </channel>
</rss>