SQL SERVER – Guidelines and Coding Standards Complete List Download

SQL SERVER – Guidelines and Coding Standards complete List Download

Coding standards and guidelines are very important for any developer on the path of successful career. A coding standard is a set of guidelines, rules and regulations on how to write code. Coding standards should be flexible enough or should take care of the situation where they should not prevent best practices for coding. They are basically the guidelines that one should follow for better understanding.

The concept behind implementing coding standards and guidelines, is that the consistency and uniformity in programming so that if multiple people are working on the same code, it becomes easier to communicate, share with or understand each other’s work.

With the goal of promoting good coding standards and guidelines I have created document which can guide developers.

SQL SERVER – Guidelines and Coding Standards Part – 1

SQL SERVER – Guidelines and Coding Standards Part – 2

SQL SERVER – Guidelines and Coding Standards complete List Download

Reference : Pinal Dave (http://blog.SQLAuthority.com)

About these ads

52 thoughts on “SQL SERVER – Guidelines and Coding Standards Complete List Download

  1. Hello Dave,

    I’m having two tables

    Table1: Table2:

    ID Date Month Jan Feb Mar Remarks

    1 1 Jan xx xx xx xxxxx

    2 14 Jan xx xx xx xxxxx

    3 26 Jan xx xx xx xxxxx

    4 14 Feb xx xx xx xxxxx

    5 13 Mar

    I want distinct values of Month in Table1 to be the Column Name of Table2 as above said:
    can you help me out

    Thanks & Regards
    Surendar K

  2. Hello Dave,

    I want distinct values of Month in Table1 to be the Column Name of Table2 as below dynamically

    Table1:

    ID Date Month

    1 1 Jan

    2 14 Jan

    3 26 Jan

    4 14 Feb

    5 13 Mar

    Table2:

    Jan Feb Mar Remarks

    Thanks & Regards
    Surendar K

  3. hi..
    i want count all rows with group by and also count some specific rows with same group by statement.

    department total_Emp waitng_list Joind_Emp
    —————————————————————————
    ABCD 50 10 40
    CDEF 20 10 10

  4. i want need how to change to password in sql server 2005 to run vb 6.0.

    my project not connection to change password in sql server 2005 not run in visual basic 6.0

  5. Hi,

    Deve,

    used adventureworks
    select * from sys.tables

    I am using these code to retrieve all tables name.
    it works but “Name” column field not showing full table name like “person.address”.
    Plz help me how can i retrieve full name of table.

    Thanks

  6. CREATE FUNCTION employees_in_project
    (@pr_number varchar(20))
    RETURNS TABLE
    AS
    RETURN (SELECT Sum(Amount) as Amount
    FROM MasterDetail
    WHERE MasterDetail.code = @pr_number)
    GO

    In Analizer

    SELECT *, employees_in_project(master.code ) as Amount FROM Master
    GO

    it not work what is error in query

  7. Hi Shaikh,

    As this is table-values function, you can not call it like this way.

    You need to access it as:

    SELECT *
    FROM TableName master
    CROSS APPLY employees_in_project(master.code)

    Tejas

  8. Hello Ravi,

    Do you want to see databases list in SSMS then use sys.databases catalog view.
    If this is not what you want to know then please clarify your question.

    Regards,
    Pinal Dave

  9. hi sir i m first use the primary key and then i m remove it
    but there after removing primary key the only duplicate key allowed and null is not allowed in the table pls tell me how to allowed duplicate and null in table

  10. Hi Amit,

    When we drop a primary key constraint from a table the NOT NULL property of column is not changed. To allow null make sure that column is nullable. Check the result of sp_help tableName command and if you found Nullable “no” then alter the table to allow null using below syntax:

    ALTER TABLE tableName ALTER COLUMN columnName dataType NULL

    Regards,
    Pinal Dave

  11. How to Pass a bulk of data from .net to sql server, i mean pass a datatable values from .net to sqlsever 2005 for insert into table, to avoid for loop of calling insert query function

  12. hi..

    i’m new here.

    here is my question.

    there is a employee table.

    I’ve to get the employee’s highest salary as well as corresponding name from that table.

    could you please tell the Query for that

    thanks…

    kanagavel.N

  13. Hi Pinal ,

    Can we move the system database to some other location at the time of installating sql server 2005 . These was a interview question asked from me by a company ?

    Thanks and Regards
    Ashish Gupta

  14. Kanagavel,

    Assuming that your table has duplicate employee names but unique employee IDs, the following query should give you the result:

    SELECT EMPID, EMPLOYEENAME, MAX(SALARY)
    FROM EMPLOYEE_TABLE
    GROUP BY EMPID, EMPLOYEENAME
    ORDER BY EMPID

  15. Most likely there will be only one salary amount associated with en employee ID, Employee combination. However, assuming that you just need to find which employee name draws the highest salary, this query should help:

    select top 1 employeename, MAX(salary)
    from Employeetable
    group by employeename
    order by MAX(salary) desc

  16. Hi,

    Why @@rowcount is 0(without assigning to another variable) in the following case :

    Create procedure getEmp
    AS
    SELECT *
    FROM HumanResources.Employee

    select @@rowcount
    GO

  17. Hi,

    Why @@rowcount is 0 in the following case :

    Create procedure getEmp
    AS
    SELECT *
    FROM HumanResources.Employee
    if @@rowcount > 0
    select @@rowcount
    GO

    - JB

    • The value of @@rowcount changes dynamically based on the statement. The IF statement doesn’t return any row so it becomes 0. You should always assign a value to a variable and use that variable

  18. hi jp,

    i’m new to dis site…as i m very much interested in learning sql database nd nw i no the basics of sql but not deeper..wat i hav to do to go get strong in sql…

    pls advise…

  19. Hi Pinal

    create Procedure [dbo].[sp_become_acc_reviewer_content]
    (
    @become_acc_reviewer text,
    @action varchar(20)
    )
    as
    begin
    if(@action = ‘insert’)
    begin
    insert tbl_crm_details([become_ an_acc_reviewer])values(@become_acc_reviewer)
    End
    else
    begin
    update tbl_crm_details set [become_ an_acc_reviewer]=@become_acc_reviewer
    end
    end

    when i save data in second time its save a new row
    what i want to concatenate this
    how can i do this

    plz give me solution
    thanks

  20. hi,

    I’m new to sql.I have a problem some one asked in one of my interview.he was asking like this”how to split one table data into two table result set but result should be side by side means

    table:

    id name sal
    1 ravi 1000
    2 kishore 2000
    3 naveen 3000
    4 suresh 4000

    resulet:

    id name sal : id name sal
    1 ravi 1000 : 2 kishore 2000
    3 kishore 3000 : 4 suresh 4000

    note:result shoud be appears in single window

    can any one help me.

  21. Create Table Document
    (
    DocID Int,
    PageID Int,
    DocName Varchar(100)
    )

    Insert into Document values
    (1,0,’document Test’),
    (1,0,’document Test’),
    (1,0,’document Test’),
    (1,1,’document Test’),
    (1,2,’document Test’),
    (1,3,’document Test’),
    (1,4,’document Test’),
    (1,5,’document Test’),
    (1,5,’document Test’),
    (2,0,’document Test’),
    (2,1,’document Test’),
    (2,0,’document Test’),
    (3,0,’document Test’),
    (3,0,’document Test’)

    Hai Sir,

    I need a help…

    I want to update the duplicate record with maximum of its pageID from the above table without use a loop.
    After updation the DocID & PageID combination of record should be unique.
    For eg.,

    Output will be :
    DocID PageID DocName
    ———————–
    1 0 ‘document Test’
    1 6 ‘document Test’
    1 7 ‘document Test’
    1 1 ‘document Test’
    1 2 ‘document Test’
    1 3 ‘document Test’
    1 4 ‘document Test’
    1 5 ‘document Test’
    1 8 ‘document Test’
    2 0 ‘document Test’
    2 1 ‘document Test’
    3 0 ‘document Test’
    3 1 ‘document Test’

    Thank you,
    Nikhildas
    Cochin

  22. Hi,

    In table one column passport field is there it allows only unique values at same time it allows more than two nulls ( i know unique only allow only one null value for example in college more than two students does not have passport at that time it allows null values at the same time who have passport that id must be unique. is it possible can anybody knws plz send snd answer.

  23. can anyone help me with this please. . . thanks! !
    iii. The report can be sorted by Vendor #, Purchase Order # or Item #
    1. If sorted by Vendor #
    a. Group Header: Vendor # (Company Name)
    b. Details (in this order): PO #, Request Date, Warehouse, Item #, Unit of Measurement, Order Qty, Unit Cost, Discount Rate, Ext. Net Cost
    2. If sorted by Purchase Order #
    a. Details (in this order): PO #, Vendor #, Request Date, Warehouse, Item #, Unit of Measurement, Order Qty, Unit Cost, Discount Rate,
    3. If sorted by Item #
    a. Group Header: Item # (Description)
    b. Details (in this order): Warehouse, PO #, Vendor #, Request Date, Order

  24. Hi,
    I am having a Question regarding to Database mail, the client requriment is that he must receive the mail in Excel format, without using SSIS packages,can you please give me sugguest me regarding may I get in script form and through GUI.

    Thanks & Regards
    Murali

  25. Pingback: SQL SERVER – Weekly Series – Memory Lane – #048 | Journey to SQL Authority with Pinal Dave

  26. What i do not understood is if truth be told how
    you’re now not actually a lot more smartly-liked than you might be
    now. You are very intelligent. You realize therefore considerably
    in relation to this topic, made me for my part consider it from
    a lot of various angles. Its like men and women are not
    fascinated unless it is one thing to do with Lady gaga! Your own stuffs excellent.

    Always deal with it up!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s