Hi There,

Thank You for visiting my blog. I have moved this blog to a new address http://dattatreysindol.com/. Please visit the blog at new address and re-point your feeds to the new address to continue to receive regular updates.
Thanks,
Dattatrey Sindol (Datta)

Datta's Ramblings on Business Intelligence 'N' Life

Intellisense in SSMS 2008 Lists the Objects Even Before Creating them - Pretty Intelligent

» 6 Aug 2011 | | |

As most of you us know that Intellisense feature was introduced as part of SQL Server Management Studio (SSMS) which shipped with SQL Server 2008. There after it is getting better in subsequent releases with a whole lot of new features in Denali SSMS.

Basically Intellisense assists the user while writing queries by providing necessary suggestions on the Object Names, Object Properties (like column names etc.) etc. Usually people say that SSMS provides suggestions for those objects which exist on the database/server. However, there is an interesting fact about SSMS which many people do not know and that is, Intellisense provides suggestions even on those objects for which the DDL has just been written (not executed yet!) in the same window in which it is being accessed.

Let us take a look a simple example.

1. Go to SSMS and Open a New Query Window
2. Type in the following statements - one to change the database context to tempdb and the next one to create a new table SampleTable:

USE tempdb
GO

CREATE TABLE [dbo].[SampleTable] (
ID INT IDENTITY(1,1),
Value1 NVARCHAR(255),
Value2 NVARCHAR(255)
)
GO

3. Do not execute any of the above two statements.
4. Now start typing the below statement after the above two statements:

INSERT INTO dbo.S

As soon as you type in INSERT INTO dbo., it will list the SampleTable in the list of suggestions even though we have just written the script for SampleTable creation but have not created it yet. Below screenshot shows this in action.


Here is another instance of using a SEELECT * FROM query on the SampleTable before creating it.


Now write the INSERT INTO Statement or SELECT * FROM Statement completly to make it a valid SQL Statement and try to execute the completed statement without executing the CREATE TABLE Statement and you will see that you will get an error like the one below which shows that the object does not exist.


Sounds Simple but is Really Interesting :)
If you guys have come across any such interesting things, do share it by leaving a comment below.

Readers Feedback:
Did you like this article?
If Yes, then please share it:
Did you like my blog?
If Yes, then please help spread the word by sharing this blog with your colleagues, friends, & anyone else in the MSBI Space: Like us on Facebook , Follow us on Twitter .

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

About the Author

Dattatrey Sindol is a BI Tech Lead & a passionate SQL Server Developer in a leading IT company.  read more »
Connect with Datta:

Thank You Visitors!

Hi There, Thanks for Visiting my Blog. Please feel free to leave your Comments/Suggestions about any of my Articles/My Blog.

Do Not Copy this Blog's Content !

Protected by Copyscape Online Copyright Checker