[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Using Functions In Views I.E.  Trim or iif

Posted on 2007-12-06
2
Medium Priority
?
786 Views
Last Modified: 2008-02-01
Using SQL Server 2000, I want to add a new View, such as this:

SELECT Trim([Name]) From [tblData]

or

Select iif([Age] < 30, 'Young', 'Old') From tblAges

In the first case, it tells me unrecognized function, and in the second case, it tells me it doesn't recognize it doesn't recognize the Equal sign.  

Any suggestions?
0
Comment
Question by:ssteeves
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 800 total points
ID: 20419593
sql server does not have trim, but does have ltrim and rtrim
SELECT rtrim(lTrim([Name])) From [tblData]

iif will be translated into a case statement:

Select CASE WHEN [Age] < 30 THEN 'Young' ELSE 'Old' END From tblAges
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 20419600
IFF  is not a recognised function in sql server

Select case when [Age] < 30 then  'Young' else  'Old'  end  as SomeColumn  From tblAges
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question