Hello,
I'm writing a stored procedure. This procedure has a case where if it is met, I want to stop executing the procedure and return -1. How do I do this? Currently, I'm trying the following:
IF @result <> 1
BEGIN
SELECT -1
END
However, SELECT is not a typical "return". As you can imagine I spend most of my time ...
I would like to use a parameter in my mssql stored procedures to switch between a small and a detailed result (for maintainability, performance and network load reasons).
If parameter is set to 1 i get all columns, else only the one or two most important.
In a very limited way it works like this:
ALTER PROCEDURE [dbo].[GetAllUsers]
@d...
Hi All,
I have a stored proc (SS2008) that takes a couple int ids and needs to look up if they exist in a table before adding a record. I have an int output param I would like to return and set its value based on what occrured. I have this so far, but it always returns 1. Can someone point me in the right direction?
BEGIN TRY
IF EXIS...
I have the following tables below
City
---------
CityID
StateID
Name
Description
Reports
---------
ReportID
HeaderID
FooterID
Description
I’m trying to generate a grid for use in a .Net control (Gridview, Listview…separate issue about which will be the ‘best’ one to use for my purposes) which will assign the reports as the columns an...
For a given SQL stored proc or function, I'm trying to obtain its input and output parameters, where applicable, in a Winforms app I'm creating to browse objects and display their parameters and other attributes.
So far I've discovered the SQL system function object_definition, which takes a given sysobjects.id and returns the text of t...
We are using pl/sql profiler to collect metrics. We noticed that on one of the environment the plsql_profiler_runs table is populated with the total execution time but the finer details that gets collected in the table plsql_profiler_data is missing. Any idea why this would be happening?
We do use dbms_profiler.flush_data() before stopp...
I am learning how to use SQL and Stored Procedures. I know the syntax is incorrect:
Copy data from one table into another table on another Database with a Stored Procedure. The problem is I don't know what table or what database to copy to. I want it to use parameters and not specify the columns specifically.
I have 2 Databases (Master...
When calling a stored procedure from vb.net is there a default SQL timeout time if no timeout is specified in the connection string?
I am unsure if there is a CommandTimeout specified in the connection string but am going through all the possibilites.
Example if no results after 30 seconds (or more) throw:
`System.Data.SqlClient.SqlExc...
i have used joins to get datas from two tables under comman name. as
SELECT userValidity.UserName, userValidity.ValidFrom,userValidity.ValidUpTo,userValidity.TotalPoints,
persons.SenderID
FROM userValidity
INNER JOIN persons
ON userValidity.Username=tbl_persons.Username
but i need to execute this query with oly the username which i p...
There are a lot of information about how to write an stored procedure from a practical view, in a very database server language dependent way, but since I and the team that I work everyday already know that, I was looking for a more theoretical discussion about how to do this, in some way language or database server independent.
I want ...
I have two tables, Table A with 700,000 entries and Table B with 600,000 entries. The structure is as follows:
Table A:
+-----------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------------+------+-----+---------+-------...
I have complex logic which is not possible (too slow) to run through PHP with Doctrine, so I need to create a stored procedure for this. The logic also includes inserting/updating records in a table using the Timestampable behavior. How do I preserve this behavior in the stored procedure?
...
I would like to know how to pass an array to a stored procedure which in turn will return an array from c# .net?
...
I need to select records say 2000 from a table with a matching timestamp from c# .net code.
Eg:
SELECT *
FROM ITEMDATA_TABLE
WHERE ITEMNAME='Item1' and TimeStamp='2010-04-26 17:15:05.667'
The above query has to execute for 2000 items more for the same timestamp.
for this we can use
SELECT *
FROM ITEMDATA_TABLE
WHERE ITEMNAME in...
We have an Access application front-end connected to a SQL Server 2000 database. We would like to be able to programmatically export the results of some views to whatever format we can (ideally Excel, but CSV / tab delimited is fine). Up until now we've just hit F11, opened up the view, and hit File->Save As, but we're starting to get re...
We are running MS SQL 2005 and we have been experiencing a very peculiar problem the past few days.
I have two procs, one that creates an hourly report of data. And another that calls it, puts its results in a temp table, and does some aggregations, and returns a summary.
They work fine...until the next morning.
The next morning, s...
I have a sql script that is set to roll to production. I've wrapped the various projects into separate transactions. In each of the transactions we created stored procedures. I'm getting error messages
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'procedure'.
I created this example script to illustrate
Begin...
FYI: I am completely new to using cursors...
So I have one function that is a cursor:
CREATE FUNCTION get_all_product_promos(refcursor, cursor_object_id integer) RETURNS refcursor AS '
BEGIN
OPEN $1 FOR SELECT *
FROM promos prom1
JOIN promo_objects ON (prom1.promo_id = promo_objects.promotion_id)
...
Here is my code-behind, this adds the "OakTreeName" to the datarepeater. There's about 200 of them.
Dim cmd As New SqlClient.SqlCommand("OakTree_Load", New SqlClient.SqlConnection(ConnStr))
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection.Open()
Dim datareader As SqlClient.SqlDataReader = cmd.ExecuteReader()
OakTree_Thumb_R...
How do you write a procedure which shows that one field's value cannot be higher than another field's value, in terms of numbers. Say. an employee'a salary can't be higher than his manager's salary. I've never done one before
...