Having been a fan of SQL Server 2008's Intellisense feature, I was disappointed to find it not working on a new installation of SQL Server 2008 (SP1-10.0.2531.0). I checked the Intellisense options (Tools>Options>Text Editor>Transact-SQL>Intellisense ) and it was showing as being enabled. I reviewed the other common cause of failure which is being connected to a database with a lower compatibility level than SQL Server 2008 (10) but this wasn’t the case.
I had a dig around and found the option to refresh Intellisense ’s local cache (edit>Intellisense >Refresh Local Cache), which worked for me and Intellisense sprang into life.
Curiosity persisted though, and I found the following guide to common causes of Intellisense failure. Hope it saves you some time in your investigations…
From MSDN:
There are certain cases when the Intellisense options might not work as you expect.
Conditions That Affect Intellisense
The following conditions might affect the behavior of Intellisense :
Database Engine Query Intellisense
The following issues apply to the Database Engine Query Editor:
Some questions reappear on forums more than others, my experience suggests none more so than how one should work out an individual’s age based on their date of birth.
I have been using the following logic within a procedure, as I didn’t require specific months and days as part of the returned result.
DECLARE @DOB as DateTime
Set @DOB='29 Jun 1980' -- Date Of Birth
select year(getdate())
- year(@DOB)
- case when month(@DOB) > month(getdate()) then 1
when month(@DOB) < month(getdate()) then 0
when day(@DOB) > day(getdate()) then 1
else 0
end as age
Well now the requirements have changed with the application now expecting the Month and Day part of the calculated age.
The following tsql will fulfil these new criteria:
DECLARE @date datetime,
@tmpdate datetime,
@years int,
@months int,
@days int
SELECT @date = '6/29/80'
SELECT @tmpdate = @date
SELECT @years = DATEDIFF(yy, @tmpdate, GETDATE()) - CASE WHEN MONTH(@date) > MONTH(GETDATE()) THEN 1 ELSE 0 END
SELECT @tmpdate = DATEADD(yy, @years, @tmpdate)
SELECT @months = DATEDIFF(m, @tmpdate, GETDATE()) - CASE WHEN DAY(@date) > DAY(GETDATE()) THEN 1 ELSE 0 END
SELECT @tmpdate = DATEADD(m, @months, @tmpdate)
SELECT @days = DATEDIFF(d, @tmpdate, GETDATE())
SELECT @years as Yr, @months as Mnths, @days as [Days]
This seems to do the trick but I’d be interested to hear from anyone with a different (better) way of producing the additional columns for the latter query.
A colleague of mine who is getting to grips with SQL Server had an issue after creating and implementing a maintenance plan to manage backup files on his local SQL Server instance.
The problem was with the routine maintenance which should have been removing files with a bak extension that are older than two days. He was trying to emulate a plan from one of our staging servers and despite having entered all the details, albeit manually, the job would execute and apparently succeed but there would be no removal of files. And then this morning his hard drive stopped J
I had a look at the plan that had been created and performed a quick test and the issue was exactly as my colleague had reported it. And then it hit me! The value for File Extension had ‘.bak’, and the task was therefore looking for test..bak as it apparently appends its own '.' to the string.
Removing the extra full-stop (or period) resolved the problem, so the entry simply states 'bak' rather than '.bak'.
Having briefly researched (ok, googled) the issue, I note that others have faced similar problems and most of which were resolved by observing the steps below. Hope it saves you some time…
(As posted on http://www.sqlnewsgroups.net/group/microsoft.public.sqlserver.server/topic24757.aspx by SQL Server MVP Jonathan Kehayias)
- Make sure that you have a '\' at the end of the path, so if the backups are in D:\SQLBackups use D:\SQLBackups\
- Make sure that the extension is bak and not .bak For whatever reason it doesn't like having the . before the bak.
- If you are deleting trn files and bak files, have two separate jobs one to cleanup the bak files and one to clean up the trn files.
- If you backed up databases to separate folders, checking the 'Include first-level subfolders' check box is necessary.
If you have a SQL data (mdf) file without the corresponding log (ldf) file, you can still attach the database to an instance. Use the sp_attach_single_file_db procedure as demonstrated below:
--To attach a .mdf file without its log file,
--use the following syntax
EXEC sp_attach_single_file_db @dbname = 'YourDBname',
@physname = N'd:\Database\Data\YourDBname.mdf'
For more details, including a list of arguments, please visit:
http://msdn.microsoft.com/en-us/library/ms174385.aspx
I can find out the version, edition, and build of my SQL Server by using the SERVERPROPERTY function in SQL Server (the full list of options for this function exists at the foot of this post).
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')
This will return results such as:
10.0.2531.0 SP1 Enterprise Edition
You can then reference against the build list in Steve Jones' post to see details of the build you are running
http://www.sqlservercentral.com/articles/SQL+Server+2008/63491/
The SERVERPROPERTY function is useful and provides the following options:
Property
Values returned
BuildClrVersion
Version of the Microsoft .NET Framework common language runtime (CLR) that was used while building the instance of SQL Server.
Base data type: nvarchar(128)
Collation
Name of the default collation for the server.
NULL = Input is not valid, or an error.
CollationID
ID of the SQL Server collation.
Base data type: int
ComparisonStyle
Windows comparison style of the collation.
ComputerNamePhysicalNetBIOS
NetBIOS name of the local computer on which the instance of SQL Server is currently running.
For a clustered instance of SQL Server on a failover cluster, this value changes as the instance of SQL Server fails over to other nodes in the failover cluster.
On a stand-alone instance of SQL Server, this value remains constant and returns the same value as the MachineName property.
Note:
If the instance of SQL Server is in a failover cluster and you want to obtain the name of the failover clustered instance, use the MachineName property.
Edition
Installed product edition of the instance of SQL Server. Use the value of this property to determine the features and the limits, such as maximum number of CPUs that are supported by the installed product. 64-bit versions of the Database Engine append (64-bit) to the version.
Returns:
'Desktop Engine' (Not available for SQL Server.)
'Developer Edition'
'Enterprise Edition'
'Enterprise Evaluation Edition'
'Personal Edition'(Not available for SQL Server.)
'Standard Edition'
'Express Edition'
'Express Edition with Advanced Services'
'Workgroup Edition'
'Windows Embedded SQL'
EditionID
Is an identification number that represents the installed product edition of the instance of SQL Server. Use the value of this property to determine features and limits, such as maximum number of CPUs that are supported by the installed product.
-1253826760 = Desktop
-1592396055 = Express
-1534726760 = Standard
1333529388 = Workgroup
1804890536 = Enterprise
-323382091 = Personal
-2117995310 = Developer
610778273 = Enterprise Evaluation
1044790755 = Windows Embedded SQL
4161255391 = Express with Advanced Services
EngineEdition
Database Engine edition of the instance of SQL Server installed on the server.
1 = Personal or Desktop Engine (Not available for SQL Server.)
2 = Standard (This is returned for Standard and Workgroup.)
3 = Enterprise (This is returned for Enterprise, Enterprise Evaluation, and Developer.)
4 = Express (This is returned for Express, Express with Advanced Services, and Windows Embedded SQL.)
InstanceName
Name of the instance to which the user is connected.
Returns NULL if the instance name is the default instance, if the input is not valid, or error.
IsClustered
Server instance is configured in a failover cluster.
1 = Clustered.
0 = Not Clustered.
IsFullTextInstalled
The full-text component is installed with the current instance of SQL Server.
1 = Full-text is installed.
0 = Full-text is not installed.
IsIntegratedSecurityOnly
Server is in integrated security mode.
1 = Integrated security.
0 = Not integrated security.
IsSingleUser
Server is in single-user mode.
1 = Single user.
0 = Not single user
LCID
Windows locale identifier (LCID) of the collation.
LicenseType
Mode of this instance of SQL Server.
PER_SEAT = Per Seat mode
PER_PROCESSOR = Per-processor mode
DISABLED = Licensing is disabled.
MachineName
Windows computer name on which the server instance is running.
For a clustered instance, an instance of SQL Server running on a virtual server on Microsoft Cluster Service, it returns the name of the virtual server.
NumLicenses
Number of client licenses registered for this instance of SQL Server if in Per Seat mode.
Number of processors licensed for this instance of SQL Server if in per-processor mode.
Returns NULL when the server is none of these.
ProcessID
Process ID of the SQL Server service. ProcessID is useful in identifying which Sqlservr.exe belongs to this instance.
NULL = Input is not valid or an error.
ProductVersion
Version of the instance of SQL Server, in the form of 'major.minor.build'.
ProductLevel
Level of the version of the instance of SQL Server.
Returns one of the following:
'RTM' = Original release version
'SPn' = Service pack version
'CTP', = Community Technology Preview version
ResourceLastUpdateDateTime
Returns the date and time that the Resource database was last updated.
Base data type: datetime
ResourceVersion
Returns the version Resource database.
ServerName
Both the Windows server and instance information associated with a specified instance of SQL Server.
SqlCharSet
The SQL character set ID from the collation ID.
Base data type: tinyint
SqlCharSetName
The SQL character set name from the collation.
SqlSortOrder
The SQL sort order ID from the collation
SqlSortOrderName
The SQL sort order name from the collation.
FilestreamShareName
The name of the share used by FILESTREAM.
FilestreamConfiguredLevel
The configured level of FILESTREAM access. For more information, see filestream access level.
FilestreamEffectiveLevel
The effective level of FILESTREAM access. This value can be different than the FilestreamConfiguredLevel if the level has changed and either an instance restart or a computer restart is pending. For more information, see filestream access level.
Bottom of Form