SQL Server :: Case Statement Works One Way But Not The Other?

Dec 15, 2010

I have been working on a stored procedure to calculate likert scales for course evaluations. I have the stored procedure done but I ran into an interesting but frustrating situation.

I used a case statement along with a select query to count the number of responses of a given value. Likert scales are usually 5 point scales 5 being the highest and 1 being the lowest. The value that gave me the trouble was null values. In my evaluation page the instert query puts a null value in the field instead of leaving the response blank. These are the two queries I used both are syntactically correct but one works and the other doesn't. #1 Null query that works

[Code]....

Can anyone explain the differences and why one works but the other doesn't? Can it be as simple as switching the WHEN and the column name and if it is would it be advisable the other ones around?

View 4 Replies


Similar Messages:

SQL Server :: Case Statement In Where Clause?

Sep 13, 2010

i trying following query Select

View 4 Replies

SQL Server :: Case Statement To Insert New Record Syntax

Aug 5, 2010

I am using a SP to insert into tables base on the parameters but getting syntax errors on:

Msg 156, Level 15, State 1, Procedure Dyno_InsertNewItem, Line 27

View 3 Replies

SQL Server :: How To Use Case Statement In Scalar Valued Function In Sql

Feb 21, 2011

i want to get one value from function using case statement,i tried it but not work

CREATE FUNCTION [FATMS].[fnReturnByPeriod]
(

@Period INT

) [code]....

View 2 Replies

Custom Server Controls :: Case Statement Is Never Executing?

Aug 25, 2010

why the case statement is never running

[Code]....

[Code]....

View 3 Replies

SQL Server :: Using A User Defined Function In A Case Statement?

Sep 23, 2010

I created a function and am trying to access it through a case statement, but I am getting the error:

Cannot find either column "core" or the user-defined function or aggregate "core.f_FiscalYear_Open_Days", or the name is ambiguous.

The case statement is below:

CASE
WHEN c.program_id
= 5
and
CAST(minutes)
As
float)/60
>=
@MiddleSyTargetHrs
/core.f_FiscalYear_Open_Days(c.program_id,Org_Site_ID_Contract,'7-01-2009','7-31-2009')
Then 1
Else 0
End
As
mon_1_hrs

View 4 Replies

SQL Server :: Using CASE Statement In "IN" Clause Of Query?

Sep 29, 2010

I have a sql datasource with the ControlParameter called ddlDropDownList.

2 questions:

1. Is my syntax below ok, I am getting a runttime error that the syntax is incorrect.

2. I have the select statement set up the control parameter to get the selected value from the dropdownlist as shown below, is that syntax correct? especially the "selectedItem.value" for the propertyname property.

[Code]....

[Code]....

View 6 Replies

MVC :: Large Number Methods In The Controller Vs A Case Statement

Feb 11, 2011

Working on a heavy ajax based site with over 100 methods from all the ajax calls inside each of each controller all with basically the same code.Was thinking of changing them to a big case statement for readability which would keep the code a bit more dry and make it easier to read.What I am wondering is: Will there be a performance hit and is there a better way to deal with it?

View 4 Replies

DataSource Controls :: Case Statement Assign Values Based On Condition?

Feb 2, 2010

I need to modify the results (NULL) to reflect '0.00'.

My query statement is giving me an error at the CASE level.

[code]...

View 3 Replies

Root Path With Tilde - Doesn't Change Upper Case To Lower Case

Dec 30, 2010

I have my project set up with the virtual path "/MyVirtualPath", create the virtual directory in IIS 6 (W2003) and everything works fine. Then to work better with Google Analytics I change the virtual path "/myvirtualpath" and change all redicecciones and links to lowercase. also applies the class "lowercase route urls in aspnet mvc" and works perfectly.

The problem I had to modify the virtual directory in IIS, delete virtual path "/MyVirtualPath" and I created the new "/myvirtualpath", but in all cases I use tilde "~" or where I make a "RedirecToAction" (which should take "LowercaseRoute"), continues to maintain the virtual path "/MyVirtualPath". For example, if I see the HTML source code in the browser, see "/MyVirtualPath/Content/Site.css" instead of "/myvirtualpath/Content/Site.css. "

View 1 Replies

SQL Server :: Calculation In Case Don't Work?

Jul 15, 2010

I have below sql statement wich don't work. It don't come up with an error but votepercentage is 0 and when I calculate it manually it should come up with

Dog = 5/9*100 = 55,55
Cat: 4/9*100 = 44,44
in votepercentage

My code:

[Code]....

The result for above code:

Dog 5 0
Cat 4 0

I triple checked that questionAnswersCount is 9 Anyone who can tell me what is wrong with this line:

(CASE WHEN pa.answersCount = 0 THEN 0 ELSE Convert(decimal, ((pa.answersCount/pq.questionAnswersCount) * 100)) END) as votepercentage

View 3 Replies

SQL Server :: CASE Or Conditional View?

Dec 9, 2010

I have a [Permission] and [Unit] table (permissions types are to view, update, add, ... records). One of the [Unit]'s is "1" for "ALL Units". What I want to do is use either a CASE or IF statement in my view which will pair every [UnitId] (except "1" ofcourse)
if/when the [UnitId] is set to "1".

Here are my view as-is:

[Code]....

Which results in: [Code]....

What I want is: [Code]....

View 3 Replies

SQL Server :: ORDER BY CASE Is Not Working

Jan 19, 2011

I am having trouble with my ORDY By Case Statement. It doesn't seem to be ording correctly. To see it in action, please go to [URL] and click on "latin" and it should change the sort order and when you click back on "common" it should change it back but it doesn't. Here's my code:

[Code]....

View 17 Replies

SQL Server :: Setting Up The CASE Keyword In SQL From Web App?

Mar 7, 2011

I was wondering how I would go about setting up the CASE keyword in SQL from my Web app. I have a table where I need to update anywhere between 20 and 300 rows with different values. My table looks like this

ID EventID SeatType SeatCount Status Comments

On my page, these rows are listed in a table with a textarea to add comments. So when I click a button I need to update All the comments for all the users of a certain "EventID".I think my SQL Statement should go something Like this:

UPDATE Events
SET Comments =
CASE [code]....

Is that correct? I would be getting the ID and comment from each row of the table. Also (using C#) what would be the most efficient way to get this information into the query? I was thinking to use a for statement but I hear many string concatenations requires lots of processing?

[Code]....

View 7 Replies

SQL Server :: (INSERT EXEC Statement Cannot Be Nested.) And (Cannot Use The ROLLBACK Statement Within An INSERT?

Sep 25, 2010

have a very important issue,i have three Stored Procedures Sp1,Sp2 and Sp3 .the first one (Sp1) will execute the second one (Sp2) and save returned data into @tempTB1 and the Second one will execute the third one (Sp3) and save data into @tempTB2.if I execute the Sp2 it will works and it will returned me all my data from the Sp3 ,but the problem is in the Sp1, when i execute it it will display this Error:INSERT EXEC statement cannot be nested I tried to change the place of execute Sp2 and it display me another error:Cannot use the ROLLBACK statement within an INSERT-EXEC statement.

View 4 Replies

Delay In The Development Server Response In Case Of A Postback,in Website?

Jan 18, 2010

I am working on an Asp.net webiste.The response time(in case of a postback) of the pages in the website is ok on my local machine.But when I uploaded the same website to the internal development server and tried to access the server pages from my local machine,its taking bit long(in case of a postback) as compared to my local machine.I do not understand why the same webiste runs slowly on the dev server..

Following is the configuration of dev server.

Microsoft Windows Server 2003 R2 Enterprise Edition service pack 2
Intel(R) Xeon(R) CPU
E5450 @ 3.00GHZ
3.23 GHZ,2.00 GB of RAM
Physical Address extension

Following is the configuration of my local system

Microsoft Windows XP Professional Version 2002 service pack 2
Intel(R) Pentium(R) Dual CPU
E2180 @ 2.00 GHZ
2.00GHZ,1.99 GB of RAM.

View 1 Replies

AJAX :: Method Error 500 (code WORKS On Dev Server, FAILS On Prod. Server) / How To Fix It

Nov 8, 2010

Locally I have the cascading dropdown which loads countries in a cascading dropdown working.

But as soon as I place the code on the hosting server, Firebug shows me an:

500 Internal Server Error - [URL]

The cascading dropdown just shows "[Method error 500]"

REMEMBER: IT WORKS ON MY LOCAL SERVER!!!

local configuration:

Windows 7
IIS7.5
ASP.NET4

server configuration:

Windows Server 2008
IIS7.5
ASP.NET4

So it almost MUST be something on my hosting server! :s I dont know what to configure though...

[code]....

View 5 Replies

Web Forms :: HttpContext.Current.Server.MapPath Within Server Control Works?

Sep 30, 2010

Does anyone knows why HttpContext.Current.Server.MapPath within a server control works when I run the server control but gives and error whilst in Design mode?

View 2 Replies

Forms Authentication Works On Dev Server But Not Production Server (same SQL Db)?

Feb 7, 2010

I've never had this problem before, I'm at a total loss.

I have a SQL Server 2008 database with ASP.NET Forms Authentication, profiles and roles created and is functional on the development workstation. I can login using the created users without problem.

I back up the database on the development computer and restore it on the production server. I xcopy the DLLs and ASP.NET files to the server. I make the necessary changes in the web.config, changing the SQL connection strings to point to the production server database and upload it.

I've made sure to generate a machine key and it is the same on both the development web.config and the production web.config.

And yet, when I try to login on the production server, the same user that I'm able to login successfully with on the development computer, fails on the production server.

There is other content in the database, the schema generated by FluentNHibernate. This content is able to be queried successfully on both development and production servers.

View 2 Replies

C# - Uploading Files To Varbinary(max) In SQL Server -- Works On One Server Not The Other

Jun 16, 2010

I have some code that allows users to upload file attachments into a varbinary(max) column in SQL Server from their web browser. It has been working perfectly fine for almost two years, but all of a sudden it stopped working. And it stopped working on only the production database server -- it still works fine on the development server.

I can only conclude that the code is fine and there is something up with the instance of SQL Server itself. But I have no idea how to isolate the problem.

I insert a record into the ATTACHMENT table, only inserting non-binary data like the title and the content type, and then chunk-upload the uploaded file using the following code:

[code].....

View 1 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

Show Download Dialog Box In Case Of File Download - Located On Amazon Server

Jan 4, 2010

i am using amazon s3 service. now i want to show download dialog box in my asp.net application when user come on download page. i am using amazon sdk.

View 1 Replies

Forms Data Controls :: Text Validator Case-sensitive / Change The Server-side validator?

Dec 13, 2010

I have a validator on a textbox that validates against a list to ensure that the user doesn't input the same name. When testing it, if I type in the same name including the same case structure, it returns an error. If I change one letter to a different case, it doesn't return an error but rather my SQL server returns a duplicate error. How do I change the server-side validator so that it picks up duplicate names regardless of case?

View 4 Replies

Configuration :: VB.Net IF Function Works On One Server But Not Another

Aug 27, 2010

I have two web servers plus my desktop. I use Visual Studio 2008 to generate asp.net pages. I put a statement like:

response.write("Testing if function: " & if(0>1,"true","false") & "<br />")

in a code-behind file (test.aspx.vb). When I type it, Intellisense clearly recognizes the IF function and gives me guidance on the two overloaded versions. When I Build the page, it gives no errors, but when I View in Browser, I get an error: "BC30201: Expression expected." with the compiler details pointing to the IF. When I run the page on my test server, I get the same result, but when I run it on my production server, it works just fine.

View 5 Replies

URLMapping Works On Local But Not On Server?

Aug 11, 2010

I'm using VS2010 and on my local machine, using web.config to map one url to another works fine, using the tag. However, as soon as I upload to the IIS6 server it doesn't work at all! Is there something about IIS6 that doesn't support this feature?

View 1 Replies







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