יום רביעי, 17 ביוני 2009

Table valued parameters

כידוע ישנם חידושים ושיפורים רבים בפלטפורמת ה- sql server 2008, בין החידושים השימושיים ביותר בתחום האפליקיטיבי הינו: Table valued parameters.

ישנם מקרים בהם אנו רוצים להעביר לפרוצדורה יותר מערך אחד, לדוגמא כאשר אנו רוצים להעביר סט של מספרים לפרוצדורה במטרה לשלב את המספרים ב- where לדוגמא.
בגרסאות הקודמות היינו מממשים את הפתרון בצורות שונות (xml, Dynamic SQL, משרשרים כסטרינג עם מפריד וכו'..) .
ב- sql server 2008 ישנו פתרון יעיל ונוח יותר :Table valued parameters המאפשר לפרוצדורה לקבל משתנה מסוג טבלה.

השלבים למימוש הפתרון:
1. Create a table type
2. Create a procedure to receive data for the table-valued parameter
3. Declare a variable that references the type
4. Add data to the table variable
5. Pass the table variable data to a stored procedure

לדוגמא:
USE AdventureWorks;
GO
/* Create a table type. */
CREATE TYPE LocationTableType AS TABLE
( LocationName VARCHAR(50),
CostRate INT );
GO
/* Create a procedure to receive data for the table-valued parameter. */
CREATE PROCEDURE usp_InsertProductionLocation
@TVP LocationTableType READONLY
AS
SET NOCOUNT ON
INSERT INTO [AdventureWorks].[Production].[Location]
([Name] ,[CostRate] ,[Availability] ,[ModifiedDate])
SELECT *, 0, GETDATE()
FROM @TVP;
GO
/* Declare a variable that references the type. */
DECLARE @LocationTVP
AS LocationTableType;
/* Add data to the table variable. */
INSERT INTO @LocationTVP (LocationName, CostRate)
SELECT [Name], 0.00
FROM [AdventureWorks].[Person].[StateProvince];
/* Pass the table variable data to a stored procedure. */
EXEC usp_InsertProductionLocation
@LocationTVP;
GO
בהצלחה.

יום שני, 15 ביוני 2009

xp_msver

שלום רב,

כידוע פלטפורמת sql server מורכבת גם ממספר רב של פונקציות ופורצדורות מערכת.
אחת מהפונקציות השימושיות הינה - xp_msver .

מטרת הפונקציה להציג מידע חיוני אודות פלטפורמת ה- sql server שבשרת.

לדוגמא:
xp_msver 'ProductVersion' - מציג את הגרסה של הפלטפורמה.

פרמטרים נוספים שהפונקציה יכולה לקבל:

ProductName
Language
Platform
WindowsVersion
ProcessorCount
PhysicalMemory ועוד'.

לפרטים נוספים אודות הפונקציה:
http://msdn.microsoft.com/en-us/library/ms187372.aspx

בהצלחה.

יום רביעי, 27 במאי 2009

Microsoft SQL Server 2008 Reporting Services Report Builder 2.0

Microsoft SQL Server 2008 Reporting Services Report Builder 2.0 delivers an intuitive,
Office-like report authoring environment enabling business and power users to leverage their experience with Microsoft Office 2007 products.
Microsoft SQL Server 2008 Reporting Services Report Builder 2.0 supports the full capabilities of SQL Server 2008 Reporting Services including:

* Flexible report layout caabilities of SQL Server 2008 Report Definition Language
* Data Visualizations including charts and gauges
* Richly formatted textboxes
* Export to Microsoft Office Word format
Features specific to Report Builder 2.0 are focused on simplifying the process of creating and editing reports and queries and include the following:


* Easy to use wizards for creating table, matrix and chart data regions
* Support for directly opening and editing reports stored on the report server
* Support for using server resources such as shared data sources
* Query designers for multiple data sources including a Microsoft SQL Server-specific query designer

יום ראשון, 24 במאי 2009

Microsoft SQL Server 2008 Books Online (May 2009)

שלום רב,
מייקרוסופט שיחררה עדכון ל- Books Online לפלטפורמת sql server 2008.
להלן פרטים אודות העדכון:
SQL Server 2008, the latest release of Microsoft SQL Server, provides a comprehensive data platform. Books Online is the primary documentation for SQL Server 2008.
Books Online includes the following types of information:
* Setup and upgrade instructions.
* Information about new features and backward compatibility.
* Conceptual descriptions of the technologies and features in SQL Server 2008.
* Procedural topics describing how to use the various features in SQL Server 2008.
* Tutorials that guide you through common tasks.
* Reference documentation for the graphical tools, command prompt utilities, programming languages, and application programming interfaces (APIs) that are supported by SQL Server 2008.
* Descriptions of the sample databases and applications that are available with SQL Server 200.
You can download the sample databases from the SQL Server Community Projects and Samples page on CodePlex.
לפרטים נוספים:

יום שלישי, 19 במאי 2009

sp_clean_db_free_space - Clean Up Your SQL Server Databases

שלום רב,

כידוע service pack 3 של פלטפורמת sql server 2005 תיקן באגים רבים (http://support.microsoft.com/?kbid=955706).

אחד מהבאגים החשובים הינו - שימוש חוזר בעמודי זיכרון .
ע"פ עלון אבטחה של מיקרוסופט מס' MS08-0 , קיימת פגיעות של גילוי מידע באופן שבו SQL Server מנהל את השימוש החוזר בעמודי זיכרון. תוקף בעל גישה של מפעיל מסד נתונים שמצליח לנצל פגיעות זו עלול לגשת לנתוני לקוחות שאלמלא כן אסור היה לו לצפות בהם.

לפרטים נוספים:
להלן קישור לעלון האבטחה: https://www.microsoft.com.nsatc.net/israel/technet/security/Bulletin/MS08-040.mspx

מאמר של Kalen Delaney בנושא:
http://www.sqlmag.com/Articles/ArticleID/101551/101551.html?Ad=1

בהצלחה.