Skip to main content

Posts

Showing posts with the label t-sql

PowerShell to get Some DATA on ALL your Azure SQL DB's

שלום רב למי שיש הרבה בסיסי נתונים מפוזרים בענן רוצה לצבור עליהם מידע לצרכים שונים יכול ליצור סקריפט PowerShell שיעבור על כל ה Subscriptions ויאסוף מידע שקיים ב PowerShell. וכן המקום לפינת הקיטור היומית - ידידינו ממיקרוסופט מה עם Backward Compatability? היו לי פרמטרים שיכלנו לשאוב למשל כמה גודל בסיס הנתונים וכרגע אי אפשר לדעתי. נכון נותנים את המידע במקומות אחרים אבל נוח שזה יעבוד שנים - וסקריפט שעבד לי שנים - לאחרונה הפסיק לעבוד. יש לזה המון שימושים למשל רוצים לראות באילו בסיסי נתונים יש המלצות למשל להוסיף אינדקס ואתה לא רוצה לעבור בפורטל לכל בסיס נתונים. או מתי הגיבוי הראשון או הגיבוי האחרון שיש. אז הנה סקריפט בסיסי ממש - מוזמנים לשפר ולשתף עם הקהילה. ראשית עליכם לוודא שהמודולים של Azure מותקנים אצלכם (הרצה חד פעמית במחשב) install-module -Name AzureRM -Force עושים לוגאין ליוזר שלכם ב Azure (חד פעמית בסשין) Add-AzureRmAccount מריצים את הסקריפט להנאתכם Write-Host "Login to Azure..." -ForegroundColor Cyan $subscription = ( Get-AzureRmSu...

RETENTION on Temporal Tables

שלום לכולם אכן הרבה זמן לא כתבתי, אשתדל לחזור לעצבי בקרוב. והיום בקצרה על ניהול טבלאות temporal. בקצרה ב SQL Server - החלו להשתמש ברעיון של שמירה אוטמטית של שינויים בנתונים בטבלה. ואפשר לתשאל גם את הטבלה ההיסטורית וגם את הנוכחית בשליפה אחת: https://docs.microsoft.com/en-us/sql/relational-databases/tables/querying-data-in-a-system-versioned-temporal-table /*State of entire table AS OF specific date in the past*/ SELECT [DeptID], [DeptName], [SysStartTime],[SysEndTime] FROM [dbo].[Department] FOR SYSTEM_TIME AS OF '2015-09-01 T10:00:00.7230011' ; אחת הבעיות זה ניהול הטבלה ההיסטורית אי אפשר למחוק ממנה בצורה רגילה - ואצלי ב SQL Azure הדבר נהיה משמעותי עקב מגבלת הגודל. לכן עלינו על נושא ה RETENTION שזה פיצ'ר מדהים שניתן בכל SQL Server ולהפתעתי גם ב SQL Azure. יש אפשרות להגדיר כמה זמן יישמר המידע בטבלת היסטוריה. כאשר יש סרביס מאחורה שרץ ומוחק מה שצריך ללא עומס מיוחד בבסיס הנתונים - לא הצלחתי להבין היכן זה רץ ומה חלונות הזמן שלהם. הגדרה זו ה...

Azure Automation vs Azure Function AS SQL Server Agent

שלום לכולם ב 2014-9-21 פירסמתי פוסט על Azure Automation - מנגנון תיזמון התהליכים של Azure. מעבר להיותו טיפה מסורבל הוא יכול להריץ בעיקר  PS. לאי אפשר לתזמן דברים בתדירות גבוהה ולכןן לא העברתי אליו תהליכים רבים. לאחרונה נוסף חידוש בAzure, הנקרא Azure Function שזהו הכלי להריץ קטעי קוד קטנים מבלי להרים שרת ServerLess. רבותי הענן מריץ לכם סוגי קוד שונים:   Write functions using C#, F#, Node.js, Python, PHP, batch, bash, or any executable  ניתן לקרוא על זה פה: Azure Functions Overview טוב חשבתי לעצמי - יללה Agent לא רק PS אלא קצת נשפשף את ה C# שלנו. ואז ראיתי 2 מאמרים שבעצם הוכיחו לי שהכיוון נכון - או יותר נכון לומר 2 מאמארים שגנבו לי את המחשבות: Azure Functions to Schedule SQL Azure operations  - מפה לא יצא לי כלום. Azure Functions Tutorial – SQL Database  - אחלה מאמר ומפה התקדמנו. ביקשתי מגרי רשף שיעשה כמה בדיקות ויריץ את - ואכן הדבר עובד להפליא - נשאר רק לנהל מנגנון התרעות על כשלונות והכל יהיה מעולה. ראו מאמר של גרי בנושא: תזמון משימות ב-...

Performance Recommendations you DO NOT want to do in your Azure SQL DB

שלום לכולם בתקופה האחרונה אני רואה טרנד מאד חזק של בלוגים ומאמרים שאומרים "אל תהיה טיפש.... אל תעשה את זה.." או בלוגים בסגנון של "רעיונות ממש - אבל ממש רעים..". אז יילה גם אני ארחב על הגל הזה בהקשר של SQL Azure. והיום ה - "אל תהיה טיפש" מספר 1:   יש בפורטל מסך השייך לכל בסיס נתונים ובו פעולות אפשריות על בסיס הנתונים - החל בפתיחת קריאה - עבור לשינוי יכולות וביצועים וכלה בהמלצות. תחת הכותרת: "SUPPORT + TROUBLESHOOTING" יש 5 אפשרויות לחיצה הראשונה בודקת מצב כללי של בסיס הנתונים. האחרונה זו פתיחת קריאה ישר על בסיס הנתונים הזה - מאד נוח לשימוש וממליץ לפתוח קריאה מפה.        השניה מציגה סיכום קצר של נקודות 3 וארבע כלומר   Over view on Query insights - that is the same as query store and Overview on Performance Recommendations.   זהו המסך:          המסך מחולק ל 4 חלקים - למעלה זהו החלק שאחראי על    Overview on Performance Recommendations: Create & Drop indexes...

Cross Database Queries in SQL Azure DB - Part 2

Hi All   So After a month of using Cross Database Queries in SQL Azure DB, I can say that we have a very useful tool.   We can use in many scenarios, I will show today one.   We are using 10 shards DB's to balance read operations to many DB's. The write operations goes to the DB's as well.   I' as a DBA wants to know the status of all DB's, so instead of creating PowerShell that connect to all of the DB's I have created external tables in 1 DB that reads the     sys . dm_db_resource_stats     from all DB's' so I have now 1 real table and 9 external tables.   I have created a view that reads from al 10 tables' and now I see all data from all shards.   I also put it in PowerBI and I see it in a visual way - and also in my Mobile.   Here I have in the first line DTU AVG value for each shard in the last 10 minutes, 1 clock that avg all shards.   The second line is the DTU real value in the ...

Cross Database Queries in SQL Azure DB - Part 1

Hi   I wanted to write this post a long time ago but have not had the chance, so now with the new year - this will be the first post for 2016.   Cross Database Queries in SQL Azure DB was a key feature that was missing from day 1 on SQL Azure DB. Finally we have this  key feature, and no, it is not the same as in the regular SQL Server. We have a new way to do this. It is bases on the new key feature  in SQL Server 2016 called "External Tables" ( https://msdn.microsoft.com/en-us/library/dn935021.aspx ). Also known as " PolyBase ".   The logic behind the feature is that you can query tables with-in your DB (like you are doing today) and also at any other DATA source like it is a table within the DB.   From one SQL Azure DB to another we can not connect to it via linked server. However a second SQL Azure DB is referenced like any other external data source. Microsoft thinking is that SQL Azure DB is another DATA s...