| Author |
Topic |
|
yellowman
Starting Member
25 Posts |
Posted - 2004-12-29 : 08:33:04
|
| I am trying to drop a column from a table using the following syntax:ALTER TABLE daily_reading DROP COLUMN MyPKgo...but I get an error everytime I try to run it:Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near 'MyPK'.Where's the syntax error? |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-12-29 : 09:06:06
|
| Is MyPK the column name? |
 |
|
|
yellowman
Starting Member
25 Posts |
Posted - 2004-12-29 : 09:21:16
|
| yes it is. This is how it was created...Alter table dup_authors add MyPK int NULLgoThen the column was filled with a bunch of sequential numbers. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-12-29 : 09:34:44
|
| It's giving a syntax error suggesting there is some other character there or you didn't execute the whole statement.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
yellowman
Starting Member
25 Posts |
Posted - 2004-12-29 : 11:01:16
|
Is the syntax correct on the above statement then? I don't see any other stray characters there unless they are invisible |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-12-29 : 11:32:01
|
| does "go" have to be capitalized? (I have no idea, just guessing)- Jeff |
 |
|
|
yellowman
Starting Member
25 Posts |
Posted - 2004-12-29 : 11:38:21
|
SQL Server isn't case sensitive like Oracle is, so no 'go' does not need to be capitalized. I still tried it though just to make sure |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-12-29 : 12:09:37
|
| Try thiscreate table #a (i int, j int)alter table #a drop column j==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
yellowman
Starting Member
25 Posts |
Posted - 2004-12-29 : 12:12:05
|
| This is what I get when I run the above script...Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near 'j'. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-12-29 : 12:57:49
|
| Which version are you running?If 2000 are you in compatibility mode==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
yellowman
Starting Member
25 Posts |
Posted - 2004-12-29 : 14:02:37
|
| Ha....That was it. I was running with a compatibility of 65. Thanks for all of your help. |
 |
|
|
|