ssms tools pack

by Neon Quach 28. August 2010 18:17

ssms tools pack

SSMS Tools Pack is an add-in for Microsoft SQL Server Management Studio (SSMS) 2005, 2008, 2008 R2 and their respective Express versions.
It contains a few upgrades to the SSMS IDE that I thought were missing.

The current features include:
• SQL Snippets
• Window Connection Coloring
• Query Execution History and Current Window History
• Format SQL
• Search Table, View or Database Data
• Run one script on multiple databases
• Copy execution plan bitmaps to clipboard or file
• Search Results in Grid Mode
• Generate Insert statements from resultsets, tables or database
• Regions and Debug sections
• Running custom scripts from Object Explorer
• CRUD stored procedure generation
• New query template
• General options


To download it go to:

http://www.ssmstoolspack.com/

Tags: , ,


Categories: download | sql

Mã hóa và giải mã mật khẩu sử dụng EncryptByPassPhrase và DecryptByPassPhrase

by Neon Quach 5. June 2010 02:46

Giới thiệu:
Bài này mình sẻ hướng dẫn mọi người làm thế nào để mật khẩu và lưu trữ mật khẩu dạng VarBinary sử dụng hàm EncryptByPassPhrase và giải mã sử dụng DecryptByPassPhrase.

Giải thích:

EncryptByPassPhrase sử dụng thuật toán Triple DES để mã hóa text được truyền vào.

Cú pháp: ENCRYPTBYPASSPHRASE('PASSPHRASE',”text”)


Trong cú pháp phía trên 'PASSPHRASE' được xem như là 1 cái khóa bảo mật, và text phải là dữ liệu dạng VarBinary.


Tạo 1 bảng Creating a ' table:

create
table login_details(uid integer,username varchar(10),password varbinary(100))

Thêm 1 vài record:

insert
into login_details(uid,username,password) values(1,'smith',EncryptByPassPhrase('12','XXX'))

insert into login_details(uid,username,password) values(2,'kennal',EncryptByPassPhrase('12','YYY'))

insert into login_details(uid,username,password) values(3,'staurt',EncryptByPassPhrase('12','ZZZ'))

Hiển thị các record vừa chèn vào
select * from login_details



DecryptByPassPhrase:  trường được mã hóa có thể được giải mã bởi việc sử dụng DecryptByPassPhrase

Hàm DecryptByPassPhrase nhận vào 2 tham số, 1 là PASSPHRASE  giống như key, 2 là text hoặc tên trường.

select uid,username, DECRYPTBYPASSPHRASE ('12',password) as Password from login_details



Kết quả bên trên mật khẩu vẩn là dạng VarBinary, cho nên chúng ta phải chuyển VarBinary sang dạng Varchar sử  dụng hàm chuyển đổi như sau:

select uid,username,convert(varchar(10), DECRYPTBYPASSPHRASE ('12',password)) as pwd from login_details

Reference

Tags:


Categories: sql

bật clr trong sql server

by Neon Quach 4. June 2010 18:40

Cơ chế clr trong sql giúp chúng ta có thể tạo User Define Types (UDF), User Define Function (UDF), Table value Functions (TVF), Triggers, and Stored Procedures sử dụng ngôn ngữ lập trình như: C#, VB.NET.

Đoạn script giúp chúng ta có thể bật hoặc tắt nếu muốn

if exists(select * from sys.configurations where name = 'clr enabled' and value_in_use <> 1)

begin

        exec sp_configure 'clr enabled', 1

        reconfigure with override

end

go

 
Và khi muốn tắt chức năng clr đi thì chỉ cần thay đổi giá trị 1 thành 0.

Hope this help!

 

Tags:


Categories: sql

introducing microsoft sql server 2008 r2

by Neon Quach 23. April 2010 21:10

introducing microsoft sql server 2008 r2

We’re thrilled to publish another free ebook: Introducing Microsoft SQL Server 2008 R2, by Ross Mistry and Stacia Misner!

The book contains 10 chapters and 216 pages, like so:

PART I   Database Administration

CHAPTER 1   SQL Server 2008 R2 Editions and Enhancements 3
CHAPTER 2   Multi-Server Administration 21
CHAPTER 3   Data-Tier Applications 41
CHAPTER 4   High Availability and Virtualization Enhancements 63
CHAPTER 5   Consolidation and Monitoring 85

PART II   Business Intelligence Development

CHAPTER 6   Scalable Data Warehousing 109
CHAPTER 7   Master Data Services 125
CHAPTER 8   Complex Event Processing with StreamInsight 145
CHAPTER 9   Reporting Services Enhancements 165
CHAPTER 10   Self-Service Analysis with PowerPivot 189

Here’s more info about the book:

Introduction

Our purpose in Introducing Microsoft SQL Server 2008 R2 is to point out both the new and the improved in the latest version of SQL Server. Because this version is Release 2 (R2) of SQL Server 2008, you might think the changes are relatively minor—more than a service pack, but not enough to justify an entirely new version. However, as you read this book, we think you will find that there are a lot of exciting enhancements and new capabilities engineered into SQL Server 2008 R2 that will have a positive impact on your applications, ranging from improvements in operation to those in management. It is definitely not a minor release!

Who Is This Book For?

This book is for anyone who has an interest in SQL Server 2008 R2 and wants to understand its capabilities. In a book of this size, we cannot cover every feature that distinguishes SQL Server from other databases, and consequently we assume that you have some familiarity with SQL Server already. You might be a database administrator (DBA), an application developer, a power user, or a technical decision maker. Regardless of your role, we hope that you can use this book to discover the features in SQL Server 2008 R2 that are most beneficial to you.

You can download the ebook in XPS format here and in PDF format here.

Enjoy!

 

Tags: , , , , ,


Categories: download | ebook | sql

Attach Database với đoạn scritp mẩu

by Neon Quach 4. April 2010 17:19

Attach Database using SQL server 2005 template script

sau khi login vào SQL với quyền cao nhất, các bạn chọn Template Explorer bằng cách nhấn vào Menu Vews >> Template Explorer Ctrl + Alt + T).

Attach Database với đoạn scritp mẩu


 Để attach DB chúng ta chọn đoạn script attach database mẫu như sau :



Có thể SQL yêu cầu lại quyền login, chúng ta điền vào và tiếp tục công việc attach.

Để đặt tên cũng như đường dẩn mà database của chúng ta cư ngụ, thay vì gỏ bằng tay, chúng ta có thể dể dàng cung cấp nhưng thông tin đó thông qua menu : Query → Specify Values for template parameters ...(Ctr + Shift + M).



 Điền vào tên CSDL muốn attach và đường dẫn vật lý tuyệt đối của CSDL:

Sau đó Click OK và nhấn F5 để thực thi .

Tags:


Categories: sql

Select random các records từ database

by code2code 28. January 2010 15:07

Đôi khi lập trình bạn vẫn thường gặp trường hợp phải xử lý vấn đề trên. Ví dụ: Lấy ngẫu nhiên danh sách câu hỏi sử dụng cho chương trình thi trắc nghiệm.

Rất nhiều bạn chọn giải pháp là xử lý dữ liệu đã được lấy lên từ database.
Hôm nay mình giới thiệu các truy vấn các câu hỏi từ database:

Cách thứ nhất : dùng hàm Rand() hàm này sẽ trả về giá trị ngẫu nhiên > 0 và < 1.

Nhưng xử dụng hàm này có một bất lợi: khi bạn sử dụng trực tiếp hàm này trong câu lệnh truy vấn sẽ tạo ra một giá trị giống hệt nhau cho tất cả các records. Câu lệnh truy vấn sau :

SELECT TOP 5 ProductName, RAND() as RandomValue FROM products ORDER BY 2
SELECT RAND()


Returns result 0.7154366573674853

sẽ cho ra kết quả:

ProductName RandomValue
Alice Mutton 0.80020779549998178
Aniseed Syrup 0.80020779549998178
Boston Crab Meat 0.80020779549998178
Camembert Pierrot 0.80020779549998178
Carnarvon Tigers 0.80020779549998178

Các giải quyết là viết một funciton sử dụng hàm rand này.

Cách thứ 2: Sử dụng hàm NewID(). Hàm này khắc phục vấn đề gặp ở trên với hàm rand(). Khi bạn sử dụng trực tiếp hàm NewID trong câu lệnh select thì kết quả sẽ tạo ra các giá trị ngẫu nhiên hoàn toàn khác nhau.

SELECT TOP 5 productName FROM products ORDER BY NEWID()


kết quả chạy lần thứ nhất :

* Guaraná Fantástica
* Tunnbröd
* Ikura
* Filo Mix
* Genen Shouyu

Kết quả chạy lần thứ 2:

* Mozzarella di Giovanni
* Scottish Longbreads
* Gustaf's Knäckebröd
* Louisiana Fiery Hot Pepper Sauce
* Filo Mix

Tags: ,


Categories: sql

Microsoft SQL Server Migration Assistant for MySQL v1.0 CTP1

by Neon Quach 13. January 2010 02:04

Microsoft has made available for download a free tool designed to streamline the migration of MySQL databases to SQL Server. At the start of this week, the company began offering customers a preview version of Microsoft SQL Server Migration Assistant. According to the software giant, the Community Technology Preview of SQL Server Migration Assistant (SSMA) for MySQL v1.0 integrates seamlessly with not only SQL Server 2005, but also SQL Server 2008 and even SQL Azure. The company underlines that the migration assistant is capable of automating aspects of the migration process to SQL Server 2005 & 2008 and to SQL Azure Database from MySQL.

“SQL Server Migration Assistant for MySQL is the newest migration toolkit, others include Oracle, Sybase, Access, and an analyzer for PowerBuilder. The toolkits were designed to tackle the complex manual process customers deal with when migrating databases. In using the SQL Server Migration Assistants, customers and partners reduce the manual effort; as a result the time, cost and risks associated with migrating are significantly reduced. Our recent SSMA survey showed that 94% of SSMA downloaders would recommend the tool to others,” revealed Erika Sommer, a member of Microsoft's SQL Server marketing team.

The Microsoft SQL Server Migration Assistant is current up for grabs as a free download from Microsoft, and because the release is a CTP build, the fact that the company is not charging customers anything for the tool is understandable. However, the promise from the software giant is that the SQL Server Migration Assistant will continue to be free even after general availability in mid-2010.

“Since the SQL Server Migration Assistants for Oracle became available in June of 2005, Microsoft has seen more than a 250,000 downloads across all of the SSMAs. Motorola, Simon & Schuster, Sony Ericsson and Artesia are just a few of the customers that have downloaded and used the SQL Server Migration Assistant toolkit to move to Microsoft SQL Server,” Sommer added.

Microsoft SQL Server Migration Assistant 2008 for MySQL v1.0 CTP1 is available for download here

Microsoft SQL Server Migration Assistant 2005 for MySQL v1.0 CTP1  is available for download here.

Required:

  • Microsoft Windows Installer 3.1 or a later version.
  • The Microsoft .NET Framework version 2.0 or a later version.
  • MySQL Connector/ODBC v5.1.
  • 1 GB RAM.


Tags: , ,


Categories: mysql | sql

SQL Azure Explorer Addin for VS2010 Beta 1

by Neon Quach 1. October 2009 03:02

Johan Danforth and Dag König just released the alpha version of a (so far) small Codeplex project we’ve been working on for the last week or so – an SQL Azure Explorer Addin for Visual Studio 2010 Beta 1.

The reasons for this project are several, but mostly to learn more about VS2010, how to create addins for it, dig into SQL Azure and at the same time learn some WPF and XAML.

The addin is a VSIX package and easily installed in VS2010 by just downloading and double clicking it.

Here’s a sample screenshot of the explorer and the integrated SQL Editor:



If you got VS2010 Beta 1 and some SQL Azure databases you work with, please download and feedback. I’m sure Microsoft will eventually support SQL Azure in the built-in server explorer, but as I said, this is for fun (it’s great fun to code addins) and the code might be useful for other future projects :)

Reference

Tags:


Categories: sql | tools | visual studio 2010 | visual studio add-in

Publish CSDL cục bộ sử dụng Data Publish Wizard

by Neon Quach 28. September 2009 02:48

Publish CSDL cục bộ sử dụng Data PublishWizard

Giới thiệu

Như 1 người phát triển web, mình hay làm việc với dử liệu trên local (máy cục bộ) trước khi đưa chúng lên mạng (go live), và 1 trong những giai đoạn cuối của việc test trên local là đưa database cũng như data của nó lên host.

Mình hay dùng tiện ích Data Publish Winzard, 1 tiện ích mà khi cài Visual Studio 2008.

Cách thực hiện

Note: Data Publish Winzard có thể cài đặt riêng lẻ phiên bản chạy độc lập.

1. Khởi động VS
2. View 
Server Explorer
3. Data Connection 
Add Connection



4. Chọn Provider là Microsoft Sql Server.
5. Add Northwind Connectin



6. Chọn database 
Publish to provider






7. Chọn database Northwind



Uncheck Script all objects in the selected database, nếu muốn tùy chọn các đối tượng được publish.

8. Chọn location



9. Chọn schema option



Chú ý: type of data to publish ở đây có 3 tùy chọn:
- Data only: chỉ publish data (generate insert script)
- Schema and data: Cấu trúc database và dữ liệu.
- Schema only: chỉ publish cấu trúc.

Next 
finished



Xong, giờ thì các bạn có thề dùng sql script này chạy trên database server.



Reference

Tags: ,


Categories: sql | vs .net

Microsoft WebSite Spark

by Neon Quach 25. September 2009 04:24

Microsoft supporting web startups and independent web developers by providing free software's for 3years

Microsoft has launched today a very exciting program called WebSiteSpark for individual developers and small web startup companies having less than 10 employees.

Given below are few software licenses which will be given free to you for 3 years

  • 3 licenses of Visual Studio 2008 Professional Edition
  • 1 license of Expression Studio 3 (which includes Expression Blend, Sketchflow, and Web)
  • 2 licenses of Expression Web 3
  • 4 processor licenses of Windows Web Server 2008 R2
  • 4 processor licenses of SQL Server 2008 Web Edition
  • DotNetPanel control panel (enabling easy remote/hosted management of your servers)

IMHO it is very good initiative by Microsoft to promote small companies and individuals to leverage their products and build next generation application on the web.

More information can be found here

http://weblogs.asp.net/scottgu/archive/2009/09/24/announcing-the-websitespark-program.aspx

http://www.microsoft.com/web/WebSiteSpark

 

Tags:


Categories: general | sql | vs .net

Powered by BlogEngine.NET 1.6.0.0 - Eco Theme by n3o Web Designers