Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

same table for two applications

$
0
0

Hi,

 im using two tables  for two diferent   applications because fields in both applications are common. except in one application has one column extra ClientID

below are two tables

CREATE TABLE [dbo].[EmployeeTSDates](
	[TSID] [int] IDENTITY(1,1) NOT NULL,
	[ClientID] [int] NULL,
	[EmployeeName] [varchar](50) NULL,
	[TSStartDate] [datetime] NULL,
	[TSEndDate] [datetime] NULL,
 CONSTRAINT [PK_EmployeesTable]





CREATE TABLE [dbo].[EmpTimesheet](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ClientID] [int] NULL,
	[EmpID] [int] NOT NULL,
	[EmpName] [varchar](50) NULL,
	[StartDate] [datetime] NULL,
	[EndDate] [datetime] NULL,
	[day] [varchar](50) NULL,
	[date] [datetime] NULL,
	[Service] [nvarchar](max) NULL,
	[Venue] [varchar](50) NULL,
	[Project] [varchar](50) NULL,
	[StartTime] [varchar](50) NULL,


In one applicaion i dont need ClientID so CLientID isalways empty  but in another application it has ClientID =32

below storeprocedure for  without clientid

ALTER PROCEDURE [dbo].[Sp_EmployeeTSDates_InsertGet]@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

below procedure wih client ID

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,ClientID from EmployeeTSDates nolock where Employeename = @empName and TSStartDate = @tsStartDate end END

my issue is  do i  need to create another  two more tables(emptimesheet1,emtsdates2) for without clientID application


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>