Date time Variable in SQl SErver 2008

hi,

I want to creat a date variable but whenever i create a date variable i am getting a error...

Msg 2715, Level 16, State 7, Line 1
Column, parameter, or variable #5: Cannot find data type DATE.

I have attached the code below..
create table tbl 
(
sl int Primary key Identity,
Name Varchar(66),
Age int,
Address_ varchar(30),
Dates  DATE
)

Open in new window

Yogesh_AgarwalAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
DATE is available on sql server 2008, make sure that you are running it on sql 2008 for prior  versions you can use datetime
0
Yogesh_AgarwalAuthor Commented:
but i am getting error..
0
Chris LuttrellSenior Database ArchitectCommented:
You must be trying to create it on a SQL Server 2005 instance.  Use DATETIME instead of DATE like below.
create table tbl 
(
sl int Primary key Identity,
Name Varchar(66),
Age int,
Address_ varchar(30),
Dates  DATETIME
)

Open in new window

0
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Olaf DoschkeSoftware DeveloperCommented:
make triple sure the instance of SQL Server you're running is 2008 and if you execute this remote via ODBC or OLEDB you're also using an SQL 2008 driver.

Bye, Olaf.
0
Yogesh_AgarwalAuthor Commented:
i am testing thsi codes in SQL Server Management Studio..
0
Anthony PerkinsCommented:
>>i am testing thsi codes in SQL Server Management Studio..<<
Correct. But you are using SQL Server 2005 or you compatibility level is set to 90.
0
Yogesh_AgarwalAuthor Commented:
i have installed SQL Server 2008.. not sure with its compatibility..
0
Anthony PerkinsCommented:
This will show you the version and Service Pack:

Select SERVERPROPERTY('ProductVersion'), SERVERPROPERTY('ProductLevel')

And this will Print in the messages tab the Compatibility Level.

EXEC sp_dbcmptlevel YourDatabaseNameGoesHere

0
Olaf DoschkeSoftware DeveloperCommented:
I just executed your CREATE TABLE statement on SQL 2005 and get the exact same error message. Looks like you execute it in SQL2005.

We believe you, you installed SQL2008, but it's quite probable there's also an SQL 2005 or lower version instance of SQL Server you connect to, you can install many SQL Server versions in parallel, installing SQL 2008 does not mean there can't be anything else on the same machine.

Bye, Olaf.
0
Chris LuttrellSenior Database ArchitectCommented:
If the ProductVersion from this query is something like this, 9.00.4035.00, instead of starting with 10 like this, 10.0.2531.0 then you are on a 2005 box because 2005 is version 9 of SQL and 2008 is version 10.
If that reveals that you are on 2008 then check the compatibliity either with acperkins command above or look at the database properties in SSMS, see image below.  With the sql command look for "The current compatibility level is 100", if it says 90 instead of 100 then your compatibility is set to 2005.  You can get to the DB options window in the image by right clicking on the DB name in SSMS and selecting Properties.

SELECT SERVERPROPERTY('productversion') ProductVersion, SERVERPROPERTY ('productlevel') ProductLevel, SERVERPROPERTY ('edition') Edition

Open in new window

SQL-Server-2008-Compatibility-Se.png
0
Yogesh_AgarwalAuthor Commented:
yeah i found that i am running sql 2005.. there is no option for sql 2008.. i am sure i have installed sql server 2008... i don know wats going on.. please tell me how to proceed..
0
Chris LuttrellSenior Database ArchitectCommented:
As I posted above, you need to change the datatype from DATE to DATETIME as in this snippet.
create table tbl 
(
sl int Primary key Identity,
Name Varchar(66),
Age int,
Address_ varchar(30),
Dates  DATETIME
)

Open in new window

0
Yogesh_AgarwalAuthor Commented:
is it possible to correct my sql version?
0
Chris LuttrellSenior Database ArchitectCommented:
If you have both installed, at least one of them must be a named instance.  Look in SQL Server Configuration Manager and see if you see more than one SQL Server service, one may be named the default (MSSQLSERVER) but the other one must be named something else.  If so, then when you pick the server to connect to do not just use the server name, add the named instance.  For example: YourServerName/SQL2008NamedInstance.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Olaf DoschkeSoftware DeveloperCommented:
If you don't need the SQL2005 Server anymore then deinstall it. Like CGLuttrell said your SQL2008 Instance must have an instance name. You might list all SQL Server Instances via this:

http://technet.microsoft.com/en-us/library/ms210334(SQL.90).aspx

Bye, Olaf.
0
Olaf DoschkeSoftware DeveloperCommented:
>is it possible to correct my sql version?

There is no need to "correct" the version. If you install SQL Sever 2008 on a machine where SQL2005 is installed you don't update SQL Server 2005 to SQL Server 2008, you install SQL 2008 in parallel.

You seem to think installing SQL2008 updates SQL2005 and updates all databases. No it does not.

You don't inherit all the SQL2005 databases within SQL2008 for example. You now have two seperate SQL Servers installed. To access 2008 you need to specify an instance name, as there can only be one standard instance, additional instances need to be named instances. Setup must have asked for an instance name.

Bye, Olaf.
0
Yogesh_AgarwalAuthor Commented:
oh man.. actually there was two instances.. mysysname and mysysname/sqlexpress default was sql express.. now after ur suggestion i checked logins and found all to be alright.. thanks for ur help.
0
Yogesh_AgarwalAuthor Commented:
great guides..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.