473,889 Members | 1,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DECODE in SQL Server?"

N
What is the function in SQL that works like DECODE in Oracle?"

Thanks,

N

Jul 20 '05 #1
10 111293
Use CASE

--
David Portas
SQL Server MVP
--
Jul 20 '05 #2
N
SELECT CASE WHEN Assignment_Type = 'C' THEN 'Com' ELSE 'Donot Know'
FROM ASSIGNMENT

When I try to use CASE WHEN, it gave me error [Microsoft][ODBC SQL Server
Driver][SQL Server]Incorrect syntax near the keyword 'FROM'. What did I do
wrong?

Thanks

"David Portas" <RE************ *************** *@acm.org> wrote in message
news:24******** ************@gi ganews.com...
Use CASE

--
David Portas
SQL Server MVP
--

Jul 20 '05 #3
> What did I do
wrong?


You didn't read-up on the syntax first! My reply was intended as an
indication of something you should look up. You'll find Books Online is a
great resource if you refer to it occassionally :-)

SELECT CASE WHEN Assignment_Type = 'C' THEN 'Com' ELSE 'Do not know' END
FROM ASSIGNMENT

or

SELECT CASE Assignment_Type WHEN 'C' THEN 'Com' ELSE 'Do not know' END
FROM ASSIGNMENT

--
David Portas
SQL Server MVP
--
Jul 20 '05 #4
N
David,

Sorry, I don't have books online. The examples I found on the site, none of
them used "END" in the statment.

Thanks a bunch! ^_____^
N
"David Portas" <RE************ *************** *@acm.org> wrote in message
news:5M******** ************@gi ganews.com...
What did I do
wrong?


You didn't read-up on the syntax first! My reply was intended as an
indication of something you should look up. You'll find Books Online is a
great resource if you refer to it occassionally :-)

SELECT CASE WHEN Assignment_Type = 'C' THEN 'Com' ELSE 'Do not know' END
FROM ASSIGNMENT

or

SELECT CASE Assignment_Type WHEN 'C' THEN 'Com' ELSE 'Do not know' END
FROM ASSIGNMENT

--
David Portas
SQL Server MVP
--

Jul 20 '05 #5
Get BOL here:
http://www.microsoft.com/sql/techinf...00/default.asp

--
David Portas
SQL Server MVP
--
Jul 20 '05 #6
N wrote:
What is the function in SQL that works like DECODE in Oracle?"

Thanks,

N


As you know CASE is not the same as DECODE ... but SQL Server hsa no
functionality equivalent to DECODE so you will have to adapt CASE to
do the job.
--
Daniel A. Morgan
University of Washington
da******@x.wash ington.edu
(replace 'x' with 'u' to respond)

Jul 20 '05 #7
Daniel Morgan wrote:
N wrote:
What is the function in SQL that works like DECODE in Oracle?"

Thanks,

N

As you know CASE is not the same as DECODE ... but SQL Server hsa no
functionality equivalent to DECODE so you will have to adapt CASE to
do the job.

How is DECODE different than "simple CASE"?
(Other than that DECODE is a function and CASE an expression, of course...)

Cheers
Serge
Jul 20 '05 #8
You can also find the books online online at

http://msdn.microsoft.com/library/de...server2000.asp

Open up the SDK Documentation tree item.

Muhd

"David Portas" <RE************ *************** *@acm.org> wrote in message
news:5a******** ************@gi ganews.com...
Get BOL here:
http://www.microsoft.com/sql/techinf...00/default.asp

--
David Portas
SQL Server MVP
--

Jul 20 '05 #9
"Daniel Morgan" <da******@x.was hington.edu> wrote in message
news:1096932539 .547042@yasure. ..
N wrote:
What is the function in SQL that works like DECODE in Oracle?"
Thanks,

N


As you know CASE is not the same as DECODE ... but SQL Server hsa no
functionality equivalent to DECODE so you will have to adapt CASE to
do the job.
--
Daniel A. Morgan
University of Washington
da******@x.wash ington.edu
(replace 'x' with 'u' to respond)


OK, then, what does DECODE do?
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2893
by: bonnie.tangyn | last post by:
Hello all I get Too few parameters expected 2 error and "The MS Jet Database engine cannot find the input table or query "myTempTablename". Make sure it exists and that its name is spelled correctly. 3078" after I migrated "MS Access 2000" to "MS SQL Server 2000" and relinked all linked tables. The front-end interface of my application is MS Access 2000. The back-end is MS SQL Server 2000. After I migrated the database and
0
1707
by: Oliver | last post by:
> I am seeing an 'Access Denied' exception when using a "Server" "Serviced Component" >> ..are...registered in the GAC ? yes. >> ..are...the parameters serializable? um - parameters? - the method parameters? - yes think so - there's only one and it's a 'string' here's an example class that illustrates the problem:
2
8414
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
0
1281
by: Jim Moon | last post by:
Hello. We have SQL Server Stored Procedures that use the "CURRENT_USER" variable. We have SQL Server database fields that call "user_name()" as a default. That has been fine in the use and storage of user names, in the context of being called from IIS 5 and 6, from ASP 3.0 using ADODB. I'll add that the web applications are using Basic Authentication. So, individual user account names are garnered and stored. That is valuable to us.
2
3054
by: Jim Moon | last post by:
Hello. We have SQL Server Stored Procedures that use the "CURRENT_USER" variable. We have SQL Server database fields that call "user_name()" as a default. That has been fine in the use and storage of user names, in the context of being called from IIS 5 and 6, from ASP 3.0 using ADODB. I'll add that the web applications are using Basic Authentication. So, individual user account names are garnered and stored. That is valuable to us.
1
2555
by: SibAndela | last post by:
Is there a way that I can attach the uploaded file from a client web site to the web server without first storing the uploaded file on the server? Currently on my local PC (local host) the following code works but not when I run the app from a web server it fails: private void StoreFile(HttpPostedFile uploadedFile) { FileInfo uploadedFileInfo = new FileInfo(uploadedFile.FileName); ...... uploadedFileInfo.CopyTo(fileName, true); //...
3
3502
by: Jim in Arizona | last post by:
Most of the asp.net learning I've done has been from books that were written during the 1.0 framework. I didn't have a copy of visual studio when I started reading them then I got a hold of VS 2005 Beta 1, then Beta 2. I was using the <div runat="server"> statement on my projects. Once I placed a <div id="testdiv" runat="server"> within my aspx page, I could then manipulate it in the code behind like so: testdiv.visible = true...
0
5455
by: martin leer | last post by:
Hi all. I got the following error: OLE DB provider "MSDAORA" for linked server "infonet" returned message "Oracle client and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3.3 or later client software installation. Provider is unable to function until these components are installed.".
3
14647
by: Gilles Ganault | last post by:
Hello I'm getting this error while downloading and parsing web pages: ===== title = m.group(1) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 48: ordinal not in range(128) =====
0
9961
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9807
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10789
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10889
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10441
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5828
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4647
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3255
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.