|
-
Apr 4th, 2000, 12:37 AM
#1
Thread Starter
Addicted Member
I need to write a similiar SQL query on a SQL server.
This query determines if the "Weekday" = Monday. If it does then the DayImport result = MONDAY if it equals something other than 2 it supplies a result of OTHER. This was written in Access97 and works great. I am trying to convert my application to SQL server and can't figure this one out.
SELECT tMaster.DT_Import, IIf(Weekday([dt_import])=2,"MONDAY","OTHER") AS DayImport
FROM tMaster;
Can it be done?
-
Apr 4th, 2000, 12:58 AM
#2
Lively Member
Try this DATENAME(wk, date)
Instead of Weekday try DateName(wk,date)
see Transact SQL Help
-
Apr 4th, 2000, 11:22 PM
#3
Frenzied Member
You won't be able to use IIF as part of a sql statement on SQL server. You can, though, create a stored procedure to to the same thing...
-
Apr 4th, 2000, 11:47 PM
#4
Thread Starter
Addicted Member
Can you give me a really simple example?
Hey you seem to be using SQL server. Can I ask you anopther question. I am using a Data Control to access the SQL server. However, when I try and click on the control to move it forward, backward, etc, it just freezes on me?
Thanks
-
Apr 5th, 2000, 12:54 AM
#5
Frenzied Member
Try this:
Code:
if exists (select * from sysobjects where id = object_id('dbo.cp_getWeekDay') and sysstat & 0xf = 4)
drop procedure dbo.cp_getWeekDay
GO
CREATE PROCEDURE cp_getWeekDay
as
create table #tempWkDay (
DT_Import smallint not null,
DayImport char(6))
insert into #tempWkDay SELECT DT_Import, "Monday" FROM tMaster where dt_import=2
insert into #tempWkDay SELECT DT_Import, "Other" FROM tMaster where dt_import not = 2
SELECT * from #tempWkDay
GO
WRT your other question, I don't use controls against SQL server.
[Edited by JHausmann on 04-05-2000 at 02:25 PM]
-
Apr 5th, 2000, 01:00 AM
#6
Thread Starter
Addicted Member
Thanks for this code, I will look at it.
Why don't you use controls? I have a database that has about 25 fields associated with a customer such as name, addr, city, state, etc. It seems much easier for me to bind these to a data control rather than populate them.
I am curious how you get around this without a bunch of code. Or maybe you are writing different type of app.
Thanks
-
Apr 5th, 2000, 01:47 AM
#7
Frenzied Member
The main database I support has over 100 tables, some with hundreds of fields. The data gets moved from client apps to the servers (multiple locations) which then replicates to a central server. The central server passes data through to a single MVS DB2 database, which feeds a unix based system. The data transfer from the client to the servers is handled via a C++ based .dll. It compares the client database to the server database and, if the structures are compatible, it sends the data.
I have a handful of VB applications that access some of the data but none use a data control because I find them too restrictive. I may have to code more but my code does what I want when I want.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|