why contained database user needs Persist Security Info=True

I have a database where I created a contained user and I needed to connect to my web app using that user. I have always been able to connect to the web app with a standard user having Persist Security Info=False. However, the only way I was able to connect with the contained user was […]

SQL Server Management Studio VS Visual Studio – Different version of SQL

I would love to manage and create my databases in SQL Server using SQL Server Management Studio and use them in Visual Studio but I can’t connect to the same database : Different Version of SQL used As you can see, Visual Studio is connected to SQL Server 13.0 and Management Studio is connected to […]

Get the value of each XML node and set it to a parameter

How to set a parameter in each XML nodes using SQL Server 2008? I am new with SQL and I have XML data like this Set @xml='<root><name>John </name><age>8</age></root>’ I need to set the value of node <name>, <age> in a parameter. For example: Set @name=’get value of node <name>’ Set @age=’the value of <age>’ Is […]

How can I convert a JSON date with timezone to a SQL Server datetime?

I saved the output of a JSON object in a CSV file. I want to import the data into SQL Server. I have tried to cast the JSON date column to a SQL Server datetime data type. select cast(‘2009-06-18T16:44:20+0000’ as datetime) This causes an error to be raised: Conversion failed when converting date and/or time […]

Multiple Where vs Inner Join

I have a filter where depending on the user selection I conditionally add in more Where/Joins. Which method is faster than the other and why? Example with Where: var queryable = db.Sometable.Where(x=> x.Id > 30); queryable = queryable.Where(x=> x.Name.Contains(‘something’)); var final = queryable.ToList(); Example with Join: var queryable1 = db.Sometable.Where(x=> x.Id > 30); var queryable2 […]

How can I use an attribute from another table in defining a derived attribute in a new table?

For example: I have a table “Children” which has an attribute “age”. I am now making a table “Students” which inherits only the primary key “SSN” from child, but it should have an attribute “grade” which is derived from the corresponding child’s age as (Children.age – 5). This is something I made up and tried […]

Adding non-clustered index to a table to increase performance

I have table structure as below CREATE TABLE [dbo].[AIRQUALITYTS2] ( [FeatureID] [nvarchar](20) NOT NULL, [ParameterID] [nvarchar](20) NOT NULL, [MeasurementDateTime] [datetime2](7) NOT NULL, [ParameterValue] [numeric](38, 8) NULL, [Remarks] [nvarchar](150) NULL, CONSTRAINT [PK_AIRQUALITYTS2] PRIMARY KEY CLUSTERED ([FeatureID] ASC, [ParameterID] ASC, [MeasurementDateTime] ASC) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = […]

How to restrict the values read from a table based upon another table in sql

I am working with sqlserver and C#. I have to populate a dropdownbox with times of 30 min increment between a start and end time from a table named time_series. For example, the date read from this table will be like, 10:00 am, 10:30 am, 11:00 am, 11:30 am … 5:00 pm. I have another […]

SELECT name of table if table is empty

I have table with names of tables… I need to select only that tables that are empty. For this I’ve tried to write CURSOR. DECLARE @Footprint VARCHAR(200) DECLARE @query VARCHAR(200) DECLARE MY_CURSOR CURSOR LOCAL STATIC READ_ONLY FORWARD_ONLY FOR SELECT ‘[‘ + [SchemaName] + ‘].[FootprintBuildState]’ FROM [dbo].[vwAgencySchemas] OPEN MY_CURSOR FETCH NEXT FROM MY_CURSOR INTO @Footprint WHILE […]

SQL Server 2012 “Application cannot start” after installing Visual Studio 2008

Microsoft SQL Server 2012 is installed and was working fine until I installed Visual Studio 2008. When installing VS2008 completed VS2008 would not start, I checked to see if SQL Server 2012 would start and it would NOT. I found out the VS2008 Needed the dte80.olb in a different directory, once I copied the dte80.olb […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.