Hi ,
I have table with 4 columns TSID,CLientID,Startdate,enddate.right now in my application when user enters name and startdate one TSID (primary key)is created in table for one application.for another application user enters name and startdate and client one TSID is created in the same table .below is the output
TSID ClientID name statdate enddate
22 NULL Angie 2014-02-02 00:00:00.000 2014-02-08 00:00:00.000 23 NULL Alex 2014-02-02 00:00:00.000 2014-02-08 00:00:00.000 24 32 test2 2014-02-02 00:00:00.000 2014-02-08 00:00:00.000
but if user enters in two application i want to show dates related to that application .
TSID ClientID name statdate enddate 22 NULL Angie 2014-02-02 00:00:00.000 2014-02-08 00:00:00.000 23 32 Angie 2014-02-02 00:00:00.000 2014-02-08 00:00:00.000If user enters name ,start date first time in one application it insertTSID in table .second time same user enters name start date in another application its not inserting into table.
storeprocedure for insert and get with clientID
ALTER PROCEDURE [dbo].[Sp_AEmployeeTSDates_InsertGet] -- Add the parameters for the stored procedure here @empName varchar(50), @clientId int, @tsStartDate datetime, @tsEnddate datetime AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here if exists (SELECT TSID ,ClientID from EmployeeTSDates nolock where Employeename = @empName and TSStartDate = @tsStartDate) begin SELECT TSID from EmployeeTSDates nolock where Employeename = @empName and TSStartDate = @tsStartDate end else begin insert into EmployeeTSDates (Employeename,ClientID, TSStartDate, TSEndDate) values (@empName,@clientId, @tsStartDate, @tsEnddate) SELECT TSID from EmployeeTSDates nolock where Employeename = @empName and TSStartDate = @tsStartDate end END
below procedure don't have clientId
ALTER PROCEDURE [dbo].[Sp_EmployeeTSDates_InsertGet] -- Add the parameters for the stored procedure here @empName varchar(50), @tsStartDate datetime, @tsEnddate datetime AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here if exists (SELECT TSID from EmployeeTSDates nolock where Employeename = @empName and TSStartDate = @tsStartDate) begin SELECT TSID from EmployeeTSDates nolock where Employeename = @empName and TSStartDate = @tsStartDate end else begin insert into EmployeeTSDates (Employeename, TSStartDate, TSEndDate) values (@empName, @tsStartDate, @tsEnddate) SELECT TSID from EmployeeTSDates nolock where Employeename = @empName and TSStartDate = @tsStartDate end END