Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

what is select 'X'? Expand / Collapse
Author
Message
Posted Thursday, January 06, 2011 2:50 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, April 02, 2014 2:59 AM
Points: 63, Visits: 194
can anyone explain me the functionality of "select x from tablename"?
Post #1043576
Posted Thursday, January 06, 2011 2:51 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 12:20 PM
Points: 41,529, Visits: 34,445
It returns the column X for all rows in table tablename


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1043579
Posted Thursday, January 06, 2011 3:13 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, April 02, 2014 2:59 AM
Points: 63, Visits: 194
why do people make use of "select x" instead of "select columnname"?
Post #1043590
Posted Thursday, January 06, 2011 3:17 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Tuesday, April 15, 2014 11:09 AM
Points: 583, Visits: 962
in topic you have specified select 'x'
so i think you wanted to know for select 'x' from tablename

the above query will return char x for all the records in the table.
normally stmts like these are used with exists/not exists

so instead of fetching all the columns in case where you want weather the data exists or not ,,simply use something like 'x',1 ,,
this will reduce the traffic and use less memory.


Pramod
SQL Server DBA | MCSA SQL Server 2012
Post #1043594
Posted Thursday, January 06, 2011 3:20 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 12:20 PM
Points: 41,529, Visits: 34,445
deepikamm (1/6/2011)
why do people make use of "select x" instead of "select columnname"?


Errr, they don't. Select x is only possible if there's a column called x, otherwise it will throw an error.

Can you explain clearer what you're asking about?



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1043595
Posted Thursday, January 06, 2011 3:22 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, April 02, 2014 2:59 AM
Points: 63, Visits: 194
yes thats wat am asking..so it is generally used with if exixts/not exists to check for the exixtence of rows..am i correct?
Post #1043597
Posted Thursday, January 06, 2011 3:22 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Tuesday, April 15, 2014 11:09 AM
Points: 583, Visits: 962
yes

Pramod
SQL Server DBA | MCSA SQL Server 2012
Post #1043598
Posted Thursday, January 06, 2011 3:25 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, April 02, 2014 2:59 AM
Points: 63, Visits: 194
@gila: i hav seen queries like" if exists ( select 'x' from tablename)" actaully i meant this query only.
Post #1043601
Posted Thursday, January 06, 2011 3:32 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, April 02, 2014 2:59 AM
Points: 63, Visits: 194
thank u..:)
Post #1043604
Posted Thursday, January 06, 2011 3:58 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Wednesday, April 09, 2014 12:58 AM
Points: 1,904, Visits: 2,771
Is this query is SQL or VB?

in SQL you might find a: Select @x from..... if @x was declared as a variable.

but normal Select x .... means X is your column name.


----------------------------------------------
Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.
Post #1043612
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse