Wednesday 15 September 2010

sql - Converting query to a stored procedure -


I have the following question that works (people have to press on, but how to ignore it is how much Is bad):

  DECLARE @submit_day DATETIME; DECLARE @meeting_day DATETIME; DECLARE @start_time_of_business_day DATETIME; DECLARE @ business_day_hoursFloat; DECLARE @submit_time DATETIME; DECLARE @meeting_time DATETIME; DECLARE @ num1 Float Dissural @ Nome2 Float Dissonal @ NM3 Floset Set @ meetinging_de = '2013-06-24'; - User Generated Variable Set @ meeting_time = '15: 45 '; - User restricted SET @submit_day = CONVERT (VARCHAR (10), GETDATE (), 101); SET @submit_time = CONVERT (VARCHAR (8), GETDATE (), 108); SET @start_time_of_business_day = '0 9: 00'; SET @ business_day_hours = 8.5; Set @ number1 = ((DateDiff (day, @submit_day, @meeting_day)) - (DateDiff (@submit_day, week, @meeting_day) * 2) - (This is the case when DatePart (DW, @submit_day) = 1 then 1 more 0 end) - (The case is when DatePart (DW, @meeting_day) = 7 then 1 and 0 end) - from intranet.dbo.bank_holiday to where the_date @submit_day and @meeting_day) * @business_day_hours SET (COUNT) Select) @ nUM2 = / 60.0 set (DateDiff (minutes, @start_time_of_business_day, @submit_time)) @ num3 = ((minute, @start_time_of_business_day, @meeting_time choose DateDiff)) / 60.0 @ Number 1 selection - @ nUM2 + @ num3 As [hour]   

so I want to set it as a stored procedure Yes, so I tried the following:

  USE [INTRANET] Go / ****** Object: StoredProcedure [dbo] [BusinessHours] Script Date: 2013/06/21 GO set QUOTED_IDENTIFIER at 15:19:47 ****** / set ANSI_NULLS Go create process [dbo] [BusinessHours] @meeting_date DATETIME, @. Meeting_teat DATETIME as DECLARE @submit_day DATETIME; DECLARE @submit_time DATETIME; DECLARE @start_time_of_business_day DATETIME; DECLARE @ business_day_hoursFloat; DECLARE @ num1 Float Dissural @ Nome2 Float Disler @ nm3 flosette SET @submit_day = CONVERT (VARCHAR (10), Gateetet (), 101); SET @submit_time = CONVERT (VARCHAR (8), GETDATE (), 108); SET @start_time_of_business_day = '0 9: 00'; SET @ business_day_hours = 8.5; Set @ number1 = ((DateDiff (day, @submit_day, @meeting_day)) - (DateDiff (@submit_day, week, @meeting_day) * 2) - (This is the case when DatePart (DW, @submit_day) = 1 then 1 more 0 end) - (case when DatePart (DW, @meeting_day) = 7 and 1 and 0 at the end) - * @business_day_hours SET between where intranet.dbo.bank_holiday the_date @submit_day and @meeting_day)) (COUNT (* select) @ nUM2 = / 60.0 set (DateDiff (minutes, @start_time_of_business_day, select @submit_time)) @ num3 = ((minutes, @start_time_of_business_day, select @meeting_time DateDiff)) / 60.0 @ No. 1 selection - @ nUM2 + @ num3 As [hours]   

this gives me an error:

message 137, level 15, state2, p. Recovery BusinessHours, line 25 should declare variable variables "@meeting_day". Message 137, Level 15, State 2, Process BusinessHours, Line 29

Scalar Variable should declare "@meeting_day".

Try searching for, but can not understand how to get it to work.

You type "meeting_date" instead of "meeting_day" in your parameter declaration.

  Create the process [dbo]. [BusinessHours] @meeting_day DATETIME, --ERROR is here @meeting_time as DATETIME    

No comments:

Post a Comment