Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1920
  • Last Modified:

sql server 2008 - Cannot find data type DATE

I am using SQL Server 2008. I tried to use the data type date. DECLARE @CurrentDate DATE
I get the error: Parameter or variable '@CurrentDate' has an invalid data type. Why?
0
qbjgqbjg
Asked:
qbjgqbjg
  • 6
  • 3
  • 2
  • +1
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>Why?
The DATE data type was not introduced until SQL Server 2008 R2.
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Disregard the above, it was introduced in 2008, not R2.
Show us the full T-SQL, as the error is likely somewhere else in code.
0
 
pateljituCommented:
Could you please execute this query and print the result:

SELECT  @@VERSION 

Open in new window

0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
qbjgqbjgConsultantAuthor Commented:
I highlighted just the declare and got the error. I ran the SELECT  @@VERSION
It says 2005, but the logon screen says 2008.
0
 
qbjgqbjgConsultantAuthor Commented:
Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86)   Nov 24 2008 13:01:59   Copyright (c) 1988-2005 Microsoft Corporation  Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)
0
 
qbjgqbjgConsultantAuthor Commented:
It shows this under about.sql-version.docx
0
 
dannygonzalez09Commented:
Could that be because you've multiple instances of SQL servers -SQL 2005 and SQL 2008... you are using SQL 2008 but the database is on SQL 2005?
0
 
qbjgqbjgConsultantAuthor Commented:
How can I tell?
0
 
dannygonzalez09Commented:
SELECT @@version should get you the correct information about the SQL instance you are connected to irrespective of what version you are using (version at the log on screen)

for Ex: I am using SQL 2012 to connect to a database running on SQL 2008

@@version gives me the information about SQL 2008 but Help in the tool bar gets me info about the SQL version i'm using

ex
0
 
qbjgqbjgConsultantAuthor Commented:
So even though I am using 2008, I can't use 2008 features.
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>you are using SQL 2008 but the database is on SQL 2005?
booya ... problem solved.

I'm using SSMS 2012 to go up against 2008R2 databases, and have to remind myself that I can't use the features that are new to 2012 such as LAG, LEAD, BOMONTH, etc.
0
 
qbjgqbjgConsultantAuthor Commented:
Thanks
0
 
pateljituCommented:
You can check "Program and Features" to verify if both SQL 2005 and SQL 2008 are installed on the same machine, I guess that's the case.

To use features of SQL 2008 you will need to re-install SQL 2008 with Named instance and use that named instance to connect to SQL 2008 database.

Please see this video on how to configure SQL 2008 with named instance, once installation is complete connect to the new named instance and that's it.

http://www.youtube.com/watch?v=9oXqzdHUH4A

Good luck
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 6
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now