Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Using Paranthesis in SQL Server

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 65
    Comment on it

    While writing queries we use paranthesis while writing Table Name or Column Name

    This is so because if you have any keyword used in your column or table no conflict can occur

     

    -- To get User Details
    
    SELECT @TargetUserID=[ID] ,@CompanyID=[CompanyID]  from [User] WHERE AccessToken=@AccessToken
    
    --Using Paranthesis for Table and Column
    
    SELECT N.[ID],N.[Message],N.[LocationID],N.[TargetUserID],N.[Url],CONCAT(U.[FirstName],U.[LastName]) AS [CreatedBy],CONVERT(VARCHAR(20), N.[CreatedDate], 103) as [CreatedDate],N.[DaysTillExpire],N.[HoursTillExpire] 
    	FROM [NUDGE] AS N INNER JOIN  [User] AS U ON N.[CreatedBy]=U.[ID]
    	WHERE N.[LocationID]=0 
    	AND N.[TargetUserID]=@TargetUserID
    	AND N.[IsDeleted]=0 
    	AND N.[IsExpired]=0 
    	AND N.[IsCompleted]=0 

    So i have used paranthesis everywhere to avoid any conflict with table or column name

    So for writing any query you need to use it every time for saving conflict and for better query execution by the SQL engine

    SQL Server

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: