ADO.NET :: Perform If Else Statement In A Stored Procedure?

Dec 2, 2010

split off from [URL]

how do i do this in stored procedure .. can you give me ane xample using if than else condition in stored procedure?

View 1 Replies


Similar Messages:

SQL Server :: Write Code Of Stored Procedure / Create Stored Procedure And Write Select Statement In It

Nov 23, 2010

how can I create stored procedure and write my select statement in it, I know how to create dataset then put type stored procedure and assign it to the sp ... what I want is writing my sp... how can I make it ?

check the following code, this is what I want to write put I don't know where or how !

CREATE STORED PROCEDURE SP_CATEGORY

@CATEGORY VARCHAR(30)

AS

BEGIN

SELECT LATIN_NAME, ENGLISH_NAME, ARABIC_NAME, CATEGORY

FROM FLORA, CATEGORY_LIST

WHERE FLORA.CATEGORY=CATEGORY_LIST.CATEGORY_NAME AND CATEGORY_LIST.CATEGORY_NAME IN (SELECT * FROM SPLITLIST(@CATEGORY, ','))

END

where can I write this code ?!

View 5 Replies

ADO.NET :: Executing Stored Procedure/ Select Statement?

Jul 29, 2010

I am executing stored procedure using session.CreateSqlQueries but it is giving me exception as {"SQL queries do not currently support returning aliases"}.

I tried doing following also but it is not working for me

[code]....

View 8 Replies

C# - Change Inline Sql Statement Into Stored Procedure?

Sep 8, 2010

I have few inline sql statements with some arrays and if loops. I want to change them all into one stored procedure in SQL server 2005.

As i am learning SQL, i have got no idea about how it should be done with arrays and if loops. Is that possible to send arrays into stored procs or is there any other solution.

[code]....

View 2 Replies

DataSource Controls :: Use A Stored Procedure In A Select Statement?

May 25, 2010

Just quick question, is it possible to Use a Stored Procedure which has a parameter in a select statement,, I mean something like the following

SELECT A, B

FROM Something

-- Something is the name of the Stored Procedure which take date parameter

View 2 Replies

DataSource Controls :: For Each Row In Select Statement - Exec Stored Procedure

Apr 21, 2010

Ive been banging my head against the wall for the last 2 days with this query I am trying to produce. I have an application that creates requests and these requests have status codes dependant on how far along in the process they are : new request, awaiting approval, approved, in progress, complete When a request is moved to the next status, it Inserts a row into an auditing table, so we can track who moved it onto the next status, along with a timestamp. There are Service Level Agreements in place that mean that a request that is currently 'In Progress' must be actioned to 'Complete' within 5 days. I have been asked to create a query that will return all records that fall outside of this SLA. My main problem is trying to Select the time from the audit log for 'In Progress' and 'Complete' status codes. It would be simple if i only had to find one of the times, as i could add a "WHERE StatusCode = 'complete' clause to the query My Audit table is structured as follows:

[RequestID] [Request Status] [UserID] [CreateDate]

So far I have been successful in querying the table by using the DATEDIFF() function as below:

SELECT
DateDiff
(day,
( SELECT
top 1 CreateDate
FROM audit_tblRequest
WHERE RequestStatus
= 'In Progress'
AND RequestID
=
@RequestID Order
by CreateDate
DESC)
,(SELECT
top 1 CreateDate
FROM audit_tblRequestWHERE RequestStatus
= 90AND RequestID
=@RequestID
Order
by CreateDate
DESC)
)

This will return the difference in days to me, however, i cannot figure out how to integrate this into a query that will be run across all RequestIDs. I was wondering if there was any way to bundle the DateDiff function into a stored Procedure and be able to call it For Each RequestID in the result set I would need to pass the requestID as a parameter, and also add some If Else logic to only return records outside of the 5 Day SLA. Im sure there are some patches in the above logic, but my brain is about to explode and I needed to type it all out before calling it a day for today.

View 3 Replies

DataSource Controls :: Is There Any Option To Use Loop Statement In MS SQL Stored Procedure

Jul 3, 2010

Is there any option to use loop statement in MS SQL Stored Procedure?

Suppose I have two tables Table-A and Table-B

Table-A

ID

Name

Phone

1

X

12354

2

Y

3689

3

Z

2578

Table-B

ID

Name

Phone

I want to insert all the values of Table-A into Table-B by using Stored Procedure

I am using MS SQL 2005

View 3 Replies

DataSource Controls :: If Statement In Stored Procedure / Checking If A Value Is A Number Between 10-20?

Jan 31, 2010

I have this stored procedure which check a collection and according to that return a result.

The problem is I want to check if a number is between 10-20 then do something

How on earth you checking something like that? I know > and < etc.. but checking if a value is a number between 10-20?

View 1 Replies

DataSource Controls :: How To Declare A Parameter Value From One Select Statement To Another In Stored Procedure

Mar 23, 2010

I have an sp that I would like to us the data from one column to use as a parameter for the following Select Statement

[Code]....

need to set the @customerID parameter = customer_data.CustomerID from the first Select Statement

View 5 Replies

SQL Server :: Sql Server Triggers Not Firing For Update Statement Executed By Sp_execute In A Stored Procedure?

Feb 27, 2011

The following stored procedure updates the value in LeaveTransaction table.

[code].,...

My Question here:

I have written the above trigger,which would update the value for the corresponding records in another table ie) LeaveCumulative table. The trigger is not updating the value in the designated rows in the leavecumulative table. Whereas when I excute the same update command separately in the Query Editor window the trigger is working fine.

View 1 Replies

DataSource Controls :: How To Convert The Oracle Stored Procedure To Sqlserver 2005 Stored Procedure

Apr 2, 2010

This is surareddy. i nead some small clarification in the "Stored Procedure"

how to convert the oracle Stored Procedure to sqlserver2005/2008 Stored Procedure.

right now i am enhancing the project that project already developed the oracle Stored Procedure. now our company is using sqlserver 2005/2008.

how to convert the Oracle Stored Procedure to sqlserver 2005 Stored Procedure

View 4 Replies

DataSource Controls :: Do Not Use Or Call Any Stored Procedure But It Says "Could Not Find Stored Procedure 'xxxxx'?

Dec 9, 2010

Initially, I have tried to use stored procedure. But I changed my mind and preferred to call sql query in codebase with command text. However, it stills tries to find initially-called stored procedure (which is neither called or exists).I think that it is related caching. But I tried it with different browsers it did not work.What might be the reason?

View 4 Replies

SQL Server :: Have A Stored Procedure Execute Another Stored Procedure During Time Period?

Jan 28, 2011

I could probably figure this out if I tried to, but I have been working so long on code, I'm a little fried

I have a stored procedure, and I want to execute another stored procedure during a time period of lets say 1/1/2011 to 12/31/2011

How Would I accomplish this?

View 4 Replies

DataSource Controls :: Execute A Stored Procedure Within A Stored Procedure?

Jan 18, 2010

Does anybody if it is possible that a stored procedure returns rows which is the result of the execution of another sp? Something like..

[Code]....

View 11 Replies

DataSource Controls :: How To Call A Stored Procedure In Another Stored Procedure

May 13, 2010

i want to return output parameter from 1 storeprocedure. into another stored procedure.

View 7 Replies

Use C# In Html To Perform If Statement?

Mar 2, 2011

I've previously seen answers on Stackoverflow that involve using 'the c# construct' to essentially perform an 'if' statement in the html of a asp.net page.

So imagine i want to display Eval("option1") if its not null OR Eval("option2") if option 1 is null. How do i do this?

View 2 Replies

Forms Data Controls :: Working Procedure With Varbinary From Existing Stored Procedure?

Feb 22, 2010

[Code]....

i have a stored procedure with this values and i need just to make a button that will send something to "Equip" column,how to do it? write the values on my webpage and make a button to exec the procedu

View 1 Replies

How To Create Stored Procedure In Sql Server And Call That Procedure From C# Code

Sep 1, 2010

I am trying to create the following stored procedure in sql server Lat and Lng are the parameters being passed from c# code behind .But I am not able to create this stored procedureit indicates with error saying undefined column name Lat,Lng

CREATE FUNCTION spherical_distance(@a float, @b float, @c float)
RETURNS float
AS
BEGIN
RETURN ( 6371 * ACOS( COS( (@a/@b) ) * COS( (Lat/@b) ) * COS( ( Lng/@b ) - (@c/@b) ) + SIN( @a/@b ) * SIN( Lat/@b ) ) )
END
sqlda.SelectCommand.CommandText = "select *, spherical_distance( Lat, 57.2958, Lng) as distance
from business
[code]...

View 1 Replies

DataSource Controls :: Call One Stored Procedure In Another Procedure For Search?

May 1, 2010

I want to apply other stored procedure select query on result of first stored procedure.

View 1 Replies

SQL Server :: How To Create Stored Procedure In Sql Server 2005 And How To Use That Stored Procedure

Oct 1, 2010

I have created stored procedure and student database and also asp.net application for asp.net page but it could not found stored procedure what is the mistake actually I don't no

View 7 Replies

Forms Data Controls :: Populate Drop Down List Using Stored Stored Procedure

Mar 14, 2010

i want data to drop down list using stored procedure .

However im not able to do that.

View 3 Replies

DataSource Controls :: Stored Procedures Are Not Showing Up Correctly In The Stored Procedure Drop Down

Apr 27, 2010

I am using Visual Studio 2008 and SQL Server 2008 and have added a SQL datasource to my form.

When I configure the datasource, I choose my connection string which looks like this in my webconfig:

<connectionStrings>

<add
name="PSFSPRD_ConnectionString"
connectionString="Data

The database I am using has a schema called EQB and as such, my stored procedures are named as EQB.usp_SelectFunds, EQB.usp_SelectAccount, etc.

On the select tab of the Configure Data Source screen, I choose to use a stored procedure. The dropdown shows my stored procedures, however, the schema name does not show up in front of the stored procedures in the drop down. I see only usp_SelectFunds, usp_SelectAccount, etc.

I select one of the stored procedures and when I click TEST, I get the message that the stored procedure is not found. If I instead choose to use a SQL statement instead on the configuration screen and enter EXEC EQB.usp_SelectFunds and click TEST, it works fine.

Why are my stored procedures not showing up correctly in the stored procedure drop down and how can I fix this?

View 3 Replies

Multiple Single-result Sql Server Stored Procedures Or Single Multple-result Stored Procedure?

Aug 9, 2010

Background: I use stored procedures exclusively for an ASP.NET application. I am using a DataReader to load a dataset object.

View 4 Replies

Can't Find Stored Procedure

Feb 17, 2011

I have migrated a database from one server to another and following the migration had an orphaned user (WholeSystem_webuser), which has been fixed using the auto_fix option of sp_change_users_login
•The WholeSystem_webuser account is used by ASP.NET pages to connect to the database and run stored procedures.

•I can log in to Management Studio as WholeSystem_webuser OK and execute the sp's from there
•When I try to run my ASP.NET page it was saying “Can’t find stored procedure [procedure name]”
•If I drop the sp and create it as [dbo].[GetContactsCount] instead of [WholeSystem_ webuser]. [GetContactsCount] it says “The EXECUTE permission was denied on the object 'GetContactsCount', database 'WholeSystem', schema 'dbo'.” (which is what I’d expect as the connection string is using the WholeSystem_webuser account??) –does that show that the web user is logging into the database OK??
•If I try and configure the SqlDataSource in VWD to see what it is looking at though, it won’t let me get beyond the connection string window and says “Default schema could not be retrieved for this connection”
•I tried setting up a new login/user/connection string but still get the
“Default schema could not be retrieved for this connection” error

IN SQL Server:
•Users mapped to the login WholeSystem_webuser - WholeSystem_webuser, default schema dbo
•User WholeSystem_webuser has default schema dbo and db_dataread and db_datawrite permissions
•There is a schema dbo whose owner is dbo, and a schema WholeSystem_webuser whose owner is WholeSystem_webuser

View 1 Replies

Sqldataapter With Stored Procedure?

Jan 5, 2010

I am using sqldataadapter for my gridview, but it doesn't talk with stored procedure. How can I use it with stored procedure?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved