SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 procedure
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

immad
Posting Yak Master

Pakistan
220 Posts

Posted - 09/23/2013 :  07:11:24  Show Profile  Reply with Quote
this is my procedure




ALTER procedure [dbo].[hh]
@EmpID VARCHAR(50),
@FromDate DATETIME,
@ToDate DATETIME,
@Dept VARCHAR(50),
@Remarks VARCHAR(50),
@CID VARCHAR(50),
@BID VARCHAR(50),
@Grade VARCHAR(50),
@UserID VARCHAR(50)
AS
BEGIN

CREATE TABLE #P2
(
CID INT,
BID INT,
EBID INT,
EmployeeCode INT,
DID INT,
Date DATETIME,
[Time IN] DATETIME,
IAttendID INT,
[Time Out] DATETIME,
OAttendID INT,
DiffHrs INT,
DiffMin INT,
Spend NVARCHAR(50),
SID INT,
Shift NVARCHAR(50),
LTime DATETIME,
HDTime DATETIME,
EarlyArival DATETIME,
ShiftTimeDiff NVARCHAR(50),
ExcShort NVARCHAR(50),
SpendTimeDiffInSec NVARCHAR(50),
EShortTimeinSEC NVARCHAR(50),
DutyHours INT,
Remarks NVARCHAR(50),
Comments NVARCHAR(50),
InBetween INT,
EShortTime NVARCHAR(50),
userid VARCHAR(50)

)
INSERT INTO #P2
EXEC [26Procedure12] @EmpID,@FromDate,@ToDate,@Dept,@Remarks,@CID,@BID,@Grade,@userid


UPDATE #P2
SET CheckTime = DATEADD(DAY, -1, CheckTime)
WHERE Status = 'O' and checktime>'2013-09-23 00:00:00.000' and datepart(hh,CheckTime) BETWEEN 0 AND 11


i want to update that after insert in #P2
is that query correct

please help me out

immad uddin ahmed

James K
Flowing Fount of Yak Knowledge

3712 Posts

Posted - 09/23/2013 :  08:26:10  Show Profile  Reply with Quote
quote:
Originally posted by immad

this is my procedure




ALTER procedure [dbo].[hh]
@EmpID VARCHAR(50),
@FromDate DATETIME,
@ToDate DATETIME,
@Dept VARCHAR(50),
@Remarks VARCHAR(50),
@CID VARCHAR(50),
@BID VARCHAR(50),
@Grade VARCHAR(50),
@UserID VARCHAR(50)
AS
BEGIN

CREATE TABLE #P2
(
CID INT,
BID INT,
EBID INT,
EmployeeCode INT,
DID INT,
Date DATETIME,
[Time IN] DATETIME,
IAttendID INT,
[Time Out] DATETIME,
OAttendID INT,
DiffHrs INT,
DiffMin INT,
Spend NVARCHAR(50),
SID INT,
Shift NVARCHAR(50),
LTime DATETIME,
HDTime DATETIME,
EarlyArival DATETIME,
ShiftTimeDiff NVARCHAR(50),
ExcShort NVARCHAR(50),
SpendTimeDiffInSec NVARCHAR(50),
EShortTimeinSEC NVARCHAR(50),
DutyHours INT,
Remarks NVARCHAR(50),
Comments NVARCHAR(50),
InBetween INT,
EShortTime NVARCHAR(50),
userid VARCHAR(50)

)
INSERT INTO #P2
EXEC [26Procedure12] @EmpID,@FromDate,@ToDate,@Dept,@Remarks,@CID,@BID,@Grade,@userid


UPDATE #P2
SET CheckTime = DATEADD(DAY, -1, CheckTime)
WHERE Status = 'O' and checktime>'2013-09-23 00:00:00.000' and datepart(hh,CheckTime) BETWEEN 0 AND 11


i want to update that after insert in #P2
is that query correct

please help me out

immad uddin ahmed

I don't think this is correct. In the update statement, you are trying to update the column CheckTime in table #P2. Yet, in the create table statement for #P2, I don't see a column named CheckTime.

Can you explain in more detail what you are trying to do?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 09/23/2013 :  12:03:52  Show Profile  Reply with Quote
1.if you're planning to use INSERT...EXEC the strcture of table should exactly match procedure output
2. If you need an additional column in table you need to create it after using ALTER TABLE ...ADD syntax and then UPDATE it

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000