Re: NULL values in a SELECT in another SELECT



Just for the sake of replicating what you were trying to do, in SQL Server 2000 you can use UDF:

CREATE FUNCTION dbo.B
( @x CHAR(1) )
RETURNS CHAR
AS
BEGIN
SET @x = (SELECT y FROM Bar WHERE x = @x
UNION
SELECT y FROM Bar WHERE x = @x)
RETURN @x
END

Then you can write the query like:

SELECT x, dbo.B(x)
FROM Foo
WHERE dbo.B(x) IS NOT NULL

HTH,

Plamen Ratchev
http://www.SQLStudio.com

.



Relevant Pages

  • Re: User Defined Functions ???
    ... But UDF can be used in From clause. ... Just refer to SQL Server Books online. ... CREATE TABLE employees (empid nchar(5) PRIMARY KEY, ...
    (microsoft.public.sqlserver.programming)
  • Re: Run As Command
    ... Declare @VCHCOMMAND Char, ... if you are using BACKUP DATABASE command to backup the database then ... to use a seperate logon for the destination server. ... to SQL server bacause SQL Server cannot see that domain. ...
    (microsoft.public.sqlserver.security)
  • Re: Parameterised Query vs LookUps
    ... The data in Oracle is for all time periods but I ... > derived from a UDF in the SQL Server DB. ... > you can execute a look up against a diff connection and use this but i've ...
    (microsoft.public.sqlserver.dts)
  • Re: Maintaining Field Length in .txt format
    ... If the types are VARCHAR, ... converts them to CHAR types. ... >are on a SQL Server 2000 environment and I can create ... The header information for the feed to be ...
    (microsoft.public.sqlserver.programming)
  • Re: Merge Replication
    ... You will need to partition your ... probably involved adding another column to your tables you are replicating. ... Looking for a SQL Server replication book? ... > Identity columns. ...
    (microsoft.public.sqlserver.replication)