Basic difference is that SELECT is Command and PRINT is function
The parameter to the COUNT function is an expression that is to be evaluated for each row. The COUNT function returns the number of rows for which the expression evaluates to a non-null value. ( * is a special expression that is not evaluated, it simply returns the number of rows.)There are two additional modifiers for the expression: ALL and DISTINCT. These determine whether duplicates are discarded. Since ALL is the default, your example is the same as count(ALL 1), which means that duplicates are retained.Since the expression "1" evaluates to non-null for every row, and since you are not removing duplicates, COUNT(1) should always return the same number as COUNT(*)
Select return the value but print function only display.
select return the value but print function only display
1)Select is command as it is part of SQL whereas Print is not part of SQL, it is used for debugging. 2)Select return datatype supplied whereas Print return varchar.But to layman it will give same output of 1
Both will give same output i.e 1but the important difference is that "Select" statement gives output in Result window and Print() will give output in Message window.
PRINT 1 will display 1 in message window. select 1 will display 1 in Result window
Select is a command which return as tabular form while print is a function which give result in message format. Print return values only in varchar format.
Select is Used to get result in result window . Print is Used to print any thing for debugging.
"select" returns the output as table format. "Print" returns the output as text(not in table format)
1.select is a command and always return output in raw and column while print is a function in SQL and it return a message in varchar format only. 2. select 1 return output in one raw and one column format while print(1) showing 1 in a message not in result window.
Select : - Used to get result in result window. Print : - Used to print any thing as a checkpoint in output window.
select 1 considered as a table that contain single row and single column , so when you execute this command you will find a message that " (1 row(s) affected)" But print('1') is used to print a text in Sql server 's screen