When you run a query like select count(*) from myTable where (myVariable =1) you get a number returned that fits that criteria. If you replace the asterisk with any number, you get the same answer. What’s going on with SQL here?
When you run a query like select count(*) from myTable where (myVariable =1) you
Share
Its equivalent.
You are asking how many rows are in the table the number n will refer to the nth column in the table. Even if you don’t have n columns this will work.
But it gets better you don’t even need to put in anything relating to the table
SELECT ('X') from Tableis validThere is a school of thought that SELECT(1) is better for performance but MSSQL at least the query optimzer looks after this by choosing the correct plan