en-UShe-IL
You are here:   Blog
Register   |  Login

Blog Archive:

Maximize
* Can be used in order to search for older blogs Entries

Search in blogs


Blog Categories:

Maximize
* Can be used in order to search for blogs Entries by Categories

Blog Tags:

Maximize
* Can be used in order to search for blogs by keywords

TNWikiSummit


Awared MVP 


 


Microsoft® Community Contributor 


Microsoft® Community Contributor


 Read first, before you you use the blog! Maximize

Recent Entries

By ronen ariely on 13/10/2019 10:00

This post includes two simple demo code to demonstrate (1) how order of columns can impact the size of the table and the database, and (2) That order of columns can be related to errors in the execution.

By ronen ariely on 13/10/2019 09:56

Understanding what we have under the hood is not only done for the sake of learning a theory, but it directly impacts your daily work, and it can help us to improve performance and reduce resources dramatically.

During this session we will go over the structure of tables behind the scenes. We will see the changes behind the scenes related to DDL actions which we execute on tables.

Using this information, I will demonstrate several real case scenarios, and the dramatic impact of understanding the internals on choosing our solution.

Is the order of columns important? Is dropping a column the right solution? Questions like those are very common in the forums and usually does not get the right answers. The answers might be a game changer in production environment

This session is a live demo!

By ronen ariely on 29/09/2019 07:36

OPENJSON is a build-in SQL Server table-valued function (return tabular structure), which parse text that formatted as JSON. By default, the function only parse the first level of the JSON document, but using explicit path to the nodes in the document we can parse the entire document including unlimited level of hierarchy. This sound great except the fact that JSON document is commonly used for unstructured data, meaning we do not know what nodes the document will have and what is the the path to each node... OPENJSON does not provide a dynamic parsing for hierarchy structure.

In this blog, I will present a simple recursive table-valued function, which based on OPENJSON and provide full dynamic hierarchy parsing of JSON document.


By ronen ariely on 07/08/2019 04:38
This post includes sample code for step by step: (1) create database. (2) CREATE TABLE. (3) create folder for the Audit logs. (4) CREATE SERVER AUDIT. (5) CREATE SERVER AUDIT SPECIFICATION. (6) CREATE DATABASE AUDIT SPECIFICATION. (7) Read the log file.
By ronen ariely on 17/07/2019 02:45
According to the documentation if you want to Access the error log files on Linux then you can convert the files to UTF-8. There is only one issue... The files are already written in UTF-8 encoding and not like in windows in UTF-16, which mean that this paragraph is really confusing...
By ronen ariely on 03/07/2019 02:28

Well, I don't know if you noticed but in the last year or so, blogs on the MSDN and TechNet system were closed or become "read-only". Unfortunately, this includes two of the blogs where I serve as co-administrator (wikininjas and forumninjas) which are in the same situation, but today I do not want to focus on these. In this post I want to focus only on the blogs where the Microsoft Data Platform teams write. The problem is that by closing the blogs on MSDN/TechNet blogs it seems like the blogs of the SQL Server teams has dispersed, and today each person or each group publishes his blog elsewhere in a different interface. It is almost impossible to follow all the blogs this way... I hope this list can be useful to you.

By ronen ariely on 26/06/2019 20:13

The official announcement of the release of SQL Server 2019 community technology preview 3.1 was published several minutes ago! Be the second to download the new version 😃

By ronen ariely on 21/06/2019 09:49

Error: The UTC time represented when the offset is applied must be between year 0 and 10,000.

A question in the MSDN forum about an error message which the user get, turned out to be an unknown (until now) bug in the SQL Server Management Studio SSMS (relevant to SSMS 18.1 and before). 

If you are in Israel then you are probably fine😃, in fact anyone who use UTC/GMT Time Zone or positive offset in time (Meaning, location east to Greenwich England) is fine... But if you are in US for example, then you must know about this

Read more...

By ronen ariely on 30/03/2019 23:59

We have a SET of separated slots/ranges and we want to represent the merged ranges which cover all the separated ranges, using a SET of minimum number of ranges. In other words, we want to to Group continuous and overlaps Ranges together. If we have SET of slots/ranges, and two or more of these ranges has shared point/s (a point which exists in both ranges), then these ranges can be merge together into a single range. 

For example if we are dealing with ranges of integers and we have the ranges 3-6 and 5-8, then we can marge these into the single range 3-8, or the ranges 2-4,4-6 can be merged into 2-6.

In my previous post I covered the solution using the "Gaps and Islands" approach. In this post I will cover a solution which is based on SQL Server built-in GEOMETRY data type.

By ronen ariely on 25/03/2019 13:19

Note! This post is draft, which I post fast as answer to question which asked at stackoverflow. Since I don't have time this week to prepare a well formatted post with images, full explanation, and well formatted text, but at the same time I want to provide a solution for the sake of these who asked for it, therefore I publish this as a first draft and provide the code for one of two solutions I will discuss.

Note! The solution which presented here is not the one which I recommend to use in this case. This solution address the question using a well known approach named "Gaps and Islands" and might fit for most cases. In my next post I will present a totally different approach using my personal trick, which can improve performance dramatically in some scenario.

So what do we have here? The post include code and some comments to solve several scenario of Grouping continuous Ranges together.

I will start with the simplest case which is ranges of integers, for example 2-4, 6-8, 8-10, 13-14 which should be grouped into 2-4, 6-10, 13-14.

Next I will move to explain issue related to the resolution of space between the ranges, and I will go to present a solution for Ranges of Decimal numbers.

Finally, using the solution which I presented in detail for INTEGERS I will present a solution for "Grouping continuous time-slots together", which was the original question in the forum.

By ronen ariely on 20/03/2019 22:40

This post summarize my lecture from last week at PASS DBA Virtual Group.

Understanding what we have under the hood is not only done for the sake of learning a theory, but it directly impacts your daily work, and it can help us to improve performance and reduce resources dramatically.

During this session we discussed the structure of tables behind the scenes. We saw the changes behind the scenes related to DDL actions, which we execute on tables. Using this information, I demonstrated several real case scenarios, and the dramatic impact of understanding the internals on choosing our solution.

Is the order of columns important? Is dropping a column is the right solution and what is the impact? Questions like those are very common in the forums and usually does not get the right answers even by experts, but the answers might be a game changer in production environment. 

This session is a live demo!
There is no presentation to share, but in this post I will share the code and some points.

THIS POST DOES NOT REPLACE THE SESSION BUT COMES TO SUMMERTIME IT
It is highly recommended to watch the recording first

By ronen ariely on 13/02/2019 00:55
This post does not aim to provide a solution for production but to present some playing with the function STRING_SPLIT which was added to SQL Server 2016, and discuss some theoretical results we can get using the function (Not For Production)
By ronen ariely on 12/01/2019 05:37

Several days ago, i saw a question in the MSDN forums, which led me to write this blog. I will rephrase the original question a bit and discuss the following request: How can we get the name of the current Stored Procedure (SP) from inside the SP

This is actually very simple question with multiple solutions which we can use on SQL Server On-Premises, but these solutions are not supported in other frameworks like Azure Data Warehouse and Parallel Data Warehouse.

My goal is to provide solutions for Azure Data Warehouse and Parallel Data Warehouse, but on the way I will cover the common solution for SQL Server and Azure Database as well.

By ronen ariely on 28/11/2018 19:44

A common question that raise in forums: Is The Order of columns important? 

We focus on the database's side and not the client's side point-of-view. For example, is order of columns related to performance, is it related to errors that might rise only when use specific order, or will SELECT query return different DATA (not important the order of the result SET but the DATA) if the order of columns is different...

In this post I want to present some simple demo which answer the question

Update 2019-03-21: adding example from my last lecture.

By ronen ariely on 25/09/2018 08:24

PowerShell gives us a powerfull tool to invoke queries using the cmdlet command "Invoke-Sqlcmd".

Invoke-Sqlcmd execute statements which are supported by the SQL Server SQLCMD utility, which is where the name Invoke-Sqlcmd came from probably. It allows us to execute Transact-SQL or XQuery statements, or sqlcmd commands. Using the parameter "-Query" we can execute inline queries, and using the parameter "-inputfile" we can specifies a path to a file, which is used as the query input to this cmdlet.

There are a lot of tutorials online on how to use Invoke-Sqlcmd command, which usually focus on the built-in paramatres and how to execute the command. One of these parameters is "Out-File", which allows us to send the output of the queries to a file, but how can we control the output of PRINT for example or the output of ERROR massage?!? 

Today I want to discuss some undocumented options of using Invoke-Sqlcmd. In this post I will show how we can control the target of the output not only of the queries but also errors and user-defined messages (PRINT statements), and how we can send these to a new file, to the shell screen or to any other target.

By ronen ariely on 24/09/2018 23:12

היום באירוע השנתי של Ignite 2018, מיקרוסופט הודיעה על שחרור גרסת הבטא (Public Preview) של SQL Server 2019.

כמי שמלווה את הפיתוח של השרת כבר זמן רב תחת Private Preview וללא יכולת לדבר על המוצר המדהים הבא בשל הסכמי הסודיות עליהם אני חתום, השחרור היום מהווה מבחינתי האישית את האישור הרשמי להתחיל ולדברעל הגרסה הבאה של שרתי SQL. ותאמינו לי שיש הרבה על מה לדבר! אבל תחילה בואו נפתח עם ההכרזה הרשמית, ובימים ובחודשים הקרובים אני אתחיל להעביר הרצאות יותר מעמיקות על התכונות החדשות אשר נוספו בגרסת 2019 והשיפורים של התכונות הקיימות אשר ניתן למצוא.

By ronen ariely on 22/08/2018 12:10

We have a table with Integer Column, which is no longer needed. What should we do in order to reclaim the size and/or improve performance?

(1) DROP column
(2) UPDATE values to zero
(3) Change the column to null
(4) ALTER column type

This post presents some important points related to discussion about a real-life case, which was asked in the MSDN's forums. For the sake of the post, I will present a summarize of the solutions, which were mentioned in the original thread, and a short discussion on each.

This post is advance topic, level 500 - Internals!

Update 2019-03-019: After presenting a lecture in PASS user group, i add some more points and code.

By ronen ariely on 11/08/2018 01:52

Several days ago I got a support call from a senior DBA, saying that "someone" in the company dropped a column in a table by mistake, before they copied several of the values,which they needed. Moreover, he explained that they do have any backup of the database and therefore they lost important data.

Before he contacted to me, he tried to get help in the forums, to contact several experts, and he found Microsoft's documentation which claimed that "This action cannot be undone". The question was simply a request to find away to get the lost data... 

Can it be done?!?

The short answer is, that a common user which work only with the LOGICAL layer of SQL Server using the documented tools cannot undone this action, but for SQL Server internals level of users, this is a different story...

By ronen ariely on 10/03/2018 04:43

When we are working with Many-To-Many relationship between two entity tables, we often need to find all the entities (rows in one table) which have relations with specific list of entities from the second type (rows in the second entity table). Our goal is to get all the Users that related to all specific roles. For example, all the users that have both RoleId 2 and RoleId 4.

By ronen ariely on 14/02/2018 00:13
Microsoft SQL Server Command Line Utilities version 14.0 was released several days ago, and it is available for download here. This post summarizes some information about Microsoft SQL Server Command Line Utilities, and provides links to the official documentation of sqlcmd in general and of each tool.
By ronen ariely on 05/01/2018 00:00
If you are one of the tech freaks who can afford to buy a new computer every week, or if it's just time for you to buy a new computer, or even if you simply use modern Intel processors dating back at least a decade, then you should read this post! A vulnerability affecting computers running Intel chips was announced two days ago!
By ronen ariely on 23/12/2017 15:54

בהמשך לדיון בהועלה בפיסבוק אני רוצה להעלות כמה נקודות ולהציג את 2 הסנטים שלי בנושא המשמעות של הפרדת דיסקים בעידן הוירטואלי.

כדי לחסוך לעצלנים את קריאת הבלוג (שהוא גם כך קצר מאוד), הרשו לי להתחיל מהסוף:

באופן חד משמעי, לחלוקה נכונה של קבצי מסדי הנתונים יכולה להיות משמעות מכרעת על הביצועים גם במכונות וירטואליות!

בוא נעבור על כמה נקודות שיכולות  לכוון אתכם להבנת הנושא

By ronen ariely on 23/11/2017 10:22
This is a simple Step-By-Step tutorial, showing how to use Azure BLOB Storage services to store backups of SQL Server databases. During the tutorial I will start with creating a new Azure Storage Account, next I will create new Credential in our local SQL Server and using the Credential I will backup and restore the SQL Server database.
By ronen ariely on 04/07/2017 16:03

Using the SQL Server Management Studio Stretch Database wizard with the option to filter the rows, does not fit for cases that the table does not include data which fit the stretch condition! 

We can use the built-in SQL Server Management Studio wizard in order to enable Stretch on the database and configure the table which will be stretched to the Azure on the same time, but it does not fit for all cases. In this short blog, I want to show example (again) why you should not use wizards.

* The solution is simply to use T-SQL queries, and please forget about using Stretch Database wizard, as I usually recommend regarding most wizards.

By ronen ariely on 10/06/2017 04:23

This is short post I publish as an answer to a question in the MSDN forum. In this post I will go very fast on the theoretical topic and will move to a short demo. Relational database system implements relations by using foreign key, which point to the related unique key identifying the row in the other table (named Primary Key). Since foreign key can only point to a single row in the other table, this model cannot implement a direct Many-To-Many relationship between rows in two entity tables. Read more to see how we implement it...

By ronen ariely on 10/05/2017 21:51

I want to bring a short story regarding a bug report related to SSMS 2017 and a User defined Extensions. I spend several hours to find the issue and I hope this blog will help you save the time. Therefore, if you are developing extensions (addins) to SSMS using VSIX template, or if you interesting in the subject, or if you simply tried to install extension and the installer did not recognize the SSMS, which installed in your machine, then this blog is for you.

By ronen ariely on 31/03/2017 19:03
SSMS vNext BUG during creating script to delete database from azure SQL Server
By ronen ariely on 10/12/2016 07:42

SET IDENTITY_INSERT doesn't work with 4 parts name, and as such it doesn't work with linked servers unless you execute dynamic SQL. Moreover, "SET IDENTITY_INSERT" is a session level setting, therefore when you connect to another server the setting of current session are not relevant. In this short blog I will show how we can use SET IDENTITY_INSERT on linked server using dynamic SQL.

By ronen ariely on 01/12/2016 07:03

This post demonstrates several options to convert VARBINARY data into Base64 string, and vice versa convert Base64 string into VARBINARY.

* In future posts I will show practical examples of using these actions. For example, we can use Base64 string in order to send emails, which include embedded images, stored in the database as VARBINARY.

By ronen ariely on 19/11/2016 20:53
Step by step video demo: Monitoring growth of SQL Server database files using Profiler and Using the 
By ronen ariely on 02/10/2016 06:30

* This post base on a question asked at the MSDN forums in this link

In order to restore the database in the same instance with the original database, we need to (1) move the restored database files to new location, since two files cannot have the same path in windows operating system. (2) we must change the DIRECTORY_NAME for the Filetable data, since it is instance level element and it must be unique in this SQL Server instance.

We can configure the new path for the restored files using simple command "restore... with move <original path> to <new path>" for each file, but there is no built-in option to configure the DIRECTORY_NAME at the same time during restore. Well... In this post I will show step by step a simple procedure to restore the database as a new database on the same instance as the original database.

By ronen ariely on 09/07/2016 19:54
One of the new security features that SQL Server version 2016 brings, is the Dynamic Data Masking (DDM). Implementing DDM internally in SQL Server, aims to bring us better security, in the user level rules. User not been granted permission "UNMASK", cannot be exposed the original value, if column configured to be masked. Is this actually works?!? In this blog I will show how easy it is to expose the masked data, by any user.
By ronen ariely on 23/06/2016 23:25

When you try to open the Help Viewer from SSMS 2016, there are two behaviors that people reports about: (1) Instead of getting the new Help Viewer version 2.2, which came with the SSMS 2016, the old version 1.1 is opened(2) Instead of getting any help viewer, the browser opened and redirects us to the Book-Online, or An error raises with the message "no app are installed to open this type of link (ms-xhelp)".

In one of my previous blogs I wrote about how to install Microsoft SQL Server 2016 Book-online for offline use. I mentioned this bug regarding starting the help viewer:

! Quote In the current SSMS version (April 2016 preview), when we click on F1 or if we select "Help" -> "View Help" in order to get help, instead of opening the Help Viewer, SSMS opens the download page in the browser, even if the Help Viewer already installed! It seems like a bug.

The current version is SSMS June 2016 generally available release, which mean that this version theoretically ready for production. Yet, the bug is still there, and it is time to focus a bit more on what seems to behave wrong, and how we can workaround these issues...

By ronen ariely on 19/06/2016 04:47

Text strings are created from characters. A collection of characters called a "character set". A character set, also known as a code-page or charset. It is an ordered set of characters in which each character is mapped to a numeric index, called a "code-point".

Character Encoding is the mechanism to map the code points into bytes. The code points are stored in the computer as one or more bytes (collation of 0 and 1). The visual representation of characters is configured by the font. A font is a collection of glyph definitions used to display characters...

By ronen ariely on 14/06/2016 08:05

Row-Level Security enables customers to control access to rows in a database table. Access to row-level data in a table is restricted by security predicate, defined as an inline table-valued function. The function is then invoked and enforced by a security policy.

According to the BOL, RLS filter predicates are functionally equivalent to appending a WHERE clause. The predicate can be as sophisticated as business practices dictate, or the clause can be as simple as WHERE TenantId = 42. Is this accurate?


By ronen ariely on 22/05/2016 18:29

Using "Microsoft Help Viewer", which is a small free tool, we can download the entire official SQL Server Book-Online. In this short blog I will explain how to do it step-by-step from downloading Microsoft Help Viewer to installing the SQL Server documentation.

By ronen ariely on 15/04/2016 10:39

In this session we will demonstrate several built-in JSON support functions in SQL Server 2016, and we will finish with some tricks and tips to improve performance.

By ronen ariely on 12/02/2016 14:49

A very common question that raise in the forums is: why a FULL BACKUP, which was fast in past becomes slow. It can be a one-time issue (specific backup), or permanent. These question are usually not related to big database (100TB +), which we are not using FULL BACKUP usually, and are more common on small-medium databases. In this blog I will provide information, explanation, tips, and some links to read more. This blog is in permanent process of improving. If you have any comment please post it in my Facebook home page.

By ronen ariely on 31/12/2015 20:29

Simple CLR code for SQL Server

By ronen ariely on 14/12/2015 10:38

I see in the forum this question raised all the time, and yet the solution that people get usually based on looping and complex math, while there is a simple and much better solution as shown in this code. In this short blog I will wrote a simple and VERY fast solution to convert Decimal number to Binary number, Decimal number to Hexadecimal number, and vise versa without using any loop. My solution for binary base is based on using BITWISE.

By ronen ariely on 16/08/2015 21:45

The question "what is the difference between Unique Constraints and Unique Indexes" always rises in forums. Instead of writing this every time in the each forum and each question, I have decided to post this blog. There are several articles that you can find online regarding this issue. This blog does not intend to replace a full tutorial, but it is more like a preview or a summary of the issue, by showing several differences in practice.

By ronen ariely on 25/05/2015 13:10
In some cases the SQL Server query optimizer engine fail to build the best execution plan. This is the place where our abilities as DBAs can be handles. One of these cases is when we are using windows functions like ROW_NUMBER, which use "ORDER BY" the clustered index. Since our data is already sorted by the clustered index, there is no reason to sort the data again. In simple query the SQL Server query optimizer "understand" it, but in more complex queries it might fail. In this short post, I will show a small trick to improve our query and make sure that the windows function do not waist resource on sorting the data.
By ronen ariely on 07/05/2015 14:17

In this blog I will show step by step how I examined the DateTime2 data, in order to find the actual storing format. The basic process is based on reverse engineer by examining the binary data that we get in CONVERT to VARBINARY(16)

-- check the data as binary show us the format behind the scenes:
DECLARE @d DATETIME2 = '2016-02-27 00:00:00.000' -- My next birthday :-)
SELECT CONVERT(VARBINARY(16),@d)
GO
* Result: 0x070000000000143B0B

The goals in this blog are: (1) understand how DateTime2 stored in the database, (2) to provide a small glimpse on the process that we can use in order to examine what is going behind the scenes in the Page Data File (for specific data type).

By ronen ariely on 28/11/2014 13:46
Split Date's Range into Shifts per days
By ronen ariely on 29/10/2014 16:18

In some case we have to use single value, in order to represent a list of elements (values). This is a very common needs in hardware and software developing. All the logics that we discus in this article, can be implements regardless of database use. In this article we will focus on using SQL Server to implement our logics. This might be an external demand (applications for example) or even a result of bad database design. Yet, the needs is clear, we want to store multiple elements in one column. Those elements can be properties list, options, security permissions, dates, or any other data.

In this article we will go over several solutions, using different logics. Our challenge is to find a good logic, which give us a one-to-one correspondence, between each available combination of our elements, to a single value which represent this combination.

By ronen ariely on 17/10/2014 10:27

Sometimes A new version or feature release and a new bug which related to this feature revealed, but sometimes we stuck with a BUG for years.. many years... 15 years even... will it be fix in the next version?

Using User Defined Function In Constraint can lead to a BUG! In this short blog I will just reproduce the BUG and show a simple workaround. This is not a new topic, and you probably can find lot of articles on net,on the same issue, but since it came up again... i decided to post this blog again.

By ronen ariely on 10/10/2014 00:36
Short and simple Stored Procedure to find the pearson who was the last one who deleted a record from a table. Very useful when your boss delete row and start to shout at you why the data is not accurate, or why tour application have a bug :-) 
By ronen ariely on 01/10/2014 10:53
This is small set of script in order to get the connection properties. You can use it in order to compare two execution of the same query on the same database which use different Execution Plan as a result of different Connection Properties.
By ronen ariely on 11/09/2014 12:01

This short blog give a simple example how to use "FOR XML" hint in order to consolidate data in different rows into a single row in the result SET (an operation known as Un-Split data). In this example we are going to group together only rows with the same value in specific column/s. In short we can call this action "Un-split data with grouping". This post was updated on July 25 2018 in order to add a solution using STRING_AGG function which was added in SQL Server 2017.

By ronen ariely on 04/09/2014 09:41

SQL Server can listen to request which come to specific IP address on specific port, or to all request regardless the IP, It can listen to request which come to a Named pipe, as well. By default, SQL server uses port 1433 in TCP/IP, and default instance of Microsoft SQL Server listens on "\\.\pipe\sql\query" named pipe.

In this short article I will show how we can configure those options.

By ronen ariely on 17/08/2014 19:11

לפני כמה ימים נשאלה שאלה מעניינת בפורום של MSDN העולמי (אנגלית). לאחר דיון קצר בפרוום ובפייסבוק נראה שהדיון גווע עם האמירה "אי אפשר". מי שמכיר אותי יודע שאמירה כזו במחשבים לא מקובלת עלי ולמעשה הגעתי לשרשור של ההודעה בדיוק בנקודה זו. לכן החלטתי למצוא דרך פשוטה לפתרון הבעיה. בלוג זה מציג את הרעיון העומד מאחורי הפתרון בצורה מפורטת.

אז מה הבעיה מולה אנחנו עומדים?

שימוש ב DBCC כחלק משאילתת VIEW לא מאפשר בצורה ישירה. אז כיצד אפשר לבצע את זה בכל זאת?

בואו נראה עד כמה הדברים קלים לביצוע :-)
קריאה מהנה...

By ronen ariely on 26/07/2014 23:21

רמת בידוד סדרתיות (Serializable) דורשת כי כל שאילתה שבוצעה במהלך עסקה חייבת לקבל את אותו הסט של שורות בכל פעם שהיא מתבצעת במהלך העסקה. נעילת טווח נועדה להגן על שורות אשר בצורה עקיפה או ישירה נמצאות באוסף השורות שנקראות על ידי הוראת שאילתה, בזמן שאנחנו עובדים ברמת בידוד סדרתית. נעילת טווח מפתח (key) מבטיחה לנו שמירת הדרישות של רמת הבידוד, על ידי מניעת שינויים במפתחות אשר עלולים להיות בטווח המפתחות שהשאילתה קוראת.

במאמר מעמיק זה נדון בנושא נעילות טווח והקשר לרמת בידוד סדרתית. כמו כן נציג מקרים בהם נוכל למטב את השאילתה ולמצנוע נעילות תוך שינוי קטן בשאילתה, ובכך נוכל להשיג את מיטוב העבודה.

By ronen ariely on 15/07/2014 20:56

הקדמה

במשפט אחד נוכל להתייחס לחותמת זמן (timestamp) כסוג של תאריך, שמנוהל ברמת מסד הנתונים ונשמר בצורה בינארית. חותמת הזמן נועדה לאפשר לנו לנטר את השינויים של נתונים בטבלה. הרעיון הוא להצמיד לכל שורה בטבלה חותמת זמן, שמתאימה לזמן השינוי האחרון שנעשה בשורה זו. שינוי זה יכול להיות תוצאה של הכנסת השורה לטבלה, או עדכון שלה.

על מנת לעמוד במטרות של טור זה, השרת חייב להבטיח שהערכים בחותמת הזמן יהיו תמיד ייחודיים, בין שני זמנים שונים.

שרתי SQL  נועדו לעבודה מסיבית עם נתונים הן מבחינת כמות הנתונים והן מבחינת מהירות העבודה עם הנתונים. השימוש בגדלים מוחלטים כגון סוגי זמנים שונים, לא נותן לנו את הפתרון המתאים בשל תלות ברזולוציה של הנתונים, כפי שנראה בהמשך. כחלק מהצורך לניהול נתונים במערכות כבדות נמצא פתרון בעזרת סוג שונה, שקיבל את השם חותמת זמן - timestamp.

במאמר זה אני אנסה לתת הסבר מקיף ומלא על נושא חותמות זמן בשרתי SQL Server החל מהגרסאות הקדומות שלו ועד השרתים החדשים.

By ronen ariely on 30/05/2014 08:36

Buffer Pool Extension או בשם המקוצר BPE היא תוספת חדשה בגרסאות Standard ו Enterprise של SQL Server 64 Bit. באופן תיאורטי הרחבה זו יכולה לשפר באופן משמעותי את היכולת של מערכות הצורכות זיכרון כגון OLTP. ההרחבה מבוססת על הוספת Buffer Pool היושב על מחיצה מהירה (SSD למשל), ובכך מאפשרת להרחיב את השימוש בזיכרון RAM. ה BPE יראה עבור המשתמש כזיכרון מטמון נוסף. רכיב בשם Buffer Pool Manager אחראי על ניהול המידע בזיכרון המטמון המורחב (תיאום בין ה RAM לבין ההרחבה). ההרחבה נעשית על ידי יצירת מטמון זיכרון הירארכי, כאשר הרמה העליונה מתקיימת ב RAM והרמה השנייה בהרחבה של הזיכרון המטמון.

By ronen ariely on 11/01/2014 19:04

Sub Queries is not permitted in Check Constraint. we will show how to bypass this restriction.

By ronen ariely on 07/01/2014 13:21

Volume Shadow Copy Service (עותק צל) הוא שם של קבוצת ממשקים (interface) מסוג COM interfaces. רכיבי COM אלו מיישמים סביבת הרצה שמאפשרת לבצע גיבויים בזמן שיישומים במערכת ממשיכים לכתוב לאמצעי האחסון ונועלים חלק מהקבצים. במערכות הפעלה של מייקרוסופט VSS נתמך מגרסת XP והלאה. במערכות מבוססות NT אמצעי האחסון מנוהלים על ידי ה Disk Management MMC snap-in. מאחורי הקלעים תוכנה זו עושה שימוש ברכיבי ה VSS.

הליך של ביצוע עותק צל לא יעבוד טוב אם בזמן ביצוע ההעתקה, יבוצעו קריאות לשינויים בקבצים אשר לא ינוהלו בצורה מתאימה לאפליקציות העובדות עם הקבצים. בגרסת SQL 2005 מייקרוסופט סיפקה לנו תמיכה לביצוע עותק צל על ידי כך שסיפקה  כתבן (VSS writer) מתאים בשם SqlServerWriter.

במאמר זה נסביר בצורה כללית מהו עותק צל (VSS) וכיצד הוא עובד; נראה בקצרה כיצד עובדים עם תוכנת הניהול VssAdmin ליצירה, מחיקה וקריאה של עותקי צל במערכת ההפעלה; נראה את הקשר והחשיבות לשרתי SQL; נשים דגש על החלק המעשי כאשר נציג כיצד הדברים עובדים עם קבצי SQL. נראה כיצד אפשר לפתח אפליקציה קטנה להעתקת קבצי SQL תוך כמה דקות של עבודה. אפליקציה זו תאפשר לנו להעתיק קבצים ללא הרצת שאילתת גיבוי וללא צורך בביצוע פעולת detach והורדת מסד הנתונים מהאוויר.

By ronen ariely on 11/12/2013 03:03

Hierarchical data is organized into a tree-like structure. The structure allows representing information using parent/child relationships: each parent can have many children, but each child has no more than one parent (one-to-many relationship). Our records have a unique column (named "ID" in our case). Parents and children are tied together by "pointer" column. In our case we will call our pointer column "ParentID".

Our requirement is to sort the data which is based on the Child-Parent hierarchy according to the tree structure. Each child must be under its parent tree, and all children with the same father, sorted by their ID order (on Appendix A we will show how to sort by any other column).

By ronen ariely on 25/11/2013 18:56
SQL Random String using CLR
By ronen ariely on 28/10/2013 16:44

I see many questions about the difference between Cursor and While Loop in SQL queries. I think this is a fundamental mistake to compare them at all. It's like comparing a car and a boat. We use the car moving on land, and we use a boat to travel at sea. I would not recommend anyone to try the opposite. So what's so confusing?

Let's try to have a brief discussion about "Cursors and Loops" in general and the replacing between them (yes we can car to travel at sea and a boat to move on land).

By ronen ariely on 24/10/2013 15:21

In the last few weeks we are all talking about the upcoming next version of SQL Server 2014. In the process to the final release, Microsoft give us the CTP beta versions, which release with poor documentation. The second best feature I loved on the SQL 2014 (after the In-Memory OLTP) is by sure the new "extremely useful" DMV: sys.dm_exec_query_profiles. This DMV did not work on CTP1, and I understood that it should be ready on CTP2.

Is it working, and is it extremely useful as expected?!?

Let's play with it a bit

By ronen ariely on 22/09/2013 03:55

In this short blog I will show how easy it is to add sequence's column to an existing table which already have data. Sequence is a new element added to SQL server 2012 (and can be find in MySQL and Oracle for a very  long long… long time) for implementing automatically assigned integer values. We can even assign a sequence to an existing integer column which already have values in it, in a direct simple query (not like an Identity column).