Monday, April 18, 2011

How to drop all procedures

USE databasename
GO

declare @procName sysname

declare someCursor cursor for
select name from sysobjects where type = 'P' and objectproperty(id, 'IsMSShipped') = 0

open someCursor
fetch next from someCursor into @procName
while @@FETCH_STATUS = 0
begin
exec('drop proc ' + @procName)
fetch next from someCursor into @procName
end

close someCursor
deallocate someCursor
go

Wednesday, April 13, 2011

Windows Azure basics and its uses



Introduction

Windows azure is cloud computing OS. It mainly contains three components namely windows azure, windows Fabric and Windows azure SQL. It can be compared with cloud computing provided by Amazon but there are some basic difference with Amazon cloud computing. Amazon has provided basic platform for cloud computing but Microsoft Azure has provided basic platform along with basic services so developer can focus only their task rather than peripheral areas.

Areas of windows azure are:
- Web roles, data storage, worker role
Window azure – compute and storage in the cloud
SQL Azure – relational database in the cloud
.Net Services – Web based services e.g. Connectivity and access control
http://azure.snagy.name/blog/?p=176
http://azure.snagy.name/blog/?p=26

Download SDK for visual studio

http://www.microsoft.com/windowsazure/getstarted/default.aspx

Get Free Test Windows Azure server
For one month without credit card information
http://www.windowsazurepass.com/?campid=9FE3DB53-E4F0-DF11-B2EA-001F29C6FB82
Free subscription up to June
http://www.microsoft.com/windowsazure/free-trial/

How to create self assigned certificate for Windows Azure portal

1. Load the IIS 7 management console. I’m assuming here you have IIS7 installed since its required for the Windows Azure SDK.
2. Click on your Server.
3. Double Click Server Certificates in the IIS Section in the main panel.
4. Click Create Self-Signed Certificate… in the Actions panel.
5. Give it a Friendly Name.
6. Close IIS Manager.
7. Open Certificate Manager (Start->Run->certmgr.msc)
8. Open Trusted Root Certification Authorities, then Certificates.
9. Look for your certificate (Tip: Look in the Friendly Name column).
10. Right Click your certificate, then choose All Tasks, then Export…
11. In the Wizard, choose No, do not export the private key, then choose the DER file format.
12. Give your cert a name. (remember to call it something.cer).
13. Navigate to the Windows Azure Portal – http://windows.azure.com
14. Click the Account Tab, then click Manage My API Certificates.
15. Browse to the certificate file you created earlier and upload it.
16. Done!
(Ref: http://www.davidaiken.com/2009/12/21/how-to-create-a-x509-certificate-for-the-windows-azure-management-api/ )

Windows migration wizard from SQL Server to SQL Azure

http://sqlazuremw.codeplex.com/releases/view/32334
(download and run its exe file)

Connect SQL Azure via SQL Server management studio

Use the same way as in SQL server
1. Server name: Azure server name
2. Username: SQL azure user name
3. Password: SQL azure password
4. Use TCP/IP protocol, and put specific database name extending option of login window

OPENXML() and Nodes()

SQL Azure does not support OPENXML() but we have better alternative of it. Nodes() is good alternative.
Example:
DECLARE @xml xml
SET @xml = N'

CustomerNo123
CustomerNo321
CustomerNo555


SELECT
doc.col.value('Key[1]', 'NVARCHAR(200)') ponumber,
doc.col.value('Val[1]', 'NVARCHAR(MAX)') podate
FROM @xml.nodes('Parameter/Collection/Row') doc(col)