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 6, 2011 2:50 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 5:48 AM
Points: 63, Visits: 198
can anyone explain me the functionality of "select x from tablename"?
Post #1043576
Posted Thursday, January 6, 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 @ 10:25 AM
Points: 40,385, Visits: 36,827
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 6, 2011 3:13 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 5:48 AM
Points: 63, Visits: 198
why do people make use of "select x" instead of "select columnname"?
Post #1043590
Posted Thursday, January 6, 2011 3:17 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: 2 days ago @ 2:50 AM
Points: 608, Visits: 1,052
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

in.linkedin.com/in/pramodsingla/
http://pramodsingla.wordpress.com/
Post #1043594
Posted Thursday, January 6, 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 @ 10:25 AM
Points: 40,385, Visits: 36,827
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 6, 2011 3:22 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 5:48 AM
Points: 63, Visits: 198
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 6, 2011 3:22 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: 2 days ago @ 2:50 AM
Points: 608, Visits: 1,052
yes

Pramod
SQL Server DBA | MCSA SQL Server 2012

in.linkedin.com/in/pramodsingla/
http://pramodsingla.wordpress.com/
Post #1043598
Posted Thursday, January 6, 2011 3:25 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 5:48 AM
Points: 63, Visits: 198
@gila: i hav seen queries like" if exists ( select 'x' from tablename)" actaully i meant this query only.
Post #1043601
Posted Thursday, January 6, 2011 3:32 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 5:48 AM
Points: 63, Visits: 198
thank u..:)
Post #1043604
Posted Thursday, January 6, 2011 3:58 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, August 28, 2014 2:39 AM
Points: 1,880, Visits: 2,846
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