469,929 Members | 1,831 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

SQL statement

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.
Jul 23 '05 #1
2 1052
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)
Jul 23 '05 #2
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
--
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

28 posts views Thread by Fábio Mendes | last post: by
13 posts views Thread by eman1000 | last post: by
37 posts views Thread by Steven Bethard | last post: by
18 posts views Thread by Steven Bethard | last post: by
28 posts views Thread by Steven Bethard | last post: by
7 posts views Thread by Steven Bethard | last post: by
18 posts views Thread by dspfun | last post: by
23 posts views Thread by florian.loitsch | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.