January 27, 2010 at 1:55 pm
The result you get is exactly what you've been asking SQL Server to do:
select -- print the output
8 -- output is supposed to be the number "8". If you'd like to have a column alias, uncomment the following line
--,8 as mycolumname -- and you'll get a separate column
from table1 -- for each line you find in table 1
Now, since we figured that you actually get the result you've asked for, the question is: What result do you expect?
Maybe we have to change the question (=SELECT statement)?
January 27, 2010 at 10:00 pm
thanks lynn i got your point i understand it but the only confusion was that we are typing
SELECT -- Have SQL return something to me
8 -- In this case, the constant value 8
FROM
dbo.MyTable -- from MyTable
and we are getting 8 for number of rows present in table i can under stand that it will return all rows because no where condtion is applied but y 8 is printed is it the property of select statement to print it as output ..
thanks for your support
anshu
January 27, 2010 at 10:12 pm
anshu84onnet (1/27/2010)
thanks lynn i got your point i understand it but the only confusion was that we are typingSELECT -- Have SQL return something to me
8 -- In this case, the constant value 8
FROM
dbo.MyTable -- from MyTable
and we are getting 8 for number of rows present in table i can under stand that it will return all rows because no where condtion is applied but y 8 is printed is it the property of select statement to print it as output ..
thanks for your support
anshu
The value 8 is being returned as the select statement you are asking that a constant expression (8) be returned when selecting all rows from a given table.
Please take the time to review the SELECT statement syntax in Books Online. It should help you understand what is going on.
January 27, 2010 at 11:23 pm
Thanks Lynn Pettis i check the syntax of select now my doubt is clear thanks for your great support god bless you ....
January 29, 2010 at 8:04 am
Just for fun if others read this thread:
There is a difference between
[font="Courier New"]SELECT 8[/font]
and
[font="Courier New"]SELECT 8 FROM Table1[/font]
The first query may be what one may expect.
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply