|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Newbie - Student - Helpa.) Alter a table and add a column b.) Alter a table and add a constraint c.) Alter a table and add an index What I have so far is: USE Northwind ALTER TABLE Employees ADD COLUMN TerminationDate DateTime NULL Server: Msg 156, Level 15, State 1, Line 3 I keep getting "Incorrect syntax near the keyword 'COLUMN'" What am I doing wrong? If I can not get part 'a' then I will never get the rest of the assignment. Thanks in advance, Deanna UoP Student deanna***@cableone.net I am using SQL Query Analyzer
-- Deanna UoP Student deanna***@cableone.net "Deanna Cusic" <deanna***@cableone.net> wrote in message news:11lh29913e9ngd5@corp.supernews.com... I am working on an assignment that was due at midnight. The question is using the "Northwind database write the following SQL statements to be executed against on of the tables within the "Northwind database"a.) Alter a table and add a column b.) Alter a table and add a constraint c.) Alter a table and add an index What I have so far is: USE Northwind ALTER TABLE Employees ADD COLUMN TerminationDate DateTime NULL Server: Msg 156, Level 15, State 1, Line 3 I keep getting "Incorrect syntax near the keyword 'COLUMN'" What am I doing wrong? If I can not get part 'a' then I will never get the rest of the assignment. Thanks in advance, Deanna UoP Student deanna***@cableone.net Deanna Cusic skrev:
> What I have so far is: Have you checked Books online, the help that comes with SQL Server?> > USE Northwind > > ALTER TABLE Employees ADD COLUMN TerminationDate DateTime NULL > > > Server: Msg 156, Level 15, State 1, Line 3 > I keep getting "Incorrect syntax near the keyword 'COLUMN'" > > Using that you should be able to work the syntax out! Or check eg. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/sqlserver2000.asp if you don't have access to BOL. Other than that, try losing the 'COLUMN' part. /impslayer, aka Birger Johansson
Show quote
"impslayer" <impsla***@hotmail.com> wrote in message Thank you, all I did is take out 'COLUMN' and it works. I have been news:1129876626.682799.308040@f14g2000cwb.googlegroups.com... > > Deanna Cusic skrev: > >> What I have so far is: >> >> USE Northwind >> >> ALTER TABLE Employees ADD COLUMN TerminationDate DateTime NULL >> >> >> Server: Msg 156, Level 15, State 1, Line 3 >> I keep getting "Incorrect syntax near the keyword 'COLUMN'" >> >> > > Have you checked Books online, the help that comes with SQL Server? > Using that you should be able to work the syntax out! Or check eg. > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/sqlserver2000.asp > if you don't have access to BOL. > > Other than that, try losing the 'COLUMN' part. > > /impslayer, aka Birger Johansson > wracking my brain for hours over this. Deanna UoP Student deanna***@cableone.net OK, thanks for your help so far but now I am stuck on the final one. I am
trying to add an index. So far I have: use Northwind ALTER TABLE Employees ADD [idxAddress] nvarchar(60), Address nvarchar(60) the error I get is Server: Msg 2705, level 16, State 4, Line 3 Column names in each table must be unique. Column name 'Address' in table 'Employees' is specified more than once. I have tried this on many different fields including the primary keys and still get this same error. I have even pulled up the data to check for replication and did not find any. I am lost. I finally, thanks to help, have part a and b, however I need part c. When I get that I can actually get some sleep before the sun, and my children, get up ;-) -- Show quoteDeanna "Deanna Cusic" <deanna***@cableone.net> wrote in message news:11lh4epilg52q9b@corp.supernews.com... > "impslayer" <impsla***@hotmail.com> wrote in message > news:1129876626.682799.308040@f14g2000cwb.googlegroups.com... >> >> Deanna Cusic skrev: >> >>> What I have so far is: >>> >>> USE Northwind >>> >>> ALTER TABLE Employees ADD COLUMN TerminationDate DateTime NULL >>> >>> >>> Server: Msg 156, Level 15, State 1, Line 3 >>> I keep getting "Incorrect syntax near the keyword 'COLUMN'" >>> >>> >> >> Have you checked Books online, the help that comes with SQL Server? >> Using that you should be able to work the syntax out! Or check eg. >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/sqlserver2000.asp >> if you don't have access to BOL. >> >> Other than that, try losing the 'COLUMN' part. >> >> /impslayer, aka Birger Johansson >> > Thank you, all I did is take out 'COLUMN' and it works. I have been > wracking my brain for hours over this. > > Deanna > UoP Student > deanna***@cableone.net > > Deanna Cusic skrev:
> OK, thanks for your help so far but now I am stuck on the final one. I am You should look for help on creating an index, not 'ALTER TABLE'...> trying to add an index. So far I have: > > use Northwind > > ALTER TABLE Employees ADD [idxAddress] nvarchar(60), Address nvarchar(60) > The assignment question seemed to indicate an 'ALTER TABLE', but you should really search for help on 'index' instead, that would give you your desired answer! Without Books online, you might check out: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_create_64l4.asp /impslayer, aka Birger Johansson |
|||||||||||||||||||||||