473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SQL-Kindly clarify the ambiguity

In SQL at first I created a table as follows


Expand|Select|Wrap|Line Numbers
  1. create table employee
  2. (
  3. emp_code int,
  4. sex char(1) default 'f',
  5. constraint emp_primary primary key(emp_code)
  6. )
  7.  
Table was created without any errors

Then next when i tried to create an other table as follows

Expand|Select|Wrap|Line Numbers
  1. create table employee2
  2. (
  3. emp_code int,
  4. employee_address varchar(20),
  5. constraint fk_empcode foreign key(emp_code))
I got the following error

Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'emp_code'.

Hence kindly clarify the reason for the error and also suggest a suitable way to rectify the same
Sep 7 '10 #1

✓ answered by Oralloy

Try:
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE employee2 
  2.   emp_code INT, 
  3.   employee_address VARCHAR(20),
  4.   CONSTRAINT fk_empcode FOREIGN_KEY(emp_code) REFERENCES employee(emp_code)
  5. )
You left out the REFERENCES bit

2 1069
Oralloy
988 Expert 512MB
Try:
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE employee2 
  2.   emp_code INT, 
  3.   employee_address VARCHAR(20),
  4.   CONSTRAINT fk_empcode FOREIGN_KEY(emp_code) REFERENCES employee(emp_code)
  5. )
You left out the REFERENCES bit
Sep 7 '10 #2
Oh! yes...Thank u...
Sep 7 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: cooldv | last post by:
i am running a website on Windows 2000 server with ASP 3 webpages and Access 2000 database. (with a hosting company) traffic is slow at this time but expect to grow. lately i have been reading...
5
by: george lewycky | last post by:
I am trying to take a field description for a column of about 200+ bytes and wrap the field into 3 lines of 70 bytes apiece in PL/SQL!!!!!! I know this can be done in SQL*Plus as show below but...
2
by: Peter | last post by:
I run most of my SQL scripts via kornshell on AIX. I use the "here-document" to run some of the smaller ones. Example: #!/bin/ksh # Analyze the table. sqlplus...
0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
3
by: Ira Baxter | last post by:
Hi. We are working on tools to process PL/SQL code. What we need are precise details on the full PL/SQL syntax. We have the Oracle 9/10 documentation, but it seems a little fuzzy on the...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
6
by: Fuzzydave | last post by:
I am back developing futher our Python/CGI based web application run by a Postgres DB and as per usual I am having some issues. It Involves a lot of Legacy code. All the actual SQL Querys are...
14
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.