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)
 whats wrong with this select statement

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-01-16 : 14:39:03
hi,
whats wrong with this line of code, it keeps giving me an error

select convert(date,@date) = (select fund_date from inserted)
thanks

nathans
Aged Yak Warrior

938 Posts

Posted - 2005-01-16 : 15:27:22
Can you post the error?
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2005-01-16 : 15:53:14
1)You can't assign a value to a function, in this case CONVERT. You want to perform the conversion on the right hand side of the equal sign.

select @date = convert(datetime, fund_date, 102) -- 102 = ANSI Datatime format
from inserted

I am assuming that fund_date is some type of string. I'm not sure that you want to be storing a data in a string but you know the specifics or your situation better than I ever will.

2) It appears that this code snippet comes from a trigger since you are using a table named "inserted". You are not accounting for the fact that there could be more than one row in the inserted table.

HTH

=================================================================

Scriptures, n. The sacred books of our holy religion, as distinguished from the false and profane writings on which all other faiths are based.
-Ambrose Bierce, writer (1842-1914) [The Devil's Dictionary]
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-01-17 : 05:44:44
Yes it is a trigger
and the error message is below

Server: Msg 170, Level 15, State 1, Procedure Disallow_duplicate_funding, Line 11
Line 11: Incorrect syntax near '='.
Go to Top of Page

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2005-01-17 : 06:26:51
maybe this?

select @date=convert(datetime,(select top 1 fund_date from inserted))
Go to Top of Page
   

- Advertisement -