Tag: stored-procedures

read output stored procedure that returns multiple recordsets in sql 2005

I’m trying to programmatically access the result of executing the system stored procedure sp_spaceused. if you pass the name of an object as a parameter, the sp returns a recordset which you can read like this CREATE TABLE #TempTable ( [Table_Name] varchar(50), Row_Count int, Table_Size varchar(50), Data_Space_Used varchar(50), Index_Space_Used varchar(50), Unused_Space varchar(50) ) insert into […]

How can I create an alert in SQL Server?

I have the following structure: cho_id int cho_nombre varchar(200) cho_documento varchar(15) cho_dirrecion varchar(100) cho_telefono varchar(15) cho_fec_vencimiento_lic datetime cho_categoria int est_id int I have a row of datetime type and I want that every time the date approaches send me an alert 15 days before and send me by email. How can I design this in […]

Exception management in stored procedures?

I inherited an application with a lot of stored procedures, and many of them have exception handling code that inserts a row in an error table and sends a DBMail. We have ELMAH on the ASP.NET side, so I’m wondering if exception management in the stored procs is necessary. But before I rip it out, […]

Cannot Find Stored Procedure Error

I recently did an import of database from a sql server 2000 database to a sql server 2005 database. I’ve gone through and setup what I thought were the same login credentials and owner permissions that I had previously setup in my old database. All of the code base I’m working has stored procedures listed […]

Stored Procedure Syntax

My stored procedure is called as below from an SQL instegartion package within SQL Server 2005 EXEC ? = Validation.PopulateFaultsFileDetails ? , 0 Though i’m not sure what the ? means

How to make two pivot column with same column name using SQL Server?

I wants to make two pivot column using aggregate function with same column. ItemLookupCode StoreID DepartmentID Weeks QtySold AsOfWeekOnHand ———————————————————————————- 610759C2000 1001 23 30 0 1.5 610759C2000 1001 23 31 0 0 610759C2000 1004 23 30 0 2 610759C2000 1004 23 31 0 3.5 610759C2000 1201 23 30 0.6395 1 610759C2000 1201 23 31 0.6395 […]

Stored procedure to table variable issue

What I’m trying to do is take the results from a stored procedure and put them into a temp table… Looks like this: DECLARE @Table TABLE( [ID] int, [CostA] real, [CostB] real, [CostC] real ) INSERT INTO @Table EXECUTE [dbo].[CostProcedure] @RootId = 123 @Rate = 20 –THEN: SELECT * FROM @Table — Gives Me: ID […]

How can I make a multi search SPROC/UDF by passing a tabled-value to it?

I actually want to achieve the following description This is the table argument I want to pass to the server <items> <item category=”cats”>1</item> <item category=”dogs”>2</item> </items> SELECT * FROM Item WHERE Item.Category = <one of the items in the XML list> AND Item.ReferenceId = <the corresponding value of that item xml element> –Or in other […]

SQL Server Remove multiple character strings within one string

I have the following string of text in my database: Value1 – Value2: Value3 – Value4: Value5 – Value6: I need to remove the dash AND everything between the dash up until the colon The above result would become: Value1: Value3: Value5: Basicly, there could be endless amounts of values, but there could only be […]

How to return a user defined table type from a stored procedure

I created a user defined table type in SQL Server: Create Type dbo.Car AS Table ( CarNumber varchar(20) not null, Model varchar(20) null ) There are many other fields there, this is only an example. Now I have a stored procedure that I need it to return a list of Cars from this type. Here […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.