Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Intelligent SQL Statement

Author  Topic 

jamonakes
Starting Member

18 Posts

Posted - 2006-02-15 : 11:17:43
I have a table that has the following structure:qryId, qryCellNo, qryMsg, qryM as columns. This table gets updated round the clock via sms. For first time senders, they send their sms msg, which goes to the qryMsg column, and that I can handle straight forward with the following sqlstatement: INSERT INTO tblQueryDetails (qryCellNo, qryMsg, isSeen, qryRecsToShow, qryRecordCount)Values('<telno>', '<msg>', '0','0','0'); Which works just fine. At some point the same senders (identifiable via their cell numbers) can send again a different sms with M as their msg. The problem is I want to check the msg and if it is letter M, I commit it to the qryM column and not qryMsg column of the same sender's record. If I am to commit the M msg to the qryMsg column of the same sender's record, in essence I will be overwriting the original qryMsg, or creating a new record of the same sender with M as the entry to the qryMsg column, which is what I am trying to avoid. Is there a way I can do this via SQL without the help of a 3rd party language or scripting language?

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-02-15 : 11:57:23
Author Topic
jamonakes,

Its very hard to read what u typed. Also its having lots of stuff that v don't need, which makes lesser people attempting to answer this type of Question. This appears to be a design Q which has lots of info.

After some struggle I got what ur requirement

Write a stored proc to do all sort of logics that u have. Send whatever data as parameters





Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-16 : 03:23:49
Post table structure, sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-02-16 : 09:36:21
Little known fact: Keyboards in Kenya do not come with carriage return keys, and at the moment the country is experiencing a severe indentation shortage.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-16 : 10:12:13
>> Little known fact: Keyboards in Kenya do not come with carriage return keys, and at the moment the country is experiencing a severe indentation shortage.
Ha ha. Are you serious about this ?

----------------------------------
'KH'

Time is always against us
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-02-16 : 12:09:05
I am only half-serious half the time.

Little known fact: In Singapore it is illegal to type on a keyboard while chewing gum.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-16 : 16:52:04
>> Little known fact: In Singapore it is illegal to type on a keyboard while chewing gum
You areeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee [wait.. let me remove the sticky thing from my eeeeeeeeeeeeeeeeeeeeeeeee keeeeeeeeeeeeeeey] right.

----------------------------------
'KH'

Time is always against us
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-02-16 : 21:55:30

jamonakes,
I am not sure I understand your question. But it sounds like either a simple IF block or CASE statement could do it:


if msg = 'M'
begin
INSERT tblQueryDetails (qryCellNo, qryM, isSeen, qryRecsToShow, qryRecordCount)
Values('<telno>', '<msg>', '0','0','0')
end
else
begin
INSERT tblQueryDetails (qryCellNo, qryMsg, isSeen, qryRecsToShow, qryRecordCount)
Values('<telno>', '<msg>', '0','0','0')
end

--OR maybe this:

INSERT tblQueryDetails (qryCellNo, qryMsg, qryM, isSeen, qryRecsToShow, qryRecordCount)
select '<telno>'
,case when msg = 'M' then null else '<msg>' end
,case when msg = 'M' then '<msg>' else null end
,'0'
,'0'
,'0'

Srinika,
u r 1 2 talk about difficult 2 read styles. People in gl(|) houses should not throw stones.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -