SQL Server - Case function in SQL Vs iff function in access
Asked By sahirkalee
29-Jan-07 05:22 AM
Hi I'm new to SQL and I'm having an issue with the Case function. I=20
have a field which has the Amount in various currencies. The problem=20
is that Yen has no decimal places so the flat files I use to pickup=20
the data does not include any leading zero.
e=2Eg. For =A3100 the field would show as 10000 where as
Yen 100 would show as 100.
In access I had the following query
AMOUNT: IIf([Gw078p]![Curr_Code]=3D'JPY',[Gw078p]![Bal_Orig_Curr],
[Gw078p]![Bal_Orig_Curr]/100)
So if the currency was Japanese Yen I would take the figure from the=20
field otherwise just divide by 100.
How would I do something similar in SQL 2000. Any help would be=20
appreciated. Thanks.
Tibor Karaszi replied...
SELECT ...
CASE WHEN CurrCode = 'JPY' THEN Bal_Orig_Curr ELSE Bal_Orig_Curr/100 END
FROM ...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Hi I'm new to SQL and I'm having an issue with the Case function. I
have a field which has the Amount in various currencies. The problem
is that Yen has no decimal places so the flat files I use to pickup
the data does not include any leading zero.
e.g. For £100 the field would show as 10000 where as
Yen 100 would show as 100.
In access I had the following query
AMOUNT: IIf([Gw078p]![Curr_Code]='JPY',[Gw078p]![Bal_Orig_Curr],
[Gw078p]![Bal_Orig_Curr]/100)
So if the currency was Japanese Yen I would take the figure from the
field otherwise just divide by 100.
How would I do something similar in SQL 2000. Any help would be
appreciated. Thanks.
sahirkalee replied...
Thanks for replying, but I tried the in query analyser and I get the=20
message:
Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'CASE'.
SELECT *
CASE WHEN CurrCode =3D 'JPY' THEN Bal_Orig_Curr ELSE Bal_Orig_Curr/100=20
END
FROM gw078p
I'm probably doing something really stupid here. Thanks again.
On 29 Jan, 10:48, "Tibor Karaszi"=20
http://www.solidqualitylearning.com/
g2000cwj.googlegroups.com...
sahirkalee replied...
Its OK I was doing something stupid. It was Curr_code not Currcode.=20
Thanks for your help.
END
sphttp://www.solidqualityle...
27g2000cwj.googlegroups.com...
SQL Server SQL Express: Failed Reinstall Dear Setup Experts: I am trying to reinstall SQL Express after playing with it some. I uninstalled it, and now, it refuses to reinstall in the face. Any ideas what this log file means and how I can get SQL Express installed? I really do not want to have to reinstall my whole system. * ** ** Start of Log File Overall summary: Final result: SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL Server Setup. Exit code (Decimal): -2068643839 Exit facility code: 1203
SQL Server SQL Sever 2008 RC0 fail to install almost all services Hi, I've a new and clean installation of Windows 2008 Standard and I'm trying to install SQL Server 2008 RC0 but almost all services failed to install: databse engine, replication services, full-text fix it. Can someone help me, please? The Summary log file: Overall summary: Final result: SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL Server Setup. Exit code (Decimal): -2068643839 Exit facility code: 1203
SQL Server 2 questions regarding db design: check constraint and many-to-many relationship Hi, as I table called UserRoleAssignments. Should we have a primary key for such link tables? Murach's SQL Server 2005 for Developers says that link tables usually do not have a primary key. But link tables. I would recommend the following book by Louis Davidson: http: / / www.amazon.com / Server-Relational-Database-Design-Implementation / dp / 1 = 43020866X / ref = 3Dsr_1_2?ie = 3DUTF8&s = 3Dbooks&qid = 3D1233335931 like a joke, but I've seen it too often on the newsgroups. - - Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Links for SQL Server Books Online: SQL 2008: http: / / msdn.microsoft.com / en-us / sqlserver / cc514207.aspx SQL
SQL Server Replication between SQL server and SQL express ???? Dear all, I try to setup a replication between a database TEST on a server myServer into an SQL express database myDB on a Vista office PC machine. For that I define my SQL server to be a publisher of my database TEST and then on my Client PC
SQL Server SQLCLR vs. TSQL Since functions, triggers, etc. can now be accomplished with SQLCLR in addition preferred under what circumstances, and why? I still prefer to perform these tasks using T-SQL code if possible. If you wanted to, say, apply a sales commissioning method to the application, for example), then I can see the use of compiled code on the database server so as not to have the same logic twice. However, my experience has been that in this fashion - DBAs often wishing to protect their turf. Hope this helps Carl T-SQL is the right way to go. It uses the same rules as SQL 1) Maintaining code Which of the 40+ CLR languages did you want to use? Pretty you have a mixed system as each developer uses his native language rather than learn SQL. Since 80%+ of the lifetime cost of a system is in maintaining it, this is task. Several years ago, someone (I think Ben Gan) wrote a string parser in T-SQL and a CLR. First you pay to get to the CLR code, run it, and