If you ever come across a problem where you have to update two or more tables at the same time if you try to do that in a single statement that can’t be done ; but there is a way around, Transactions they would enable us to do that. Sample syntax can be Begin […]Read more "Updating Multiple Tables in a query"
Views and TVfs both are saved as persistent objects in the database, in order to create system administrator needs to provide you with the rights, if you already don’t have rigths ; explore the link : https://docs.microsoft.com/en-us/sql/t-sql/statements/grant-object-permissions-transact-sql Both provide encapsulation and can be used as primary source of security as we can restrict the under […]Read more "Views VS TVF"
Use the following : IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fnc_GetValuesInColumnFromCSV]’) AND type in (N’FN’, N’IF’, N’TF’, N’FS’, N’FT’)) BEGIN execute dbo.sp_executesql @statement = N’– ============================================= — Author: AASIM ABDULLAH — Description: TO GET VALUE IN TABLE FORMAT FROM CSV INPUT — ============================================= CREATE FUNCTION [dbo].[fnc_GetValuesInColumnFromCSV] ( @csv NVARCHAR(4000) […]Read more "Using a Comma separated column in sql"
So i came across this problem while writing a view in which the problem couldn’t be solved by using Case statements; i tried to do that using a cursor but hey guess what cursor can’t be used either so this came to me why not use variables ; i hadn’t use it in my past […]Read more "Using a variable in a view"
Epoch to SQL Date TimeRead more "Unix Date Format to SQL DateTime"