[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Webmatrix, working with StarterSite.sdf

Posted on 2011-09-24
2
Medium Priority
?
1,180 Views
Last Modified: 2012-05-12
Hello experts!

I have two tables:

1. ONE
index, int, primary key, is identity

2. TWO
index, bigint, primary key, is identity

I want to add foreign key and connect these two tables via index field.

The problem is: these two fields are of different type.
1. Looks like I cannot change the type of the index field.
2. Looks like I can delete index field and the add another index field, problem is: I cannot make this field "is identity".

Is there any way I can solve my problem?
Is there any editor to open "StarterSite.sdf" and make some more advanced changes there?

Thank you

panJames
0
Comment
Question by:panJames
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
Daniel_PL earned 2000 total points
ID: 36594582
How would you like to connect these two tables? Would you like to have foreign key in table ONE referencing table TWO or otherways?
After addition of new column all values in new column will be NULL. Then you'll need to update those rows with values from referenced table.
See followinf example.
 
USE tempdb;
GO
CREATE TABLE ONE
(
[index] INT IDENTITY(1,1),
CONSTRAINT PK_ONE_index PRIMARY KEY ([index]));
GO
CREATE TABLE TWO
(
[index] BIGINT IDENTITY(1,1),
CONSTRAINT PK_TWO_index PRIMARY KEY ([index]));
GO

INSERT INTO ONE DEFAULT VALUES
GO 100

INSERT INTO TWO DEFAULT VALUES
GO 1000

ALTER TABLE ONE
ADD
[index_TWO] BIGINT;
GO
ALTER TABLE ONE
ADD CONSTRAINT FK_index_TWO FOREIGN KEY ([index_TWO]) REFERENCES TWO([index]);
GO

UPDATE ONE 
SET ONE.index_TWO = TWO.[index]+1
FROM TWO JOIN ONE
ON TWO.[index] = ONE.[index];
GO

SELECT * FROM ONE;

DROP TABLE ONE;
GO
DROP TABLE TWO;
GO

Open in new window

0
 

Author Comment

by:panJames
ID: 36594931
How can I use this code in webmatrix?

Has it got any sql editor?

Thank you

panJames
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question