What is wrong with this T-Sql statement

Ben Tam 216 Reputation points

Dear All,

What's wrong with the following select statement?

string M_Surname="";
string M_GivenName="";
string M_MiddleName="";
int M_StudentID=0
string sSql = "SELECT Top 14 StudentID,Surname,GivenName,MiddleName,ChiName,Remarks FROM Student "

  • "Order by Surname,GivenName,MiddleName,StudentID "
  • "Where Pad(Surname,50)+Pad(GivenName,50)+Pad(MiddleName,50)+Cast(StudentID as Char(8))>"
  • M_Surname.PadRight(50, ' ') + M_GivenName.PadRight(50, ' ') + M_MiddleName.PadRight(50, ' ') + M_StudentID.PadLeft(8, ' ');


SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,132 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,535 questions
{count} votes

Accepted answer
  1. Olaf Helper 42,576 Reputation points

    What's wrong with the following select statement?

    Nearly everthing. The command order ist wrong, right is SELECT FROM WHERE ORDER.
    And PAD isn't a valid Transact SQL function.

    0 comments No comments

0 additional answers

Sort by: Most helpful