Share via

What is wrong with this T-Sql statement

Ben Tam 216 Reputation points
2021-09-20T04:37:17.817+00:00

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, ' ');

TIA

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

Developer technologies | C#
Developer technologies | C#

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.


Answer accepted by question author

Olaf Helper 47,621 Reputation points
2021-09-20T06:38:06.343+00:00

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.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.