Home > Archive > Microsoft SQL Server forum > April 2005 > SQL statement









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SQL statement
Peter

2005-04-26, 3:23 am

Hi,

Am having trouble with an alter table command in SQL, it is the below
command, and gives the error message shown below.

alter table "Test" add "Test" numeric(10,0) with values NULL

Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'with'.

I realise it has something to do with the 'with values NULL', but some
more clarification would be good. Is it because you cannot specify
'NULL' for the numeric type?

I find plenty of info on the net about the rest of the statement, but
the 'with values' bit there seems to be nothing about it.
Hugo Kornelis

2005-04-26, 3:23 am

On 25 Apr 2005 22:18:19 -0700, Peter wrote:

>Hi,
>
>Am having trouble with an alter table command in SQL, it is the below
>command, and gives the error message shown below.
>
>alter table "Test" add "Test" numeric(10,0) with values NULL
>
>Server: Msg 156, Level 15, State 1, Line 1
>Incorrect syntax near the keyword 'with'.
>
>I realise it has something to do with the 'with values NULL', but some
>more clarification would be good. Is it because you cannot specify
>'NULL' for the numeric type?
>
>I find plenty of info on the net about the rest of the statement, but
>the 'with values' bit there seems to be nothing about it.


Hi Peter,

The correct syntax is

ALTER TABLE Test
ADD Test numeric(10,0) DEFAULT NULL WITH VALUES

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
David Portas

2005-04-26, 3:23 am

WITH VALUES is only valid if you are declaring a DEFAULT. Since you
apparently want the default value to be NULL there is no need for a DEFAULT
or the WITH VALUES clause. The values will be NULL anyway.

--
David Portas
SQL Server MVP
--


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com