Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Error in sql statement

Author  Topic 

tracy5436
Yak Posting Veteran

50 Posts

Posted - 2010-11-08 : 09:42:26
When I run the following query, the receive an error Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'SPARSE'.

CREATE TABLE TEST.CUSTOMER
(CUSTOMERID INT IDENTITY(1,1),
LASTNAME VARCHAR(50) NOT NULL,
FIRSTNAME VARCHAR(50) NOT NULL,
CREDITLINE MONEY SPARSE NULL,
CREATIONDATE DATE NOT NULL)
GO

What is wrong with this query ? I am using sql 2008.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-08 : 09:58:12
Looks like you are not using SQL Server 2008?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

tracy5436
Yak Posting Veteran

50 Posts

Posted - 2010-11-08 : 10:20:21
I am - the version is 10.0.1600.22.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-08 : 10:38:42
But I have tried your posted code and there was no error.
Maybe something with compatibility level or ... I don't know.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-11-08 : 11:20:31
Database compatibility level set to 90 or below?

Why set the money column to sparse? Are most rows expected not to have a value for that? (and by most I mean 80%+)

p.s. 10.0.1600 is RTM. There are two service packs available for SQL 2008, you should upgrade.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-11-08 : 11:20:52
Quite possible that server is 2008 but db's compatibility level is of 2005 or less.

Can you execute the below statement in the database where you want to create Customer table and post the output.

sp_dbcmptlevel 'yourdatabasename'
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-11-08 : 11:25:06
sp_dbcmptlevel is deprecated, should not be used in new development and will be removed from a future version of the product.

SELECT name, compatibility_level FROM sys.databases

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -