donpick
asked on
Table variable and constraints
Running SQL server 2000 on Windows 2000 server
I have created a table variable. I cannot seem to assign a primary key.
I get the error:
Incorrect syntax near the keyword 'CONSTRAINT'.
See my code below:
What am I doing wrong?
I have created a table variable. I cannot seem to assign a primary key.
I get the error:
Incorrect syntax near the keyword 'CONSTRAINT'.
See my code below:
What am I doing wrong?
DECLARE @tblAmibrokerRawTemp table
(Symbol varchar(7) NOT NULL ,
EntryDate smalldatetime NOT NULL
CONSTRAINT tblAmibrokerRawTemp_PK PRIMARY KEY(Symbol, EntryDate),
Active smallint NOT NULL DEFAULT 1)
i dont think you can do that with a table variable, you need to convert that into a temp table
you can assign pk's on table variables
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is not documented anywhere I can find. Thank you for your help.
it is documented,
see syntax part of table datatype from here
http://msdn.microsoft.com/en-us/library/ms175010.aspx
see syntax part of table datatype from here
http://msdn.microsoft.com/en-us/library/ms175010.aspx
Open in new window