Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6212013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:26:14+00:00 2026-05-24T06:26:14+00:00

First time using this database because I need a type that’s portable and so

  • 0

First time using this database because I need a type that’s portable and so far it’s been a headache. I can’t seem to figure out what’s wrong with the code.

Here’s what I’m trying to run – it’s in Spanish but you get the gist of it:

create table UsuarioRol
(
UsuarioRolId int primary key identity(1,1),
Nombre nvarchar(64) not null,
NivelAutoridad int not null
)

create table Usuario
(
UsuarioId int primary key identity(1,1),
UsuarioRolId int foreign key references UsuarioRol(UsuarioRolId),
Login nvarchar(64) not null,
Password nvarchar(64) not null
)

I get the error:

————————— Microsoft Visual Studio
————————— SQL Execution Error.

Executed SQL statement: create table UsuarioRol

(

UsuarioRolId int primary key identity(1,1),

Nombre nvarchar(64) not null,

NivelAutoridad int not null

)

create table Usuario

(

UsuarioId int primary key identity(1,1),,

UsuarioRolId int foreign key references Usua… Error Source: SQL
Server Compact ADO.NET Data Provider Error Message: There was an error
parsing the query. [ Token line number = 8,Token line offset = 1,Token
in error = create ]

————————— OK Help

I don’t understand what might be wrong in the syntax. Am I missing something here?

Even tried this, and I get the same error.

Running the exact same TSQL on a regular ol’ SQL Server database, runs perfectly.

Can I conclude that SQL Compact doesn’t support foreign keys?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:26:15+00:00Added an answer on May 24, 2026 at 6:26 am

    I’m not sure if that syntax is supported with SQL Server CE. The following should work:

    create table UsuarioRol
    (
    UsuarioRolId int primary key identity(1,1),
    Nombre nvarchar(64) not null,
    NivelAutoridad int not null
    );
    GO
    
    create table Usuario
    (
    UsuarioId int primary key identity(1,1),
    UsuarioRolId int,
    Login nvarchar(64) not null,
    Password nvarchar(64) not null
    )
    GO
    
    ALTER TABLE [Usuario] ADD CONSTRAINT [FK_Usario_UsarioRol]
        FOREIGN KEY ([UsuarioRolId]) REFERENCES [UsuarioRol]([UsuarioRolId]);
    GO
    

    Update:

    Actually, what you had should work, just remove “foreign key” in the syntax:

    create table UsuarioRol
    (
    UsuarioRolId int primary key identity(1,1),
    Nombre nvarchar(64) not null,
    NivelAutoridad int not null
    );
    GO
    
    create table Usuario
    (
    UsuarioId int primary key identity(1,1),
    UsuarioRolId int references UsuarioRol(UsuarioRolId),
    Login nvarchar(64) not null,
    Password nvarchar(64) not null
    );
    GO
    

    Or this should also work:

    create table UsuarioRol
    (
    UsuarioRolId int primary key identity(1,1),
    Nombre nvarchar(64) not null,
    NivelAutoridad int not null
    );
    GO
    
    create table Usuario
    (
    UsuarioId int primary key identity(1,1),
    UsuarioRolId int,
    Login nvarchar(64) not null,
    Password nvarchar(64) not null,
    foreign key (UsuarioRolId) references UsuarioRol (UsuarioRolId)
    );
    GO
    

    Source: http://msdn.microsoft.com/en-us/library/ms173393(v=SQL.110).aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this XML classes for the first time and can't find this piece
This is my first time using joomla. I don't know if I'm using the
this is my first time using StAX for parsing XML documents (still in the
I'm fairly new to both Django and Python. This is my first time using
This is the first time ever I'm using AJAX, and I want to do
I'm using this line to get the beginning time of the first day of
I'm looking at using ELMAH for the first time but have a requirement that
First time using Asp.net-mvc and originally followed the NerdDinner tutorial. My form submit button
I'm writing a facebook desktop application for the first time using the PyFacebook api.
I'm currently trying to access a REST API for the first time using visual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.