Apple has announced the iPhone 3.0 software update which includes an updated Software Development Kit (SDK) with over 1,000 completely new APIs.
Here are a few highlighted features:
Search your iPhone
Cut, copy, and paste
Send photos, contacts, audio files, and location via MMS*
Read and compose email and text messages in landscape
And yes, I am running it (I have an Apple Developer Account), and so far I found one bug (on safari re-highlighting the address bar can sometimes make the address disapear) and an un-announced fearure (the call history list is now much more verbose)
If you like to know what’s changing on your SQL Server then the following code creates an audit table and the associated trigger for logging the changes
CREATETRIGGER[TriggerAuditObjects] ONDATABASE FOR DDL_DATABASE_LEVEL_EVENTS AS INSERTINTO[dbo].[AuditObjects](EventData) SELECT EVENTDATA()
GO
ENABLE TRIGGER[TriggerAuditObjects]ONDATABASE
– Required Declares
DECLARE @getdbname sysname
DECLARE @sqlstm nvarchar(1000)
DECLARE SeachCursor cursor FOR – Get All The Names into the SeachCursor SELECT‘['+name+']‘FROM[master].[dbo].[sysdatabases]ORDERBY name
OPEN SeachCursor – Add the Search Pattern SET @SearchString = ‘%’ + @SearchString + ‘%’ –Get the first Name
FETCH NEXT FROM SeachCursor INTO @getdbname
WHILE @@FETCH_STATUS=0
BEGIN –set the statement to define the search condition, with variables SET @sqlstm = ‘
SELECT [SP].[Specific_Catalog] AS [Database_Name], [SP].[Routine_Name] AS [Stored Procedure Name],[SP].[Routine_Definition] AS [Routine_Definition]
FROM ‘+ @getdbname+‘.[Information_Schema].[Routines] AS [SP]
WHERE PatIndex(’+””+@SearchString+””+‘, [Routine_Definition]) > 0′ –Execute the Query
EXEC (@sqlstm)
FETCH NEXT FROM SeachCursor INTO @getdbname
END –Close the Cursor and Deallocate it from memory
CLOSE SeachCursor
DEALLOCATE SeachCursor
If you get the error in the SQL 2008 Management Studio :
“Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created.”
You can enable changes inside the Microsoft SQL Server Management Studio by going to ‘Tools|Options|Designers’ then unchecking the ‘Prevent saving changes that require table re-creation’ option
You can use TSQL to Count Number Of Stored Procedures, Views, Tables or Functions in a Database by using the Database INFORMATION_SCHEMA view
/* Count Number Of Tables In A Database */ SELECT COUNT(*)AS TABLE_COUNT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE=‘BASE TABLE’ /* Count Number Of Views In A Database */ SELECT COUNT(*)AS VIEW_COUNT FROM INFORMATION_SCHEMA.VIEWS /* Count Number Of Stored Procedures In A Database */ SELECT COUNT(*)AS PROCEDURE_COUNT FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = ‘PROCEDURE’ /* Count Number Of Functions In A Database */ SELECT COUNT(*)AS FUNCTION_COUNT FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = ‘FUNCTION’
The same methodology can be used to query for information :
/* Select Table Information For A Database */ SELECT * FROM INFORMATION_SCHEMA.TABLESWHERE TABLE_TYPE=‘BASE TABLE’ /* Select View Information For A Database */ SELECT * FROM INFORMATION_SCHEMA.VIEWS /* Select Stored Procedure Information For A Database */ SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = ‘PROCEDURE’ /* Select Function Information For A Database */ SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = ‘FUNCTION’
A DISTINCT and GROUP BY usually generate the same query plan, so performance should be very simular or the same, if you only need to remove the dulicates then DISTINCT is easier to understand in the query, if you have a more complex query it may be worth running both and studdying the execution plan to see if your specific example wins