Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft SQL Server > How can I avoid...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 10948 of 11262
Post > Topic >>

How can I avoid using a cursor here?

by teddysnips@[EMAIL PROTECTED] Apr 9, 2008 at 04:46 AM

In my client's timesheet system (Intranet-hosted ASP.NET application)
there are three tables (see below for DDL).

In normal use a client can enter data into the tblTimesheetInputDetail
directly for an Employee, identified by the Employee's PinNo.
However, they want to be able to enter timesheet information for
multiple employees.  The list of these employees is in the
tblBatchTimesheetPinNos.  I don't want to use a cursor to do this, but
can't work out how to do it set-wise.

Procedurally, this is what is required.

For each @[EMAIL PROTECTED]
 in tblBatchTimesheetPinNos

    INSERT INTO tblTimesheetInputDetail
	(fldPinNo,
	fldPayrollYear,
	fldPayrollWeek,
	fldPayrollDate,
	fldEntryType)
    SELECT
	@[EMAIL PROTECTED]
    FROM
                tblBatchTimesheetInputDetail
Next @[EMAIL PROTECTED]
 thoughts on a better method?

Thanks

Edward

CREATE TABLE [dbo].[tblTimesheetInputDetail] (
	[fldID] [int] IDENTITY (1, 1) NOT NULL ,
	[fldPinNo] [int] NULL ,
	[fldPayrollYear] [smallint] NULL ,
	[fldPayrollWeek] [smallint] NULL ,
	[fldPayrollDate] [datetime] NULL ,
	[fldEntryType] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[tblBatchTimesheetInputDetail] (
	[fldID] [int] IDENTITY (1, 1) NOT NULL ,
	[fldPayrollYear] [smallint] NULL ,
	[fldPayrollWeek] [smallint] NULL ,
	[fldPayrollDate] [datetime] NULL ,
	[fldEntryType] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO


CREATE TABLE [dbo].[tblBatchTimesheetPinNos] (
	[fldPinNo] [int] NOT NULL
) ON [PRIMARY]
GO
 




 4 Posts in Topic:
How can I avoid using a cursor here?
teddysnips@[EMAIL PROTECT  2008-04-09 04:46:31 
Re: How can I avoid using a cursor here?
"Dan Guzman" &l  2008-04-09 07:08:32 
Re: How can I avoid using a cursor here?
teddysnips@[EMAIL PROTECT  2008-04-09 07:33:34 
Re: How can I avoid using a cursor here?
--CELKO-- <jcelko212@[  2008-04-09 13:49:34 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Thu Jul 24 6:03:34 CDT 2008.