stored-procedures

SQL Server 2005 - Find Which Stored Procs Run To A Particular Table

Is there a quick way that I can find which stored procedures run to a particular table in my database? The database is very large with lots of tables and SPROCS.... ...

Procedure resuming even after the error

Below is my procedure in SQL Server 2005 PROCEDURE [dbo].[sp_ProjectBackup_Insert] @prj_id bigint AS BEGIN DECLARE @MSG varchar(200) DECLARE @TranName varchar(200) DECLARE @return_value int -- 1. Starting the transaction begin transaction @TranName -- 2. Insert the records SET IDENTITY_I...

Running managed code in SQL Server 2008 - any issues?

I would like to know the performance issues associated with running managed code through SQL Server 2008. I've heard about some memory and speed issues. Specifically, I want to implement a SHA256 hashing DLL and execute it as a sproc with SQL Server 2008. Alternately, I could simply execute the hashing from my .Net app, then pass the ...

Postgres STRING_TO_ARRAY alternative? Like STRING_TO_RECORD ?

I need to convert a comma separated text into a set of records. I created this function but I am not convinced that the best way: CREATE OR REPLACE FUNCTION F_StringListToRecord(pStringList TEXT, pDelimiter VARCHAR(10)) RETURNS SETOF RECORD AS $$ DECLARE vIndex INT; arrSize INT; arrValue TEXT[]; BEGIN arrValue := STRING_TO_ARRAY...

Recover Generated Ids from Multiple Insert Query

I want to execute a query of the form: INSERT INTO table(field1, field2) SELECT field1, field2 FROM table WHERE id IN ( 4, 8, 15, 16, 23, 42 ) Where id is the auto_increment'ing primary key of table. After executing this statement, I want to know what all the new id's that just got generated are. How can I recover this information? I'...

Debugging both .net and stored procedure in VS 2008 together

I know we can debug the stored procedures in Visual Studio but is it possible to debug the .NET code and Stored Procedures together? I mean if my .NET code calls a stored procedure, whether my debugger will still continue with the stored procedure step by step. ...

SSE 2005 stored Procedure working in management studio but not in C# DAL

I have created a stored procedure CREATE PROCEDURE GetCustomerWiseSales(@StartDate nvarchar(10), @EndDate nvarchar(10)) AS SELECT C.cCode, min(C.cName) as Customer, sum(P.BeerValue) as BeerValue, sum(P.RestGroup)as RestGroup from Customers C Join ( SELECT Sales.CustomerID, SUM(SalesLog.Quantity * SalesLog.Price) as BeerValue, 0 Re...

import Select SQL Query StoredProcedure using EntityFramework 4 in Asp.Net and C# Visual Studio 2010

I am trying to import stored-procedure using the entity framework 4 in Asp.Net,MVC and C#. But when i try to update the model into entity diagram(*.edmx) it will updated into the Entity-name.Store inside Stored-procedure folder. Stored-Procedure CREATE PROCEDURE Sp_Feedback AS BEGIN Select f.User_Id,f.Over_All_Rating,f.Features_Liked,f...

How to drop Stored Procedures in a SQL 2000 + SQL 2005 compatible manner?

I have a project that requires me to do development in SQL Server 2005, but do deployments to a SQL Server 2000 box. For 99% of the SQL code, I have no problems, everything appears to be backwards compatible. Now I am just about to start adding all the Stored Procedures (SPs) to source control, and I like the idea of doing a drop-add e...

How to find out what user a SQL stored procedure accesses network shares as?

I've been asked to find out why a program is failing. I've traced it to a SQL stored procedure. The program passes in the name of a file that the st. proc. presumably tries to read. However, the SQL server is returning an error indicating that it cannot access the file because access is denied. My connection string says Integrated Se...

CrystalReport and Stored Procedures using C# Question

Hello everyone, I have an application which needs to generate a report. However, I do not know how to generate a report using CrystalReport which is based on a query. Let's say I just need to generate report from my database which shows the values returned by my select query. I've never used Crystal Reports before so I'm new to this. ...

TSQL how do you iterate through rows while parsing them?

Sorry for the poor question wording I wasn't sure how to describe this. I want to iterate through every row in a table and while doing so, extract a column, parse the varchar that is in it and depending on what it finds insert rows into another table. Something along the lines of this: DECLARE @string varchar(max); foreach row in (selec...

Transaction in VS2008 and SQL Server 2005 Stored Procedure

If I'm already using transactions in my stored procedure, is it feasible to use transactions in VS 2008 to call the procedure multiple times? What I am trying to do is re-use my insert single record stored procedure which already uaes transactions. I want to insert multiple records using this insert single record stored procedure, and r...

Unable to use a Stored Procedure with my Entity Framework v4 + POCO's :(

Hi folks, I've got a very simple Entity Framework project with POCO Entities. I've got a single stored procedure which I have imported using the EF Wizard. Kewl. I've then made my own EF Entity which I've then Add Function Import to map the Stored Procedure to my EF Entity. Now ... I'm not sure how to map my EF Entity to a POCO. As su...

Possible to use the Repository Pattern + Stored Procedures ? Should / can they return IQueryable?

Hi folks, I'm a big fan of using the Repository pattern to return IQueryable<T> objects. I then let my services layer determine what does what (eg. filter by XXX, order by YYY, project into ABCD, etc). But I've got some hardcore DB stuff, so I've got it all wrapped up into a Stored Procedure. Works fine. I know EF can execute stored pr...

What is the syntax to drop a Stored Procedure in SQL Server 2000?

Simple question, as the title suggests: What is the syntax to drop a Stored Procedure (SP) in SQL Server 2000, by first checking that the SP exists? Please provide the full code. ...

If I restore a database and overwrite the original is there any way to go back? SQL Management Studio

I do not have a backup available but I wrote over an existing database with a backup file. The problem is the one I wrote OVER had a Stored Proc that I need to get back. Any way to do this without a backup file of the database with the Stored Proc in it? ...

SQL Server 2008 Backup failes: BACKUP DATABASE is terminating abnormally

I have a stored procedure, which performs a database backup for a specific database. The problem is, it does work on one server and does not work on another server (the servers are on different machines). The backup drive is a local drive of the server. On the second server I get the exception "BACKUP DATABASE is terminating abnormally."...

Stored procedure times out when ran from code, but not from query tool

I am trying to figure out why a stored procedure call takes seconds in a SQL server express query window, but when I run call the stored procedure in code the query TIMES OUT. We are using sql server 2008. I know it is hard to say exactly what is going on without seeing the stored procedure. I'm just hoping this is a known issue. Any...

Is it possible to get the mac address using a stored procedure?

Was wondering if it was possible to get the mac address of the server using a stored procedure? I did some searching for a while but found nothing. This is using SQL2008. Update Unfortunately the answer that uses newsequentialid() can return the wrong MacAddress if there is VMWare on the server. ...