Forum Replies Created

Viewing 12 posts - 211 through 223 (of 223 total)

  • RE: Create a stored procedure

    TomThomson (10/15/2014)


    As many have already pointed out, the "correct" answer is bunk. There will be a syntax error because "column" is a reserved word. So the only option...

  • RE: Create a stored procedure

    I'm amazed at the level of acceptance of sloppy, untested code here. Yes, it was only a test, and no, there was no real jeopardy. But it was...

  • RE: Create a stored procedure

    Stewart "Arturius" Campbell (10/15/2014)


    Enough nitpicking.

    yes, the question used a reserved keyword for a column name (purely by mishap, i'm sure).

    but, despite that little inconvenience, the idea behind the question was...

  • RE: Create a stored procedure

    Koen Verbeeck (10/15/2014)


    paul.knibbs (10/15/2014)


    Maybe the author chose the column name deliberately to catch out people who just run the SQL rather than thinking about their answer? I mean, the error...

  • RE: Create a stored procedure

    Msg 156, Level 15, State 1, Procedure my_sp, Line 2

    Incorrect syntax near the keyword 'FROM'.

    Oops.

  • RE: Random values

    Steve Jones - SSC Editor (9/29/2014)


    I'm with Jeff. If I had

    ...at some point I'd do this:

    SELECT

    CustomerID

    ,Name

    ,Address

    ...

    FROM

    Customer

    ...

  • RE: Random values

    Thanks Jeff. I'll ponder and see if I prefer your way to my way. As someone once remarked, for each expert there's an equal and opposite expert (not...

  • RE: Random values

    Jeff Moden (9/29/2014)


    Heh... I'm interested to know how or why you came up with this coding standard of generally avoiding aliases. I did my degree in the school of...

  • RE: Random values

    Hugo Kornelis (9/26/2014)


    ... my personal coding standard is to always use aliases for all tables in queries that use two or more tables, but use no alias in single-query tables...

  • RE: Random values

    Except that I would write

    SELECT

    FirstName,

    Surname,

    Address,

    EmailAddress

    FROM

    Person

    As you say, it's all preference. For simple queries such...

  • RE: Random values

    Far be it from me to disagree with a guru of your stature, but personally I find aliasing makes queries difficult to read. I only ever alias where strictly...

  • RE: Random values

    Can you explain why you aliased the sys.syscolumns table?

    SELECT TOP 10

    RAND( ROW_NUMBER() OVER (ORDER BY id))

    FROM sys.syscolumns

    is functionally identical, as far as I am aware.

Viewing 12 posts - 211 through 223 (of 223 total)