Click here to Skip to main content
15,888,816 members
Home / Discussions / Database
   

Database

 
GeneralRe: Problem with the Following SQL Query Pin
Vimalsoft(Pty) Ltd9-May-08 22:57
professionalVimalsoft(Pty) Ltd9-May-08 22:57 
GeneralRe: Problem with the Following SQL Query Pin
Blue_Boy10-May-08 1:44
Blue_Boy10-May-08 1:44 
AnswerRe: Problem with the Following SQL Query Pin
Ashfield9-May-08 22:40
Ashfield9-May-08 22:40 
QuestionForeign Key in SQL server Pin
Arun Krishnan9-May-08 1:51
Arun Krishnan9-May-08 1:51 
AnswerRe: Foreign Key in SQL server Pin
Ashfield9-May-08 3:09
Ashfield9-May-08 3:09 
AnswerRe: Foreign Key in SQL server Pin
Hesham Amin9-May-08 3:13
Hesham Amin9-May-08 3:13 
AnswerRe: Foreign Key in SQL server Pin
Arsene Cormier9-May-08 7:40
Arsene Cormier9-May-08 7:40 
AnswerRe: Foreign Key in SQL server Pin
Rob Graham10-May-08 7:12
Rob Graham10-May-08 7:12 
First, I would make the foreighn key field a NOT NULL field to prevent accidental insert without a non-null value for EMPDETAILS.EMPID.
2nd, make EMPDETAILS.EMPID have a Foreign Key constraint - this would require that the value supplied be a value that exisits in LOGIN.EMPID column
 Alter table EMPDETAILS (Alter column EMPID NOT NULL)
 ALter table EMPDETAILS ADD CONSTRAINT FK_LOGIN FOREIGN_KEY (EMPID) references LOGIN (EMPID)

  Create a stored procedure for the combined insert: 
  (use appropriate types and sizes for your tables,
  this is just an example of how, hot a solution)
Create procedure AddNewEMPID (@Empid nvarchar (20), @name nvarchar(20), @age int, @loginstuff1 varchar(10),...,@loginstuffN int)
as
begin 
 insert into login (empid, lofinstuff1,...loginstuffN) values (@empid, @loginstuff1,...,@loginstuffN);
 insert into EMPDETAILS(empid,name,age) values (@empid, @name,@age);
end


call the stored procedure with values for the parameters either in code (you didn't say what language, but most have a database library like ADO.net, ADO, ODBC etc. that support parameterized query execution)
of in sql query analizer as

exec AddNewEMPID 'empidstring','l1,...,'ln', 'name','age'

QuestionDelete and Truncate Pin
.NET- India 9-May-08 1:29
.NET- India 9-May-08 1:29 
AnswerRe: Delete and Truncate Pin
Ashfield9-May-08 1:54
Ashfield9-May-08 1:54 
GeneralRe: Delete and Truncate Pin
.NET- India 9-May-08 2:27
.NET- India 9-May-08 2:27 
GeneralRe: Delete and Truncate Pin
Brady Kelly9-May-08 2:58
Brady Kelly9-May-08 2:58 
GeneralRe: Delete and Truncate Pin
.NET- India 9-May-08 3:05
.NET- India 9-May-08 3:05 
GeneralRe: Delete and Truncate Pin
Ashfield9-May-08 3:12
Ashfield9-May-08 3:12 
GeneralRe: Delete and Truncate Pin
.NET- India 9-May-08 3:25
.NET- India 9-May-08 3:25 
GeneralRe: Delete and Truncate Pin
Ashfield9-May-08 22:32
Ashfield9-May-08 22:32 
GeneralRe: Delete and Truncate Pin
.NET- India 10-May-08 1:22
.NET- India 10-May-08 1:22 
GeneralRe: Delete and Truncate Pin
Rob Graham10-May-08 7:24
Rob Graham10-May-08 7:24 
GeneralRe: Delete and Truncate Pin
Ashfield11-May-08 20:54
Ashfield11-May-08 20:54 
QuestionORACLE Commit problem--- Error 8197 Pin
megha_gharote8-May-08 23:36
megha_gharote8-May-08 23:36 
AnswerRe: ORACLE Commit problem--- Error 8197 Pin
Arsene Cormier9-May-08 7:38
Arsene Cormier9-May-08 7:38 
GeneralRe: ORACLE Commit problem--- Error 8197 Pin
megha_gharote11-May-08 18:20
megha_gharote11-May-08 18:20 
GeneralDrop and Log Constraints Pin
Brady Kelly8-May-08 23:18
Brady Kelly8-May-08 23:18 
GeneralRe: Drop and Log Constraints Pin
Mycroft Holmes11-May-08 0:30
professionalMycroft Holmes11-May-08 0:30 
QuestionNeed Help with ADODB.Connection_InfoMessage Event in VB6 Pin
valkyriexp8-May-08 13:58
valkyriexp8-May-08 13:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.