stored-procedures

SQL Procedure to run shapshots when the mirror is connected

Hi all, first i appreciate your help, is my first time on this forum. I don't have experience writing procedures on sql, i need to schedule a job that verify the conection status on sys.databese_mirroring, if the status is 'SYNCHRONIZED' y need drop a specific snapshot and create a new one. If not i leave the last snapshot running. I us...

Ok to return a Viewmodel from repository?

Hello all, Been around here for a while but this is my first question @ so. Scenario: Mvc site. Viewmodels for most pages. Each viewmodel contains models or iqueryables acquired from different repositories. Each source is updated frequently (from outside the scoop of the site) so even if caching local it will be a lot of datasource h...

Error while invoking MySQL Stored procedure(that returns resultset) from Rails 3

I am invoking a stored procedure (MySQL) from my model. This stored procedure returns a resultset, but i get this error... Mysql2::Error: PROCEDURE loqly.sp_venue_nearby_with_questions can't return a result set in the given context:.... Here's the rails code i use - connection.select_all("call sp_some_proc()") I have trie...

Intellisense and context help for sys stored procedures - bugs or by design ?

SQL Server 2008 R2 Dev Execution in SSMS of: 1) use AdventureWorksDW; GO; sp_cdc_enable_table 'dbo', 'FactInternetSales', @role_name=NULL, @supports_net_changes=0 succeeds. Why does execution of 2) sp_cdc_enable_table 'dbo', 'FactInternetSales' --, @role_name=NULL, @suppo...

how to call one stored proc from anther and modify refcursor that is returned?

I have two stored procs, p_proc1 and p_proc2. p_proc1 returns a refcursor and I want to use the data in p_proc2. Is it possible call p_proc1 in p_proc2 and modify the dataset (outer join another table)? The database is Oracle. ...

VS2010 DB Project - moving stored proc to another schema

I've got a database under source control using a VS2010 database project. I'm trying to move some stored procs from the [dbo] schema to another schema. When I change the schema name in the project (moved in folder structure plus edited the CREATE to indicate the new schema) and deploy, I end up with a CREATE for the proc in the new sch...

Pass timestamp between Powerbuilder datawindow and SQLServer insert/update stored procedure

Hi, can anyone help me out. By implementing countermeasures in solving the concurrency problem I got troubled with passing timestamps (rowversion) between Powerbuilder 7 datawindow and SQLServer 2008 (both ways) using insert and update stored procedures. The connection is serviced by ODBC, not native. Most of my attempts result in cas...

SQL stored procedure Join question

Hi, currently the stored proc returns one record based on a employee_number that is passed as a parameter. If the surpervisor_id is NULL, there is no record returned. If I want to return a record with all the other fields, and have a NULL in the supervisor_id field, how would I configure that? SELECT DISTINCT tblPeople.PERSON_ID,...

Weird error when trying to add a stored procedure to PVCS

I'm trying to add an SQL stored procedure to our PVCS directory, and I'm seeing a weird error pop up. First, I get a dialog box containing ÿþC. When I click OK on this dialog box, I'm told that - An error has ocurred: The stored procedure code does not use the CREATE method. Please check your syntax. Despite the fact that my...

Execute a SQL stored procedure before every query generated by EntityFramework

I need to execute a SQL stored procedure every time before I query my ObjectContext. What I want to achieve is setting the CONTEXT_INFO to a value which will be later on used with most of my queries. Has anyone done that? Is that possible? [EDIT] Currently I'm achieving this by opening the connection and executing the stored procedure...

MySQL Pass table name to cursor select

I want the procedure to take parameter answertable and partid in the select statement, but when i call it it doesn't replace the parameter answertable with the value the call call updateTotalScores('quiz_participation', 'quiz_answer', 1) returns the error: 1146 - Table 'quizdb.answertable' doesn't exist passing the id works, but passi...

How to call a scalar-valued from with a stored procedure

Hi, say I have a scalar-valued function with takes two Guids as parameters: dbo.CarDistribution The two Guids area ModelId and AreaId. The function returns another Guid. Could someone please explain to me how I call this function within a stored procedure and set the result returned to a variable. I tried calling it with: CarDistri...

How to generate a new Guid in stored procedure?

Hi, I currently have a stored procedure in which I want to insert new rows into a table. insert into cars (id, Make, Model) values('A new Guid', "Ford", "Mustang") So the primary key 'id' is a Guid. I know how to create a new Guid in C# code but within the stored procedure I'm unsure how to generate the new Guids for the primary key v...

Mysql Stored Procedures - Returning Message

It's a bit silly asking homework questions here, however I'm genuinely stumped as to what this question is asking. Create a stored procedure to add results. The procedure should take four (4) parameters. These are; The student's name (first and last), the name of the apparatus and the score. When the data has been inserted,...

Calling Oracle stored procedure from C#.net?

I just started reading about stored procedures. Can anyone please help me call a stored procedure in oracle from C# Thanks in advance ...

Fetch n bind data from StoredProcedure with Join, LINQ then Split. using IMultipleResults,Linq2SQL

Hi Everybody I Have one application in it i am using stored procedure and LINQ my procedure is like myProc select col1, Col2, Col3 from Tab1 inner join Tab2 on col1=ColA join tab3 on Col1=ColD Select cola, Colb, Colc from Taba inner join Tabb on cola=ColX join tabc on Cola=ColY Select colP, ColQ, ColR from TabP inner join TabQ on...

How to create more than one stored procedure using ExecuteNonQuery?

The situation is: I want to create two stored procedures: query1 = CREATE PROCEDURE MyProc1 AS SELECT * FROM TEST1; and query2 = CREATE PROCEDURE MyProc2 AS SELECT * FROM TEST2; I can do it using command.CommandText = query1; command.ExecuteNonQuery(); command.CommandTest = query2; command.ExecuteNonQuery(); Is it possible t...

Possible for SQL stored procedure to call .NET object?

Is it possible for a SQL Stored Procedure to call a .NET object? In my situation, I need to take a string parameter and return a hashed result that can be consumed by my secure client. I can either have this SP called on a per result basis (once per row), or I can possibly return multiple rows. It all depends on what SQL will support ...

Determing if stored procedure can execute based on AD login

I have a stored procedure that updates data in a table for a specific record. I have several users who will be making use of this stored procedure however I only want to them to be able to update records that are assigned to them. Each record that is to be updated by the stored procedure has a field named "UserID" which define who has c...

DATEPART as a parameter

I'm guessing this is not possible since the engine doesn't like it, but is there a way (barring dynamic SQL) to pass in a DATEPART as a parameter to a procedure? ...