Please help me correct the syntax error

user3561219

I get the an error when I execute the query below. what I'm doing wrong?

Msg 512, Level 16, State 1, Line 3 Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

select

     so.name 'Table Name'
    ,so.id 'Table ID'
     ,so.xtype
     ,sc.name 'Column Name'
     ,sc.id 'Column ID'
     ,sf.constid
     ,sf.fkeyid 'Object ID of the table with FOREIGN KEY'
     ,sf.rkeyid 'Referenced Table ID'
     ,(select o.name 'Referenced Table' 
    from sysforeignkeys f
     inner join sysobjects o
      on o.id=f.rkeyid
      where o.xtype='U') 

    from sysobjects so
   inner join syscolumns sc 
    on so.id=sc.id
      inner join sysforeignkeys sf
     on so.id=sf.fkeyid 
     where so.xtype='U'
    and (sc.name like 'SSN'
     OR sc.name LIKE 'ssn%'         
     OR sc.name LIKE 'ssn%'         
      OR sc.name LIKE '%_ssn%'          
    OR sc.name LIKE '_ocsecno'          
    OR sc.name LIKE 'Ssn%');
Stephan

I don't think your subquery is correct as it has no way of referencing your sysobjects aliased "so". Try this instead. Also I don't think you need such a long where clause.

select so.name      [Table Name]
        ,so.id      [Table ID]
        ,so.xtype
        ,sc.name    [Column Name]
        ,sc.id      [Column ID]
        ,sf.constid
        ,sf.fkeyid  [Object ID of the table with FOREIGN KEY]
        ,sf.rkeyid  [Referenced Table ID]
        ,zz.name    [Reference Table]
from sysobjects so
inner join syscolumns sc     on so.id = sc.id
inner join sysforeignkeys sf on so.id = sf.fkeyid 

--Use a join here for the reference table column
inner join sysobjects zz     on zz.id = sf.rkeyid

where   so.xtype='U'
        AND(
            sc.name LIKE '%ssn%'
            OR sc.name LIKE '_ocsecno'
            )

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Could someone please help me with why is this happening? Python invalid syntax error

From Dev

Please help me debug this error about for/in in Javascript

From Dev

Null Pointer Exception Error .Please help me

From Dev

Please help me debug a stripe error

From Dev

Please help me understand unfamiliar struct syntax in C

From Dev

SyntaxError: Unexpected token ILLEGAL. Please help me insert syntax

From Dev

i have a syntax error help me

From Dev

Please help me debug this error message I get at the console

From Dev

AngularJS small test, help me find the error please

From Dev

Please can anyone help me to find out the error in the xml file

From Dev

Please help me debug the error:java.lang.NullPointerException

From Dev

AngularJS small test, help me find the error please

From Dev

Please help me find error - program which shows prime numbers

From Dev

Please help in finding the error

From Dev

Please help me with a recursive function

From Dev

Please help me understand Arrays

From Dev

Please help me delete a file?

From Dev

Please help me with this collision detection

From Dev

Please help me open it "xampp"

From Dev

Help me with broken packages please

From Dev

can you help me please

From Dev

Parse error: syntax error, unexpected T_FUNCTION Please help includes/theme_filters.php

From Dev

Array help in Powershell - correct syntax?

From Dev

ArrayIndexOutOfBoundsException please help find the error

From Dev

What is the error in this code please help:

From Dev

paypal parameater to create recurring profile is giving error can one please help me out

From Dev

Can somebody please help me to avoid internal server error | htaccess | apache2ctl | backtrack

From Dev

I am getting an error, while adding DesignGridLayout to my register form. Please help me with this

From Dev

Please Help me. I am getting EOD tag Error while form processing in PHP

Related Related

  1. 1

    Could someone please help me with why is this happening? Python invalid syntax error

  2. 2

    Please help me debug this error about for/in in Javascript

  3. 3

    Null Pointer Exception Error .Please help me

  4. 4

    Please help me debug a stripe error

  5. 5

    Please help me understand unfamiliar struct syntax in C

  6. 6

    SyntaxError: Unexpected token ILLEGAL. Please help me insert syntax

  7. 7

    i have a syntax error help me

  8. 8

    Please help me debug this error message I get at the console

  9. 9

    AngularJS small test, help me find the error please

  10. 10

    Please can anyone help me to find out the error in the xml file

  11. 11

    Please help me debug the error:java.lang.NullPointerException

  12. 12

    AngularJS small test, help me find the error please

  13. 13

    Please help me find error - program which shows prime numbers

  14. 14

    Please help in finding the error

  15. 15

    Please help me with a recursive function

  16. 16

    Please help me understand Arrays

  17. 17

    Please help me delete a file?

  18. 18

    Please help me with this collision detection

  19. 19

    Please help me open it "xampp"

  20. 20

    Help me with broken packages please

  21. 21

    can you help me please

  22. 22

    Parse error: syntax error, unexpected T_FUNCTION Please help includes/theme_filters.php

  23. 23

    Array help in Powershell - correct syntax?

  24. 24

    ArrayIndexOutOfBoundsException please help find the error

  25. 25

    What is the error in this code please help:

  26. 26

    paypal parameater to create recurring profile is giving error can one please help me out

  27. 27

    Can somebody please help me to avoid internal server error | htaccess | apache2ctl | backtrack

  28. 28

    I am getting an error, while adding DesignGridLayout to my register form. Please help me with this

  29. 29

    Please Help me. I am getting EOD tag Error while form processing in PHP

HotTag

Archive