A blog about SQL Server, Books, Movies and life in general
Tuesday, April 10, 2007
Script Multiple Procs With Create And Drop Statements In SQL Server 2005
This is what you have to do:
1. Open you favorite database in the management studio.
2. Make sure the summary window is visible. (Press F7)
3. In the summary window, double click databases.
4. Double click 'YourDatabase'
5. Double Click 'Programability'
6. Double Click 'Stored Procedures'
7. Select the stored procedures you want to script. (using CTRL/SHIFT clicking).
8. Right click -> Script Stored Procedures As -> Drop -> New Query Editor Window.
Repeat step 8 for the Create.
Who wants to do that? Not me.
Here is a pure T-SQL solution, I didn't feel like using SMO. I can just run this code, copy and paste the output in a new window and I am done.
This code takes care of schema's it also grabs just procedures and only the ones that are created by users (OBJECTPROPERTY 'IsMSShipped' takes care of that)
USE AdventureWorks
GO
SET NOCOUNT ON
CREATE TABLE #ProcHolder (ID int identity,ProcName VARCHAR(8000), ProcDefinition VARCHAR(MAX))
INSERT #ProcHolder
SELECT QUOTENAME(SPECIFIC_SCHEMA) + '.' + QUOTENAME(SPECIFIC_NAME),OBJECT_DEFINITION(OBJECT_ID(QUOTENAME(SPECIFIC_SCHEMA) + '.' + QUOTENAME(SPECIFIC_NAME)))
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE = 'PROCEDURE'
AND OBJECTPROPERTY(OBJECT_ID(QUOTENAME(SPECIFIC_SCHEMA) + '.' + QUOTENAME(SPECIFIC_NAME)),'IsMSShipped') = 0
--SELECT * FROM #ProcHolder --if you want to test
DECLARE @LoopID int,@MaxLoopID int,@ProcDefinition VARCHAR(MAX),@ProcName VARCHAR(8000)
SELECT @LoopID =1,@MaxLoopID = MAX(id) FROM #ProcHolder
WHILE @LoopID < @MaxLoopID
BEGIN
SELECT @ProcDefinition = ProcDefinition,@ProcName =ProcName
FROM #ProcHolder
WHERE id = @LoopID
PRINT 'if exists (select * from dbo.sysobjects where id = OBJECT_ID(N''' + @ProcName + ''') and OBJECTPROPERTY(id, N''IsProcedure'') = 1)'
PRINT 'drop procedure ' + @ProcName
PRINT 'GO'
PRINT ''
PRINT ''
PRINT @ProcDefinition
PRINT 'GO'
PRINT ''
PRINT ''
SET @LoopID = @LoopID +1
END
DROP TABLE #ProcHolder
That is it, let me know what you think
Monday, April 09, 2007
Sopranos: Bobby Baccalla beats the crap out of Tony Soprano
Janice is one of those people you just cannot stand; I hate her with a passion. They way she acts towards the baby sitter is just plain wrong. BTW it was Tony’s birthday yesterday and he got golf clubs as a present among other things ;-). Yesterday was also my birthday but I did not get any golf clubs ;-(. But then again I don’t play golf or will ever play golf since it seems so boring to me. What is the point? Hit a ball then walk for 15 minutes and hit another ball, golf is not a sport I don’t care what they say otherwise.
Back to the Sopranos, I hope the other episodes are as good as the one from yesterday. Remember last season? The first episode was good; Tony got shot by Uncle Junior. Then the next episode went into the coma/dream nonsense and it was all down the hill after that.
Sunday, April 08, 2007
The Real Microsoft Vista Marketing
Thursday, April 05, 2007
Two New Hotfixes Available To Fix The Maintenance Plan Issues Caused By SQL Server 2005 SP2
SELECT @@VERSION.
If the SQL Server 2005 version is between 3042 and 3053, download build 3054 from http://support.microsoft.com/kb/934458
If the SQL Server 2005 version is between 3150 and 3158, download build 3159 from http://support.microsoft.com/kb/934459
Monday, April 02, 2007
April 8th Is Almost Here
1) My Birthday
2) Final season of Sopranos starts
3) New season of Entourage starts
4) Easter
So finally the Sopranos will end ;-( I must admit that the last season wasn’t that great, the episode in which Tony had that crazy dream with that suitcase was just horrible. Watch out for the ducks in the last episode (remember the ducks in the first episode? They will be back and we've come full circle with the show)
I did not start watching Entourage until last season, since then I have watched all the episodes (thank you Comcast on demand). Jeremy Piven (Ari Gold) and Kevin Dillon (Johnny "Drama" Chase) are my favorite characters.
Easter, oh yes the day that I have to go to Church with my wife (I made a wedding day promise). My older son will have a lot of fun with all the eggs/chocolates and gifts that the Easter Bunny will bring
It is also my birthday on April 8th, I will be getting closer to midlife crisis. I will turn 37 that day, wait isn’t 37 the new 27?
Sunday, April 01, 2007
SQL Server 2007 Beta1 CTP Released
A ton of new things, support for spatial data. New functions to deal with numeric data (IsInt, IsBigInt, IsSmallInt). Also new is the addition of Natural Join, a bunch of new dynamic management views that make it easier to prevent deadlocks. Another cool thing is the addition of the new BigDateTime datatype, this makes it possible to enter dates before 1753, you can actually go back to -3000. That is such a big plus for databases that deal with data that's older than 1753. What are you waiting for? Download it here now
Friday, March 30, 2007
SQL Server 2005 Books Online Scoped Search Provided By search.live.com
http://search.live.com/macros/sql_server_user_education/booksonline
Thursday, March 29, 2007
TEMPDB and SQL Server 2005 Tip
This will make a big difference, SQL Server 2005 uses the tempdb different than 2000, by adding more files you will see a dramatic performance improvement for big queries
Our queries on SQL Server 2005 ran slower than on 2000, by adding more files the queries are twice as fast than on the SQL Server 2000 box now
This behaviour is documented here: http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/storage-top-10.mspx
Look at number 7 (Consider configuration of TEMPDB database)
and number 8 (Lining up the number of data files with CPU’s has scalability advantages for allocation intensive workloads. )
Wednesday, March 28, 2007
A list of SQL Server 2005 Whitepapers and SQL Server 2000 Whitepapers
Get them all here: http://www.sqlskills.com/whitepapers.asp
Sunday, March 25, 2007
How Not To Do Search Engine Optimization
" Google controls 50% of the world's searches. This famous website is so controversial that it has been banned by the most popular search engine in the world 'Google'. That's right. You cannot find alexchiu.com in Google system. Some very important people don't want you to know about Alex Chiu. Alex Chiu is on more than 30 TV interviews, 250 radio interviews, and in business ever since 1996. Yet AlexChiu.com cannot show up on Google? "
Why is that? Very simple, take a look at his site http://alexchiu.com/
At the bottom of the page you will find a text area with over a thousand keywords, some of these keywords are:
System Heart Aorta Arteries Arterioles Capillaries Venules Veins Vena cava Pulmonaryarteries Lungs veins Blood Digestive Mouth Pharynx Esophagus Stomach Pancreas Gallbladder
This list goes on and on.
End result? Banned by Google.
Saturday, March 24, 2007
SQL Server 2005 SP2 Has Added The OBJECT_SCHEMA_NAME Function, OBJECT_NAME Has Been Enhanced
The OBJECT_SCHEMA_NAME metadata function can be used to return the schema name of a schema-scoped object like a table or a view by specifying the object identifier and optional database identifier.
Read more about these 2 functions here, there is also SQL code available that show you how to use the functions on the site.
30 + Tools and Hacks for Gmail
Link: http://www.makeuseof.com/tag/gmail-craze-30-tools-to-make-your-gmail-better/
Thursday, March 22, 2007
Microsoft SQL Server Samples and Community Projects On CodePlex
Link: http://www.codeplex.com/SqlServerSamples
Make sure you check out the DBScript Utility
The Ten Most Asked SQL Server Related Programming Questions In Newsgroups
That is why I will create a blogpost that lists these ten questions and also provides an answer for them. I think that to write this will take me about a week.
Here is what I have so far
1 selecting only current day/yesterday from a table
2 adding days/weeks/years/months to dates
3 splitting string values
4 select * from one table that doesn't exist in another table
5 getting all rows from one table and only the latest from the child table
6 getting all characters until some character (charindex + left)
7 NULL stuff ( a bunch of stuff here dealing with nulls)
8 Row values to column (PIVOT)
9 Show 0001 as 1 and show 1 as 0001
10 CASE and checking for NULLs
I guess I could have added date display formatting. Did I miss any other obvious questions?
Wednesday, March 21, 2007
SQL Server Speaks Almost As Many Languages As I Do
Error Code: 4860
Cannot bulk load. The file "%ls" does not exist.
Massenladen ist nicht möglich. Die Datei "%1!" ist nicht vorhanden.
Chargement en bloc impossible. Le fichier "%1!" n'existe pas.
???????????????? "%1!" ???????? No se puede realizar la carga masiva......
This is the first time that I have seen a multi-language error. It appears that SQL Server 2005 is a multi-language 'speaker'.
So we have 4 languages in this error
English
Cannot bulk load. The file "%ls" does not exist.
German
Massenladen ist nicht möglich. Die Datei "%1!" ist nicht vorhanden.
French
Chargement en bloc impossible. Le fichier "%1!" n'existe pas.
Spanish
???????????????? "%1!" ???????? No se puede realizar la carga masiva (don't know what the deal is with those question marks, probabaly a missing font)
So I speak 2 of these languages and 2.5 other languages and also a dialect. But I can curse in many more ;-)
Tuesday, March 20, 2007
Microsoft Joins OpenAjax
"Microsoft is joining the OpenAJAX Alliance to collaborate with other industry leaders to help evolve AJAX-style development by ensuring a high degree of interoperability," said Keith Smith, group product manager of the Core Web Platform & Tools to UX Web/Client Platform & Tools team at Microsoft Corp. "By joining OpenAJAX, Microsoft is continuing its commitment to empower Web developers with technology that works cross-browser and cross-platform."
The newest OpenAjax Alliance members include: 24SevenOffice, ActiveGrid, ActiveState, Appeon, Aptana, Arimaan Global Consulting, Custom Credit Systems (Thinwire), ESRI, Getahead (DWR), Global Computer Enterprises, GoETC, Helmi Technologies, HR-XML, iPolipo, Isomorphic Software, JSSL, Lightstreamer, Microsoft, MobileAware, NetScript Technologies, OpenSpot, OpenSymphony (OpenQA), OpSource, OS3.IT, Redmonk, Tealeaf Technology, Teleca Mobile, Transmend, Visible Measures, Visual WebGui and Volantis Systems.
The Alliance is also announcing that the following members have all been awarded OpenAjax Interoperability certificates: Apache XAP, Dojo Foundation, ICEsoft, ILOG, Isomorphic, IT Mill, Lightstreamer, Open Link, Open Spot, Nexaweb, Software AG and TIBCO. The interoperability certificates represent progress by both OpenAjax Alliance and its members towards defining and achieving industry support for OpenAjax Conformance.
Read the press release here: http://www.marketwire.com/mw/release_html_b1?release_id=228535
Perfect SQL Developer Setup
Got this pic in the mail today. I have been working with a dual-monitor setup since 2001 but this is unquestionably better. Here is how I would use it.
Monitor1: Outlook, Word and Excel
Monitor2: Production SQL Servers
Monitor3: Staging and Development SQL Servers
Monitor4: Visual Studio, EditPlus, XML Spy, Sybase Power Designer, Visio, SQL Compare etc etc
You see, all work and no fun (makes Jack a dull boy)
Very SQLicious don’t you think? How would you use it?
Saturday, March 17, 2007
St. Patrick's Day Joke: Irish Daughter
The girl, crying, replied, "Sniff, sniff... dad... I became a prostitute..."
Ye what!!? Out of here, ye shameless harlot! Sinner! You're a disgrace to this family."
OK, dad-- as ye wish. I just came back to give mum this luxurious fur coat, title deed to a ten bedroom mansion plus a savings certificate for $5 million. For me little brother, this gold Rolex and for ye daddy, the sparkling new Mercedes limited edition convertible that's parked outside plus a membership to the country club....(takes a breath). ... and an invitation for ye all to spend New Years Eve on board my new yacht in the Riviera, and..."
Now what was it ye said ye had become?" says dad.
Girl, crying again, "Sniff, sniff.... a prostitute dad! Sniff, sniff."
Oh! Be Jesus! Ye scared me half to death, girl! I thought ye said a Protestant'. Come here and give yer old man a hug!"
Google Buys Gapminder
GeoHive - the World in Regions
Nationmaster
OECD Data
Social Watch
Statistics Sweden (Satistiska Centralbyrån)
Sustainable World
The World Factbook
United Nations Common Database (UNSCB)
UNESCO Institute for Statistics
World Bank: World Development Indicators
WorldHistory.com
Don't Know What To Say In Meetings?
grow collaborative deliverables
disintermediate ubiquitous web-readiness
seize intuitive users
orchestrate integrated portals
So go ahead and give it a try: http://dack.com/web/bullshit.html
I could have sworn I saw some of these phrases in books ;-)
Thursday, March 15, 2007
Amazon Elastic Compute Cloud (Amazon EC2)
Okay we all know what Amazon Simple Storage Service (Amazon S3) is. Now there is a new service from Amazon called Amazon Elastic Compute Cloud (Amazon EC2). with S3 you use Amazon to store your data, images,whatever but with EC2 you use Amazon to do your computing for you.
From the site:
Amazon EC2 Functionality
Amazon EC2 presents a true virtual computing environment, allowing you to use web service interfaces to requisition machines for use, load them with your custom application environment, manage your network's access permissions, and run your image using as many or few systems as you desire.
To use Amazon EC2, you simply:
Create an Amazon Machine Image (AMI) containing your applications, libraries, data and associated configuration settings. Or use our pre-configured, templated images to get up and running immediately.
Upload the AMI into Amazon S3. Amazon EC2 provides tools that make storing the AMI simple. Amazon S3 provides a safe, reliable and fast repository to store your images.
Use Amazon EC2 web service to configure security and network access.
Use Amazon EC2 web service to start, terminate, and monitor as many instances of your AMI as needed.
Pay for the instance hours and bandwidth that you actually consume.
Service Highlights
Elastic
Amazon EC2 enables you to increase or decrease capacity within minutes, not hours or days. You can commission one, hundreds or even thousands of server instances simultaneously. Of course, because this is all controlled with web service APIs, your application can automatically scale itself up and down depending on its needs.
Completely Controlled
You have complete control of your instances. You have root access to each one, and you can interact with them as you would any machine. Each instance predictably provides the equivalent of a system with a 1.7Ghz x86 processor, 1.75GB of RAM, 160GB of local disk, and 250Mb/s of network bandwidth.
Designed for use with Amazon S3
Amazon EC2 works in conjunction with Amazon Simple Storage Service (Amazon S3) to provide a combined solution for computing and storage across a wide range of applications.
Reliable
Amazon EC2 offers a highly reliable environment where replacement instances can be rapidly and reliably commissioned. The service runs within Amazon's proven network infrastructure and datacenters.
Secure
Amazon EC2 provides web service interfaces to control network security. You define groups of instances and their desired accessibility.
Inexpensive
Amazon EC2 passes on to you the financial benefits of Amazon's scale. You pay a very low
rate for the compute capacity you actually consume. Compare this with the
significant up-front expenditures traditionally required to purchase and
maintain hardware, either in-house or hosted. This frees you from many of the
complexities of capacity planning, transforms what are commonly large fixed
costs into much smaller variable costs, and removes the need to over-buy "safety
net" capacity to handle periodic traffic spikes.
Get all the details here: http://www.amazon.com/gp/browse.html?node=201590011
Online Indexing Operations in SQL Server 2005 Whitepaper Available For Download
Included in this document:
• Introduction
• Data Structures and Concepts
• Overview of the Online Index Build Algorithm
• Capacity Planning and Concurrency Considerations for Index Create and Rebuild Operations
• Online Index Best Practices
• Conclusion
• Appendix A: Performance Study
• Appendix B: Diagnostics
• Appendix C: Log Measurement Script
• Appendix D: Online Index Limitations
Download this whitepaper (Word doc,25 pages) here: http://www.microsoft.com/technet/prodtechnol/sql/2005/onlineindex.mspx
Did You Have Your Pie On Pi Day?
March 14th is Pi Day as the date 3/14 corresponds to the mathematical number pi.
The mathematical constant π is a transcendental (and therefore irrational) real number, approximately equal to 3.14159, which is the ratio of a circle's circumference to its diameter in Euclidean geometry, and has many uses in mathematics, physics, and engineering. It is also known as Archimedes' constant and as Ludolph's number
Here are the first 100 digits of PI
3.
1415926535 8979323846 2643383279 5028841971 6939937510 5820974944 5923078164 0628620899 8628034825 3421170679 8214808651
Wednesday, March 14, 2007
GMail Storage Will Be 3560 MB on April 1st 2012
What to expect in the future:
2835 MB on April 1st 2007
2980 MB on April 1st 2008
3125 MB on April 1st 2009
3270 MB on April 1st 2010
3415 MB on April 1st 2011
3560 MB on April 1st 2012
As you can see, Gmail's storage will increase with 145 MB a year. Great for storing all that spam. Now I wish they could increase the message size to 20MB from the current 10MB.
More detail here: http://googlesystem.blogspot.com/2007/03/gmails-updated-quotas.html
How To Get The Database Name For The Current User Process
First up is the fastest method. this will run on SQL Server 200 and 2005
SELECT DB_NAME()
Next up is getting the name by joining the sys.dm_exec_requests dmv and sys.sysdatabases. this runs on SQL Server 2005 only
SELECT s.name
FROM sys.dm_exec_requests d
JOIN sys.sysdatabases s on d.database_id = s.dbid
WHERE session_id = @@SPID
Here is something similar, this also runs only on SQL Server 2005
SELECT name
FROM sys.sysdatabases
WHERE dbid = DB_ID()
And we end with something that runs on both SQL Server 2005 and 2000
SELECT name
FROM master..sysdatabases
WHERE dbid = DB_ID()
But like I said before you should always use DB_NAME()
SQL Server 2005 Performance Dashboard Reports Available For Download
Common performance problems that the dashboard reports may help to resolve include:
- CPU bottlenecks (and what queries are consuming the most CPU)
- IO bottlenecks (and what queries are performing the most IO).
- Index recommendations generated by the query optimizer (missing indexes)
- Blocking
- Latch contention
The information captured in the reports is retrieved from SQL Server's dynamic management views. There is no additional tracing or data capture required, which means the information is always available and this is a very inexpensive means of monitoring your server.
Reporting Services is not required to be installed to use the Performance Dashboard Reports.
Keep in mind that the SQL Server instance being monitored must be running SP2 or later.
So what are you waiting for? dowmload it and read the details here: http://www.microsoft.com/downloads/details.aspx?FamilyId=1D3A4A0D-7E0C-4730-8204-E419218C1EFC&displaylang=en
R.I.P Visual FoxPro
Die, die, die my darling
Dont utter a single word
Die, die, die my darling
Just shut your Foxy eyes (I replaced pretty with Foxy)
So for all you FoxPro lovers, there is a great new site (so there is hope for you ;-)) VFP-Conversion
Think Outside the Fox-Den!
Monday, March 12, 2007
map of the world, based on the frequency of its locations mentioned in books.
We've all seen views of the Earth from space, where the numerous pinpoints of light on the ground combine to yield a speckled map of the world. I wanted to show the Earth viewed from books, where individual mentions of locations in books combine to yield another interpretation of the globe. The intensity of each pixel is proportional to the number of times the location at a given set of coordinates is mentioned across all of the books in Google Books Search.
Here is the link: http://booksearch.blogspot.com/2007/03/earth-viewed-from-books.html
Saturday, March 10, 2007
Wladimir Klitschko Knocks Out Ray Austin In The Second Round
Scribd: The YouTube Of Documents
Scribd lets you publish and discover documents online. It is like a big online library where anyone can upload. We make use of a custom Flash document viewer that lets you display documents right in your Web browser. There are all sorts of other features that make it easy and fun to publish, convert, embed, analyze, and read documents.
Part of the idea behind Scribd is that everyone has a lot of documents sitting around on their computers that only they can read. With Scribd we hope to unlock this information by putting it on the web.
What kinds of documents can I publish on Scribd?
Literally, anything you can put in a Word (.doc), PDF (.pdf), text (.txt), PowerPoint (.ppt), Excel (.xls), Postscript (.ps), or LIT (.lit) file.
So go ahead and check it out: http://www.scribd.com/
Windows Server 2003 Service Pack 2 x64 Edition Release Candidate Available For Download
Windows Server 2003 SP2 can be installed directly on the following operating systems:
Windows Server 2003 Editions (All 32-bit x86)
Windows Server 2003 Itanium-based Editions
Windows Server 2003 x64 Editions
Windows Server 2003 R2 Editions
Windows Server 2003 Storage Server R2 Edition
Windows Server 2003 Compute Cluster Edition
Windows Small Business Server 2003 R2
Windows XP Professional x64 Edition
Download it here: http://www.microsoft.com/downloads/details.aspx?familyid=AC8EDD44-96B3-4D11-9293-12970CD62FED&displaylang=en
Friday, March 09, 2007
how to save a whole heap of money on SQL Server 2000 licenses
An insurance company decides to install the trial version of SQL server 2000 on their production box because they don't want to pay the license. After 6 months they backup all the data, wipe out the hard drive (reimage) and install the trial version again, restore all the databases and are good to go for another 6 months...ROFL
Why not just use developer edition? You are violating the license anyway, it will at least save you the hassle of reinstalling every 6 months...
Link to original article is here http://worsethanfailure.com/Articles/SQL_on_Trial.aspx
Thursday, March 08, 2007
Can you solve Joe Celko's SQL puzzles? Three puzzles. Many answers.
These are the puzzles:
Puzzle 1: FISCAL YEAR TABLES
Answer #1
Puzzle 4: SECURITY BADGES
Answer #1
Answer #2
Puzzle 9: AVAILABLE SEATS
Answer #1
Answer #2
Answer #3
Answer #4
Answer #5
the site has individual links to each puzzle and answer, the link to the puzzles is here: http://www.computerworld.com/action/article.do?command=viewArticleBasic&articleId=9012350&source=NLT_APP&nlid=48
Let me know what you think and if you can come up with better/different answers.
Wednesday, March 07, 2007
Visual Studio 2005 Service Pack 1 Update for Windows Vista Available For Download
Brief Description
The Visual Studio 2005 Service Pack 1 Update for Windows Vista addresses areas of Visual Studio impacted by Windows Vista enhancements.
Overview
If the machine participated in the Visual Studio 2005 Service Pack 1 Update for Windows Vista Beta, please be sure to uninstall the beta first.
During the development of Windows Vista, several key investments were made to vastly improve overall quality, security, and reliability from previous versions of Windows. While we have made tremendous investments in Windows Vista to ensure backwards compatibility, some of the system enhancements, such as User Account Control, changes to the networking stack, and the new graphics model, make Windows Vista behave differently from previous versions of Windows. These investments impact Visual Studio 2005. The Visual Studio 2005 Service Pack 1 Update for Windows Vista addresses areas of Visual Studio impacted by Vista enhancements.
Many of the Windows Vista enhancements are documented at the Windows Vista Development Center.
This download installs the Visual Studio 2005 Service Pack 1 Update for Windows Vista for the following Visual Studio SKUs:
Microsoft Visual Studio 2005 Tools for Office
Microsoft Visual Basic 2005 Express Edition
Microsoft Visual C++ 2005 Express Edition
Microsoft Visual C# 2005 Express Edition
Microsoft Visual J# 2005 Express Edition (English Only)
Microsoft Visual Web Developer 2005 Express Edition
Microsoft Visual Studio 2005 Premier Partner Edition
Microsoft Visual Studio 2005 Professional Edition
Microsoft Visual Studio 2005 Standard Edition
Microsoft Visual Studio 2005 Team Edition for Software Architects
Microsoft Visual Studio 2005 Team Edition for Software Developers
Microsoft Visual Studio 2005 Team Edition for Software Testers
Microsoft Visual Studio 2005 Team Suite
Microsoft Visual Studio 2005 Team Test Load Agent
Microsoft Visual Studio 2005 Team Test Load Controller
Microsoft Visual Studio 2005 Code Profiler
Microsoft Visual Studio 2005 Team Explorer
Tuesday, March 06, 2007
SQL Server 2005 Service Pack 2a?
.NET Rocks Podcast: Paul Randal on SQL Server 2005 Performance and Recovery
"Microsoftee Paul Randal drops by for an engaging talk about his contributions
to the recoverability of SQL Server 2005, which are many (Can you say CHECKDB?).
An old friend of ours, and a fairly new friend of Paul's, busts in on the
conversation and makes a cameo appearance. "
Download the podcast here:http://dotnetrocks.com/default.aspx?showID=220
Monday, March 05, 2007
How To Make A FileGroup Read Only in SQL Server 2005
How to make a filegroup read only in SQL Server 2005? This question popped up today on tek-tips. This is how you do that: First we will create a new database named TestFilegroup. Next we will add a filegroup named Test1FG1 which contains a file named test1dat3.
The next step is to do an alter database modift filegroup readonly command
Here is the complete script
USE master
go
--Create New DB For Testing
CREATE DATABASE TestFilegroup
go
--Create FileGroup
ALTER DATABASE TestFilegroup
ADD FILEGROUP Test1FG1;
--Add file to fileGroup
ALTER DATABASE TestFilegroup
ADD FILE
(
NAME = test1dat3,
FILENAME = 'c:\t1dat3.ndf',
SIZE = 5MB,
MAXSIZE = 100MB,
FILEGROWTH = 5MB
)
TO FILEGROUP Test1FG1
--Make FileGroup ReadOnly
ALTER DATABASE TestFilegroup
MODIFY FILEGROUP Test1FG1 Read_Only;
Use Read_Only not ReadOnly because the keyword READONLY will be removed in a future version of Microsoft SQL Server. Avoid using READONLY in new development work, and plan to modify applications that currently use READONLY. Use READ_ONLY instead.
Now what happens when you try to create a table on filegroup Test1FG1?
USE TestFilegroup
GO
CREATE TABLE abc (id INT) ON Test1FG1
You will see the following error message
Server: Msg 1924, Level 16, State 2, Line 1
Filegroup 'Test1FG1' is read-only.
You can use sys.filegroups and check the is_read_only column to find out if a filegroup is read only
SELECT is_read_only
FROM sys.filegroups
WHERE name = 'Test1FG1'
Here is the result
is_read_only
------------
1
Using NTFS Compression with Read-Only User-defined Filegroups and Read-Only Databases
SQL Server 2005 supports NTFS compression of read-only user-defined filegroups and read-only databases. You should consider compressing read-only data in the following situations:
You have a large volume of static or historical data that must be available for limited read-only access.
You have limited disk space.
ASP.NET Library Site Launched
Applications
Controls
Database
HTML
So go ahead and check it out: http://aspnetlibrary.com/
Sunday, March 04, 2007
Arrays and Lists Article Updated For SQL Server 2005
Friday, March 02, 2007
The Digg Effect
Here is a graph of the pageviews
I promise that I WILL write a SQL post this weekend and it will be about partitioned functions It will show you how you can use $PARTITION to select data from a specific partition
Top 5 Post and Google Searches For Jan and Feb 2007
1 The Sysinternals Troubleshooting Utilities have been rolled up into a single Suite of tools
2 Ten SQL Server Functions That You Hardly Use But Should
3 Clippy Is Not Dead, Clippy Is Alive.....On Linux
4 Increase Your Productivity With Query Analyzer
5 The Real Reason Why Condoleezza Rice Never Smiles
So two of these (Clippy and Condoleezza) have nothing to do with SQL Server.
Top Queries
These are searches that people typed in the Google search box on this site
I always keep track of these because it gives me some ideas of what to write
Here is the top list for the last 2 months, I left out the adult searches ;-)
None
did france pay brazil to win the cup
NotMyFault
query analyzer not view
sql login
saltrain
notmyfault
%disk read time
defrag
daylight saving SQL Express
maximum number database
openrowset
SQL queries
tree structure catalogue
rainbowfish children book
failed for login sa
jacobs
sysinternals
origin of the name jacobs
Top Ten Posts Of All Time
1 The Sysinternals Troubleshooting Utilities have been rolled up into a single Suite of tools
2 SQL Query Optimizations
3 Ten SQL Server Functions That You Hardly Use But Should
4 Five Ways To Return Values From Stored Procedures
5 Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection. SQL 2005
6 Clippy Is Not Dead, Clippy Is Alive.....On Linux
7 NULL Trouble In SQL Server Land
8 COALESCE And ISNULL Differences
9 Increase Your Productivity With Query Analyzer
10 Three Ways To Display Two Counts From a Table Side By Side
How Do I? video series focused on SQL Server 2005 Express
So what is in this series?
#1 What is a Database?
(28 minutes, 15 seconds)
#2 Understanding Database Tables and Records
(24 minutes, 56 seconds)
#3 More about Column Data Types and Other Properties
(21 minutes, 37 seconds)
#4 Designing Relational Database Tables
(34 minutes, 10 seconds)
#5 Manipulating Database Data
(40 minutes, 20 seconds)
#6 More Structured Query Language
(23 minutes, 13 seconds)
#7 Understanding Security and Network Connectivity
(40 minutes, 59 seconds)
#8 Connecting your Web Application to SQL Server 2005 Express Edition
(1 hour, 5 minutes)
#9 Using SQL Server Management Studio
(40 minutes, 26 seconds)
#10 Getting Started with Reporting Services
(32 minutes, 51 seconds)
#11 Building and Customizing Reports in Business Intelligence Development Studio
(44 minutes, 50 seconds)
#12 Creating and Using Stored Procedures
(42 minutes, 34 seconds)
#13 Enabling Full-Text Search in your Text Data
(38 minutes, 25 seconds)
You can download all of these here: http://www.asp.net/learn/videos/default.aspx?tabid=63#sql
Enjoy
Wednesday, February 28, 2007
Visual Studio Code Name "Orcas" - March 2007 Community Technology Preview (CTP) Available For Download
From the site:
Visual Studio code name “Orcas” delivers on Microsoft’s
vision of smart client applications by enabling developers to rapidly create
connected applications that deliver the highest quality rich user experiences.
This new version enables any size organization to rapidly create more secure,
manageable, and more reliable applications that take advantage of Windows Vista
and the 2007 Office System. By building these new types of applications,
organizations will find it easier than ever before to capture and analyze information
so that they can make effective business decisions.
This download is the March 2007 Community Technology Preview of Microsoft
Visual Studio Code-Named “Orcas”. This CTP is available in English only.
Note: This CTP is available as a Virtual
PC image or as a self-extracting install. If you wish to use the Virtual PC
image you will need Virtual PC or Virtual Server to run this image. If you wish
to use the self extracting install, we advise that you do not install this on a
production machine. Depending on your hardware the download files make take
between 30-60 minutes to decompress.
This CTP targets early adopters of the Microsoft technology, platform, and
tools offerings. It enables developers to experience the upcoming toolset and
underlying platform improvements. We designed this release to enable developers
to try out new technology and product changes, but not to build production
systems. This limitation is fully covered in the EULA that accompanies this
CTP.
The highlights of this CTP include:
- LINQ
The LINQ Project: this CTP represents a major milestone in the LINQ
project. For more information about LINQ click here.
- VB 9.0 Language
Support: This CTP contains the following language features: - Query Expressions:
Basic querying, filtering, and ordering support - Object Initializers
- Extension Methods
- Local Variable Type
Inference - Anonymous Types
- XML literals
- XML properties
- New Line and
Expression IntelliSense - C# 3.0 Language
Support: This CTP implements all of the C#3.0 language features from the
May LINQ CTP including: - Query Expressions
- Object and Collection
Initializers - Extension Methods
- Local Variable Type
Inference and Anonymous Types - Lambdas bound to
Delegates and Expression trees - Complete design-time
support: Intellisense, Formatting, Colorization - LINQ to ADO.NET
- ADO.NET is fully
integrated with LINQ and offers many options for using LINQ in various
scenarios: LINQ to SQL provides direct access to database tables from
the programming environment, LINQ to Entities enables developers to use
LINQ over EDM models, and LINQ to DataSet allows the full expressivity
of LINQ to be used over DataSets. - LINQ to Entities
enables developers to program against a relational database using a view
of the data that is appropriate for the application they are building,
independent of the structure of the underlying database. The use of the
Entity Data Model (EDM) enables developers to design models that follow
the concepts built into the application, instead of having to map them
to constructs available in relational stores. LINQ to Entities is built
on the ADO.NET Provider model and will support working against different
back end relational stores in addition to Microsoft SQL Server. This CTP
includes a LINQ to Entities provider for SQL Server and SQL Server
Compact Edition. - LINQ to SQL (previous
name DLinq) has enhanced the functionality from the May 2006 LINQ CTP.
You can find it in System.Data.Linq namespace in System.Data.Linq.dll.
New in this release is that DataContext provides optimized modes for
read-only use and serialization . Also new is that DataShape streamlines
eager loading capabilities and adds the ability to set queries on
relationships - LINQ To SQL Designer
- Methods can be created
from stored procedures and functions within the designer. - Better handling of
database schemas. - Improved inheritance
support in the designer. - LINQ over XML (XLinq)
- System.Xml Bridge
Classes added – There is a set of extension methods allowing XPath /
XSLT to be used over LINQ to XML trees, allow XSLT transformations to
produce an LINQ to XML tree, and to validate an XElement tree against an
XML Schema. - Event Model - This
allows LINQ to XML trees to be efficiently synchronized with a GUI, e.g.
a Windows Presentation Foundation application - Class hierarchy
changes - XObject class added, XStreamingElement class (temporarily)
removed - Various
understandability / usability improvements – There have been a number of
relatively minor changes done in response to internal reviews, usability
studies, and external feedback to make the API more clean and
consistent. - LINQ to Objects API
- The LINQ to Objects
API supports queries over any .NET collection, such as arrays and
Generic Lists. This API is defined in the System.Linq namespaces inside
System.Core.dll.
- ADO.NET
- Extended, more powerful
data APIs with the ADO.NET Entity Framework - With the ADO.NET
Entity Framework developers will be able to model the view of the data
that is appropriate for each one of the applications they are building,
independently of the structure of the data in the underlying database.
The use of the Entity Data Model (EDM) enables developers to design
models that follow the concepts built into the application, instead of
having to map them to constructs available in relational stores. Once
the model is in place, the powerful ADO.NET Entity Framework API is used
to access and manipulate the data as .NET classes or as rows and
columns, whatever is appropriate for each application. - Added paging and stored
procedures for update (“update customization”) for ADO.NET Entity
Framework: - Paging: the paging
support in the ADO.NET Entity Framework allows developers to “page” over
data in a database by indicating the start row and number of rows to be
included in the result. Paging is available through Entity SQL (using
the LIMIT AND SKIP keywords) and through the query-builder methods in
the ObjectQuery <T> class (Top and Skip). In a future CTP the
feature will also be enabled to be used in LINQ queries by means of the
standard Take and Skip LINQ operators. - Stored-procedures for
update customization: the Entity Framework by default automatically
generates SQL statements for insert, update and delete operations when
processing changes to entities in memory to be sent to the database.
With the stored-procedures update customization feature developers have
the option to override the automatic SQL generation and instead provide
stored-procedures that will perform the insert, update and delete
operations, which the system will call during entity change processing.
Among other things, this enables scenarios where direct access to tables
is restricted in the database and the only way to make changes to the
data is through stored-procedures. - Microsoft
Synchronization Services for ADO.NET - Provides an
application programming interface (API) to synchronize data between data
services and a local store. The Synchronization Services API is modeled
after the ADO.NET data access APIs and gives you an intuitive way to
synchronize data. It makes building applications for occasionally
connected environments a logical extension of building applications
where you can depend on a consistent network connection. For details
please visit http://go.microsoft.com/fwlink/?LinkId=80742
.
- Web
- Improvements for web
development in this CTP include: - New ASP.NET WebForms
design-surface with advanced XHTML and CSS features - JScript intellisense
for ASP.NET AJAX and browser DOM - Multi-targetting for
.NET Framework 2.0, 3.0, and 3.5 in websites and web applications - LINQ to SQL designer
integration in websites and web applications
- Client App-Level Services
- Enable client
application developers to use the same user profile and login services as
your Web applications. This enables customers to utilize on set of
backend storage for user personalization and authentication regardless of
the applications type.
- C# Workflow Rules
- Workflow Rules allows
users to enter rules (and conditions) in a code-like manner - Support the use of the
new C# Extension methods features in their rules - Enable operator
overloading and the new operators in their rules
- XML
- XML Tools: XSLT
Debugger - Enables Input Data
Breakpoints allowing the user to break the execution of the style-sheet
whenever a certain node in input document is hit. - XML Editor Performance
Improvements - Performance in the Xml
Editor for Intellisense, schema validation etc is improved by
implementing incremental parsing of the XML Document. - Seamless transition
between XML Editor and XSD Designer - Improves the
experience a user has when working with an XML Schema in textual and
graphical mode at the same time.
- MSBuild
- Parallel/Multi-Processor
Builds - Building multiple
projects in parallel, as much as possible based on the use of dependency
information in projects to parallelize - Allowing the
developer/builder to control the parallelism by providing them the
ability to specify the number of processors to use for build.
- UAC Manifests in the Managed Build Process
- Support for manifests
that are embedded into the final executable via the Build process.
- IDE
- Windows Presentation
Foundation (WPF) Designer (“Cider”) & Application Tools to deliver
the ability to: - Create, edit, build,
run and debug WPF projects - Use the WPF Designer
to: - Preview any XAML in
the designer including user defined controls and types - Design Windows, Pages
and UserControls - Do basic layout tasks
in a Grid - Do basic property
editing using the new property browser - Easily understand and
navigate “document structure” using the Document Outli - See changes in the
designer immediately in the XAML - Use the XAML Editor
to: - Edit XAML with
intellisense - See changes in the
XAML immediately in the designer - Build design time for
WPF controls - UAC manifests in the
IDE for Windows Vista applications - Enable developers on
Windows Vista to easily include the UAC manifest as an embedded
resource.
- CLR
- Add IRI support (RFC
3987) to URI related classes - This allows resource
identifiers to be specified using a character set that supports all
languages. - New Async model on
Socket class - A new Async model is
reduces the per I/O overhead compared to the current I/O model - Peer Networking Classes
- Delivers a set of
peer-to-peer network APIs that allow a developer to easily extend an
application with compelling collaboration functionality. - WMI.NET Provider
Extension 2.0 - WMI.NET Provider
Extension 2.0 simplifies and enhances the development of WMI providers
in the .Net framework to enable the management of the .NET applications
while minimizing the impact on the development time. - Delivers equivalent
access to WMI features and functions available to native code
providers. - Exposes property
updates and methods to managed code. - Improved scalability
for large collections of WMI entities.
- Office
- Enable ClickOnce deployment
for Microsoft Office applications - Developers now have an
easy to use and version resilient security model for their applications
that will exist for future versions of Visual Studio and Office. With
full support for ClickOnce deployment of all Office 2007 customizations
and applications, developers and administrators now have the right tools
and framework for easy deployment and maintenance of their Office
solutions.
- Team Architect
- Top-down service design
- Top-down system design
allows an application architect/lead developer to perform the design of
a business solution without having to be confronted with technology
decisions. It enables the user to progressively refine a high-level
system design, designing new sub-systems and applications in the context
of the system in which they are to be used. - Architectural Roles on
System, Applications and Endpoints - Enables an architect,
while working on the high-level design of a system’s architecture using
the System Designer, to introduce elements into the design that play a
specific pre-defined architectural role(s) within architectural
patterns.
- Team Developer
- Profiler Support for
WCF Applications - Enable profiling of
WCF based applications to improve application performance - Customize and extend
code correctness policies - Code Analysis Check-in
Policy improvements to communicate to a developer why the check-in
policy failed and to provide guidance on how to pass the policy
requirements. - Customize and extend
code correctness policies - Code Analysis Check-in
Policy improvements to communicate to a developer why the check-in
policy failed and to provide guidance on how to pass the policy
requirements. - Performance tune an
enterprise application - Enables developers to
run profiling during load and test procedures for a system, to see how
it behaves, and use integrated tools to profile, debug and tune. This
also enables performance base-lining, so that users can save a baseline
profile and then, if the performance degrades, compare up-to-date traces
to identify the source of the regression
- Team Test
- Unit Test Generation
Improvements - Improvements to unit
test generation provide an easy way for the user to specify what methods
to test, and generate test methods and helper code to do unit testing,
as well as providing unit test support for generics. - Web Test Validation
Rule Improvements - Web Test rules
improvements enable testers to create more comprehensive validation
rules for the application being tested. These improvements include the
following functions: - Stop test on error
- Search request and
response - Add validation rule
for title - Redirect validation
- Provide test level
validation rules - Expected HTTP code
- Warning level for
errors on dependents - Better Web Test Data
Binding - This feature allows
users to data bind .CSV and XML files, as well as databases to a web
test, using a simple databinding wizard. - Improved Load Test
Results Management - With this feature user
can open or remove an existing load test result from the load test
repository. User can also import and export load test results files.
- Team Foundation Server
- Team Build
- Support multi-threaded
builds with the new MSBuild. - Continuous Integration
– There are many components to this, including build queuing and queue management,
drop management (so that users can set policies for when builds should
be automatically deleted), and build triggers that allows configuration
of exactly how when CI builds should be triggered, for example – every
checkin, rolling build (completion of one build starts the next), etc. - Improved ability to
specify what source, versions of source, etc to include in a build. - Improved ability to
manage multiple build machines. - Simplified ability to
specify what tests get run as part of a build - Version Control support
- Destroy- The version
control destroy operation provides administrators with the ability to
remove files and folders from the version control system. The destroyed
files and folders cannot be recovered once they are destroyed. Destroy
allows administrators to achieve SQL server disk space usage goals
without constantly needing to add more disks to the data tier machine.
Destroy also facilitates removing versioned file contents that must be
permanently removed from the system for any other reason. - Annotate - Annotate is
a feature that allows developers to inspect a source code file and see
at line-by-line level of detail who last changed each section of code.
It brings together changeset data with difference technology to enable
developers to quickly learn change history inside a source file. - Folder Diff - Team
Foundation Server now supports compare operations on folders, whereby
the contents of the folder are recursively compared to identify files
that differ. Folder diff can compare local folders to local folders,
local folders to server folders, and server folders to server folders.
It’s a great way of identifying differences between branches, files that
you’ve changed locally, and files that have changed between two points
in time. - Get Latest on Checkout
- As an optional setting on a team project or on an individual basis,
you can have Team Foundation Server always download the latest version
of a file when you check it out. This helps ensure that you don’t have
to merge your changes with somebody else’s when you check the file back
in. - Performance and Scale
- This release includes
numerous improvements in performance and scalability of Team Foundation
Server.
- Visual C++
- Easily add the Windows
Vista “Look and Feel” to native C++ applications - Developers can use
Visual Studio to build ISV applications that exhibit the Windows Vista
“look & feel”. A number of the Windows Vista “look & feel”
features are available simply by recompiling an MFC application. Deeper
integration that requires more coding or design work on the part of the
developer is also simplified with Visual Studio’s integrated support for
the Windows Vista native APIs.
Existing CTPs: As Visual Studio code name “Orcas” CTPs are released on a predefined cadence, existing CTPs (such as the LINQ May 2006 CTP) may not yet have been integrated into a given “Orcas” CTP release (This should not be taken as a change in commitment to any existing technology that has been made available as a CTP but instead is just a real world example of how large applications, with many technology areas, are built. We will be integrating this existing functionality into future CTP builds.
Developers using a VPC image can run the CTP on a machine without impacting any existing software installations. The CTP can be removed by deleting the folder and using the Virtual PC application to remove the configuration information.
This image ships with networking set to “local”. This setting enables the virtual machine to think it is connected to a network without actually connecting and exposing the machine to the Internet. We recommend that customers do not modify the networking settings. Customers who wish to turn networking “on” to connect the image to a physical network are advised that they will need to ensure the security of the virtual machine as well as apply any security updates that may have become available since the release of this image.
Using ALTER INDEX…REBUILD To Rebuild A Clustered Index Does Not Rebuild Its Nonclustered Indexes By Default On SQL Server 2005
Well Ken Henderson has the answer for you on his blog.
On SQL Server 2005, using ALTER INDEX…REBUILD to rebuild a clustered index
does not rebuild its nonclustered indexes by default
Read the rest here: http://blogs.msdn.com/khen1234/archive/2007/02/27/does-rebuilding-a-clustered-index-rebuild-nonclustered-indexes.aspx
Sunday, February 25, 2007
Failure Trends in a Large Disk Drive Population
While drive manufacturers often quote yearly failure rates below 2%,
user studies have seen rates as high as 6%.
We find, for example, that after their first scan error, drives are 39
times more likely to fail within 60 days than drives with no such errors. First
errors in reallocations,offline reallocations, and probational counts are also
strongly correlated to higher failure probabilities.
Six percent, that is higher than I expected. I must say (and I am knocking on wood as I write this) that I only saw a drive die once (within a month of deploying) on a blade server. The only major problem I had was when consulting for a client in NYC. They had a SQL Server box which was running for 2 years without a problem. We upgraded the machine to an active/passive cluster and a week later the motherboard died (downtime 20 seconds ;-) ), talking about good timing.....
So what failure rates do you see? Does stuff break down a lot?
Saturday, February 24, 2007
The Real Reason Why Condoleezza Rice Never Smiles
Friday, February 23, 2007
Thursday, February 22, 2007
How To Find Out Which Columns Have Defaults And What Those Default Values Are
There are a couple of ways to do this
Below is a list:
1 INFORMATION_SCHEMA.COLUMNS view (2000 and 2005)
2 sysobjects,syscolumns and syscomments (2000 only)
3 sys.default_constraints and sys.sysobjects (2005 only)
4 sp_help (2000 only)
So let's get started with some code
CREATE TABLE blah(id INT DEFAULT 0,
SomeDate DATETIME DEFAULT CURRENT_TIMESTAMP)
INSERT blah DEFAULT VALUES
SELECT * FROM blah
--SQL 2000/2005
SELECT COLUMN_DEFAULT,*
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME ='blah'
--SQL 2000
SELECT Text,*
FROM sysobjects o
INNER JOIN syscolumns c
ON o.parent_obj = c.id
AND o.info = c.colid
INNER JOIN syscomments s
ON o.id = s.id
WHERE o.xtype = 'D'
AND OBJECT_NAME(parent_obj) = 'blah'
--SQL 2005
SELECT * FROM
sys.default_constraints d
JOIN sys.sysobjects o ON d.parent_object_id = o.id
WHERE o.name = 'blah'
See what happens when you don't specify a name (we will do this later)? You will get wacky names like these: DF__blah__id__15A53433 and DF__blah__SomeDate__1699586C
Instead of specifying the default when creating the table use an alter table add constraint statement.Let's see this in action.
DROP TABLE blah
CREATE TABLE blah(id INT,SomeDate DATETIME)
ALTER TABLE blah
ADD CONSTRAINT DF_Blah_ID_0
DEFAULT 0 FOR id
ALTER TABLE blah
ADD CONSTRAINT DF_Blah_SomeDate_Now
DEFAULT CURRENT_TIMESTAMP FOR SomeDate
INSERT blah DEFAULT VALUES
SELECT * FROM blah
--SQL 2000/2005
SELECT COLUMN_DEFAULT,*
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME ='blah'
--SQL 2000
SELECT Text,*
FROM sysobjects o
INNER JOIN syscolumns c
ON o.parent_obj = c.id
AND o.info = c.colid
INNER JOIN syscomments s
ON o.id = s.id
WHERE o.xtype = 'D'
AND OBJECT_NAME(parent_obj) = 'blah'
--SQL 2005
SELECT * FROM
sys.default_constraints d
JOIN sys.sysobjects o ON d.parent_object_id = o.id
WHERE o.name = 'blah'
And last we have sp_help
You can use sp_help in SQL Server 2000(you can also use it in SQL server 2005 but it doesn't return the defaults )
Execute the following
sp_help 'blah'
The defaults will be in the last resultset (the one where the first column name = constraint_type)
And last but not least did you notice that we had CURRENT_TIMESTAMP but when we queried the table we saw GETDATE() This is kind of strange since CURRENT_TIMESTAMP is ANSI complaint but GETDATE() is not
Wednesday, February 21, 2007
SQL Server 2005 Best Practices Analyzer (February 2007 CTP) Available For Download
The SQL Server 2005 Best Practices Analyzer (BPA) gathers data from Microsoft Windows and SQL Server configuration settings. BPA uses a predefined list of SQL Server 2005 recommendations and best practices to determine if there are potential issues in the database environment.
This download is the February 2007 Community Technology Preview of SQL Server 2005 Best Practices Analyzer.
SQL Server 2005 Books Online Is Not Part Of The Service Pack 2 Download
Here are two more downloads:
SQL Server 2005 Reporting Services Add-in for SharePoint Technologies
SQL Server 2005 Data Mining Add-ins for Microsoft Office 2007