stored-procedures

Calling sp_rename ( or other sp_ ) for SQL server 2008 from .Net Code

Is my the only option to wrap sp_rename or similar into stored procedure and then sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; sqlCommand.ExecuteNonQuery(); ...

sybase 'drop procedure'. can I get it to take a parameter instead of a naked proc name?

Happy Monday o/ I'm looking to do the following within a stored proc select @parameter="fooproc" drop procedure @parameter instead of drop procedure fooproc But it's choking with a syntax error. Is there some way I can bend this to my will? I would've expected to be able to do this. I've tried a few permutations of type de...

can we have a stored procedure with output parameters and return statement?

Hi,Can a stored procedure have output parameters and return statement? If so can anybody give me a simple example.thank you all. ...

Entity Framework with 'Get' Stored Procedure that returns Entities

Hello, I am attempting to execute a stored procedure that returns data with exactly the same columns as that of a table Entity I have in my project. I set the 'Returns a Collection Of' property in the 'Add Function Import' dialog to my entity type. I get a NullReferenceException error when executing the stored procedure and on further ...

How can I map stored procedure result into a custom class with linq-to-sql?

I have a stored procedure that returns a result set (4 columns x n Rows). The data is based on multiple tables within my database and provides a summary for each department within a corporate. Here is sample: usp_GetDepartmentSummary DeptName EmployeeCount Male Female HR 12 5 7 etc... ...

MySQL SELECT, store in a variable

For a stored procedure, I want to do a SELECT, and store a column's value into a variable. How do I do this? I want to do something like this: DECLARE countTemp INT; SET countTemp=(SELECT COUNT(Name) FROM mytable WHERE Name= var_name LIMIT 0,1); OR, like this : DECLARE countTemp INT; SELECT countTemp=ColumnXYZ FROM ...

.NET framework execution aborted while executing CLR stored procedure?

I constructed a stored procedure that does the equivalent of FOR XML AUTO in SQL Server 2008. Now that I'm testing it, it gives me a really unhelpful error message. What does this error mean? Msg 10329, Level 16, State 49, Procedure ForXML, Line 0 .NET Framework execution was aborted. System.Threading.ThreadAbortException: Thread was...

Dynamic sql vs stored procedures - pros and cons?

I have read many strong views (both for and against) SPs or DS. I am writing a query engine in C++ (mySQL backend for now, though I may decide to go with a C++ ORM). I cant decide whether to write a SP, or to dynamically creat the SQL and send the query to the db engine.# Any tips on how to decide? ...

How to create item templates for SQL files, for Visual Studio Database Projects

It's possible to define your own custom templates for normal project types, such as templates for C# files, for a Class Library project. What about a 'Database Project' scenario? I would like to define a standard template for adding a stored procedure, which uses the company's conventions for all stored procedures, such as standard com...

IQueryable<> from stored procedure (entity framework)

I want to get IQueryable<> result when executing stored procedure. Here is peace of code that works fine: IQueryable<SomeEntitiy> someEntities; var globbalyFilteredSomeEntities = from se in m_Entities.SomeEntitiy where se.GlobalFilter == 1234 select se; I can use this to apply global filter, and later use result...

Can I Use ASP.NET Wizard Control to Insert Data into Multiple Tables?

Hello All, I have an ASP.NET 3.5 webforms project written in VB that involves a multi-table SQL Server insert. That is, I want the customer to input all their contact information, order details etc. into one control (thinking wizard control). Then, I want to call a stored procedure that does the insert into the respective database tab...

PL/SQL time segment calculation

Hi, I need to figure how much time passed between 2 times. For example: (14:00:00 - 13:15:00) * 24 = .75 I need this to later on convert KW to KWh, but that's not the point. I can not find out how to do this in PL/SQL. My date/time fields look like this in the DB: 1/23/2010 21:00:00 I would appreciate any suggestions. Steve ...

Stored Queries?

Is it considered crazy to store common SQL queries for my web app in a database for use in execution? Or is that common practice? Or is it impossible? My thinking is, this way, I avoid hard-coding SQL into my application files, and add another level of abstraction. Is this crazy? Is this what a stored procedure is? Or is that somethin...

Merging results of two stored procedures

I have a SQL query too long to process. So I remembered to share in some stored procedures. Is there a way to attach the result of several stored procedures? ...

Stored Procedure in postgresql, multiple queries w/ agreggates.

I'm trying to write a store procedure that can take some input parameters (obviously), run multiple queries against those, taking the output from those and doing calculations, and from those calculations and the original queries, outputting a formatted text string like: Number of Rows for max(Z) matching condition x and y of total rows ...

Interesting SQL Sorting Issue

It's crunch time, deadline for my most recent contract is coming in two days and almost everything is complete and working fine (knock on wood) except for one issue. In one of my stored procedures, I'm needing to return a result set as follows. group_id name -------- -------- A101 Craig A102 Craig Z101 ...

Stored Procedure for Multi-Table Insert Error: Cannot Insert the Value Null into Column

Good Evening All, I've created the following stored procedure: CREATE PROCEDURE AddQuote -- Add the parameters for the stored procedure here AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; Declare @CompanyName nvarchar(50), @Addr nvarchar(50), @City nvar...

How to access data using VBSCRIPT from a stored procedure which contains values in Temp table ?

Hi , for testing purpose I wrote a VBscript which will fetch values from Sybase by executing a stored procedure which contains values in temp table. When I run the script I get the following errors , "Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record." or "Item cannot b...

How to pass a table from frontend to a stored procedure?

I want to pass a table as a parameter to a stored procedure. Is it possible to do it. Please give some example. ...

how to take the year using date stored in DataBase:

how to take the year using date stored in DataBase: in Sql query ?? ???? eg date stored as 2010-04-29 15:53:09.577 how to get the year in stored procedure to check whether the year i pass and the year stored in database are same ...