SQL Server Performance

Linefeeds necessary?

Discussion in 'General Developer Questions' started by Joker, Oct 11, 2005.

  1. Joker New Member

    Hi,
    I plan to remove all line-feeds (cr-lf) from some scripts.
    As far as I know, T-SQL is not line-based. But I#%92m wondering, if there is an exceptional situation for that rule.

    If the script contains no comments:
    Can you imagine some circumstances, where a linefeed is absolutely required?
  2. ranjitjain New Member

    Line feed is required for Completing the batch such as with GO.
    In cases where you have multiple insert statements then also separate them with line feed.
  3. Joker New Member

    I should have been more precise:
    I only want to remove the line feeds within procedures, functions and triggers.
    So there will be no GO statement (but thanks for that tip).

    But why not write two inserts in one line ? E.g.
    INSERT table1 VALUES (1, 2, 3) INSERT table2 SELECT (3, 4, 5)

  4. Chappy New Member

    line feeds are not required, even int he case of batches using GO<br />You can have many inserts per row also<br /><br />But whats the purpose for removing crlf's? I dont really understand how it could ever be desirable?<br />Id be pretty annoyed if I started working with someones database and all their procs were not formatted in any way <img src='/community/emoticons/emotion-5.gif' alt=';-)' /><br /><br />
  5. Madhivanan Moderator

    Try this

    INSERT table1 VALUES (1, 2, 3) ; INSERT table2 SELECT (3, 4, 5)


    Madhivanan

    Failing to plan is Planning to fail
  6. Joker New Member

    @Chappy:
    If you'd be annoyed, this is exactly what I want.
    Because the encryption of procedures are so week, I build a tool like the obfruscators for java scripts. I'll keep the original formatted sps and use the "not readable" ones in the productive systems. The tool will have some other features, to make the scripts very hard to understand. This will provide me with the so called "security by obscurity". Beside good contracts this seems the only way to protect my copyrights.


    @Madhivanan:
    Cool, it works.
    I cannot find the ";" in the references.
    Is semicolon defined to separate commands?


  7. suleman New Member

    @joker
    ; is a not defined as a seperate command but rather we can put it this way it serves the same purpose as a full stop in english language...so to say ; seperates two executable statements...and i really didnt understand the encryption thingie u were speaking of ...i find no such thing to decrypt the encrypted data in stored procedures and function in SQL server ...please do lemme know if there are some...

    Regards
    Suleman
    Hyderabad
  8. ranjitjain New Member

    Hi,<br />in my first post i had said that go requires line feed.<br />Try this<br /><br />use dbname go exec spname 'parameter'<br /><br />the above statement will not work<br /><br />but this will<br />use dbname <br />go <br />exec spname 'parameter'<br />so this way line feed is required.<br />you can write inserts all in one line but you need to separate them using ; or write them in new lines as madhivanan has already said.[<img src='/community/emoticons/emotion-1.gif' alt=':)' />]<br /><blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Chappy</i><br /><br />line feeds are not required, even in the case of batches using GO<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
  9. Madhivanan Moderator

    &gt;&gt;Is semicolon defined to separate commands?<br /><br />It is used to seperate the statements if there are multiple statements [<img src='/community/emoticons/emotion-1.gif' alt=':)' />]<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
  10. Joker New Member

    @Suleman:

    The following syntax encrypts the procedure itself on the server, but not the data.
    CREATE PROCEDURE spName WITH ENCRYPTION ...
    But as I wrote before the encryption is more than weak.
  11. Joker New Member

    @ ranjitjain and madhivanan
    I did not yet tried your GO example.
    But the following inserts work fine without any semicolon;

    If OBJECT_ID('TempDB..#table1') IS NOT NULL DROP TABLE #table1
    If OBJECT_ID('TempDB..#table2') IS NOT NULL DROP TABLE #table2

    CREATE TABLE #table1(x int, y int, z int)
    CREATE TABLE #table2(x int, y int, z int)


    INSERT #table1 VALUES (1, 2, 3) INSERT #table2 SELECT 3, 4, 5

    SELECT * FROM #table1
    SELECT * FROM #table2

    GO


    Can you please give me an example, that fails.
  12. FrankKalis Moderator

  13. Madhivanan Moderator

    >>Can you please give me an example, that fails.

    Why?

    Madhivanan

    Failing to plan is Planning to fail
  14. Joker New Member

    quote:Originally posted by FrankKalis

    May I ask what's the purpose of this exercise?

    The purpose is:


    quote:Originally posted by Joker

    @Chappy:
    ...
    Because the encryption of procedures are so week, I build a tool like the obfruscators for java scripts. I'll keep the original formatted sps and use the "not readable" ones in the productive systems. The tool will have some other features, to make the scripts very hard to understand. This will provide me with the so called "security by obscurity". Beside good contracts this seems the only way to protect my copyrights.
  15. Joker New Member

    quote:Originally posted by Madhivanan

    >>Can you please give me an example, that fails.

    Why?

    ups, sorry. I must have read to fast.
    I only want to ask ranjitjain to give me this example.


  16. suleman New Member

    @joker
    hey i gotcha now... lemme c wat comclusion u ppl derive here...

    Regards
    Suleman
    Hyderabad
  17. ranjitjain New Member

    @joker,
    have you tried the example i gave for go.
    And for insert statements it's not that it always gives error if you put many insert statements in one line.
    But sometimes it behaves wierdly.
    I had an issue on that.
    AS prevention is better than cure and it's better to separate them either by linefeed or ;

Share This Page