Member Avatar

Hi all, I wanted to procedure to return number of days and weekdays between two dates. This is what I came up with and it seems to work ok, but I'd like to read what others think. And if there's already a single line function for this, oops. Also, I'm not too comfortable with when to use @variable or just variable. Thanks. DELIMITER $$ CREATE PROCEDURE `DATEDIFF_WEEKDAYS`(IN `IN_from_date` DATE, IN `IN_to_date` DATE) BEGIN DECLARE TOTAL_WEEKDAYS INT DEFAULT 0; DECLARE TOTAL_DAYS INT DEFAULT 0; DECLARE FROM_DTE DATE DEFAULT NOW(); DECLARE TO_DTE DATE DEFAULT NOW(); DECLARE CURR_DTE DATE DEFAULT NOW(); IF(IN_from_date = …

Member Avatar
+0 forum 3
Member Avatar

How to copy a store procedure one to another database in same server I work on a project. I want copy all or single store procedure from old financial year **db_17_18** to new financial year **db_18_19** I want to do it using sql server command. i try it but showing error Please help me.... i used : SQL_Server 2008 r2 server name : shop04 **What I have tried:** **try 1** select * into DB_18_19.dbo.P_Add_FY_Data.procedures from DB_17_18.P_Add_FY_Data.procedures WHERE type_desc='SQL_STORED_PROCEDURE' **Error1 :** Msg 117, Level 15, State 1, Line 1 The object name 'DB_18_19.dbo.P_Add_FY_Data.procedures' contains more than the maximum number of prefixes. …

Member Avatar
+0 forum 2
Member Avatar

SELECT CASE WHEN (Employees.End_Date is null) THEN select EmpId, Emp_Name, Salary , Start_date , End_date ,DATEDIFF(DATE_ADD(Start_Date, INTERVAL 30 DAY), Start_Date) * Salary/30 as 'Total_Salary' from Employees ELSE Select EmpId, Emp_Name, Salary , Start_date , End_date ,DATEDIFF(End_Date, Start_Date) * Salary/30 as 'Total_Salary' from Employees END From Employees; Please help me to find error in this query. I

Member Avatar
+0 forum 1
Member Avatar

Im working through sprocs with MySQL and I came across something that made me quite uncertain... I learned sprocs with MSSQL and I am used to declaring as such: create ... myProc (@var type, @var2 type(xxx)) as .... and for declares, we declare vars as declare @var3 type(xxx), @var 4 type() ..... With mysql I have resigned to the missing @ in the proc declaration, and variables are not called via @var... However, in order to skirt the whole "cant pass a variable into a limit" issue, I basically made a prepared statement inside the proc, and execute it. However, …

Member Avatar
+0 forum 1
Member Avatar

I have a console application that I need to run a stored procedure in but I'm getting this error: a t S y s t e m . D a t a . S q l C l i e n t . S q l C o n n e c t i o n . P e r m i s s i o n D e m a n d ( ) a t S y s t e m . D a t a . S q l C l i e n t . S …

Member Avatar
+0 forum 1
Member Avatar

I return 30 tables or so from sql in a stored procedure. In the stored procedure I select these tables via... [CODE]select * from myTable1 select * from myTable2 select * from myTable3[/CODE] etc. These tables lose their sql table name when returned in a dataset and have default names of Table, Table1, Table2 etc. So how do I identify a particular table out of the now 30 'random' tables in my dataset. Thank you.

Member Avatar
+0 forum 10
Member Avatar

Hi , I am a Newbie using SQL server and vb.net in VS2010. I am re-writing an exisitng application which is written in an old programming language. I have a table with invoice records waiting to be assigned an invioce number and invoice date. I have two ways of uupdating these records , the first way is the user manually selects which records/rows to be updated for a specific customer account number. This all works fine. I am trying to write a stored proc which goes through all un-invoiced records (i.e invoice number = blank) , it is to group …

Member Avatar
+0 forum 2

The End.