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
 SQL Server Development (2000)
 CAST syntax

Author  Topic 

php95saj
Starting Member

43 Posts

Posted - 2002-05-08 : 12:09:36
Can anyone tell me the cast syntax. I am using it to convert a record to 1 or 0 depending on the value returned. This is something what I have:

SELECT tblAccountLogins.loginID, tblAccountLogins.Name,
CAST(SELECT tblTranslationProfileUsers.loginID
FROM tblTranslationProfileUsers
WHERE tblTranslationProfileUsers.translationProfileID = 3
AND tblTranslationProfileUsers.loginID = tblAccountLogins.loginID)
AS checked AS (Here the CAST VALUE)
FROM tblAccountLogins
WHERE customerID = 10

The reason to do so is that when I display loginID in an ASP page the checkboxes are checked for which the checked is true or something like that.

TIA



Edited by - php95saj on 05/08/2002 12:51:02

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2002-05-08 : 12:56:50
The syntax is

cast(expression as datatype)

So one way of writing your statement is

SELECT tblAccountLogins.loginID, tblAccountLogins.Name,
(SELECT cast(tblTranslationProfileUsers.loginID as int)
FROM tblTranslationProfileUsers
WHERE tblTranslationProfileUsers.translationProfileID = 3
AND tblTranslationProfileUsers.loginID = tblAccountLogins.loginID)
as checked
FROM tblAccountLogins
WHERE customerID = 10


Go to Top of Page
   

- Advertisement -