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
0 Comment(s)