How do I write an If statement in my stored procedure based on what value is passed through a specific variable?

I have a stored procedure that I need to modify. There are 4 possible values that can be passed through the variable @Company. The SQL looks like this…. — Create #House table CREATE TABLE #Houses ( iHouse_ID int, cName varchar(50), cNumber varchar(10), cPhoneNumber1 varchar(25), cAddressLine1 varchar(50), cCity varchar(30), cStateCode varchar(2), cZipCode varchar(10), iUnitsAvailable int, iRegOpsNumber […]

XML generation from SQL

I’m generating an XML file from SQL data. One of the Tags in the XML is a concatenation of multiple SQL columns. I need to insert a line break between each column value (all values will still be in the same XML tag, but separated by line breaks. I’m unable to insert these line breaks […]

SQL Report Server internal error

I’m running a report server on Windows Server 2008. After a recent update it would look like everything was fine in the Reporting Services Configuration Manager, but it can’t actually be accessed. The error it gives if you visit the ReportServer URL is just “There was an internal error. See log” ERROR: Error initializing configuration […]

Trigger to log inserted/updated/deleted values SQL Server 2012

I’m using SQL Server 2012 Express and since I’m really used to PL/SQL it’s a little hard to find some answers to my T-SQL questions. What I have: about 7 tables with distinct columns and an additional one for logging inserted/updated/deleted values from the other 7. Question: how can I create one trigger per table […]

Delete multiple tables using foreign Key – ADO.Net

I want to DELETE records in multiple tables with ADO.NET. I want to DELETE a Old record into a table. It has a foreign key mapped to a different table. tables: Example: cmd.CommandText = “DELETE FROM Date WHERE Date < DATEADD(Day,-10 , getdate())”; But this code not worked and I want to be removed from […]

Query to Find out Deprecated Database Engine Features (SQL Server 2008 to 2014)

Currently I am upgrading my SQL Server from 2008 to 2014, and I want to track the deprecated database engine features for one of my databases in the server. I have read these articles in msdn: and found that this query can give me a brief picture of deprecated database engine features in […]

C# Local Database error 50

So I am trying to connect a local file database when I debug the program or use it anywhere on my dev machine, it works absolutely fine. Whenever I try to take the files and run it on a different machine I get Error 50 cannot connect to the localdb: local database runtime error occurred, […]

How to distribute data from one ms sql table into another ms sql database

I am using MS SQL Server 2014. I have a “main” server that contains a database which contains a table with data. This table receives new data around every second. Per day it is currently around 500’000 new rows. As the data only stay for some days in this table, the table contains a maximum […]

How to import XML file data dynamically into SQL Server using C#

I have an .xml file that contains 30 tables and I want to read all tables and insert the data into a SQL Server database without declaring any variable, means everything is happening dynamically <person> <created_by>admin</created_by> <created_on_timestamp>2014-11-19T14:13:54.000Z</created_on_t‌​imestamp> <date_of_birth>1990-04-04</date_of_birth> <last_modified_by>admin</last_modified_by> <last_modified_on>2014-11-21T13:29:49.000Z</last_modified_on‌​> <logon_user_id>P10621</logon_user_id> <logon_user_is_active>true</logon_user_is_active> <logon_user_name>P10621</logon_user_name> <person_id>3478</person_id> <person_id_external>P10621</person_id_external> <personal_informatio> <last_modified_by>admin</last_modified_by> <last_modified_on>2014-11-21T14:45:49.000Z</last_modified_on‌​> <last_name>Singh</last_name> <marital_status>S</marital_status> <nationality>IND</nationality> <salutation>MR</salutation> <start_date>2014-05-01</start_date> <personal_information_ind> <country>IND</country> […]

SQL Server – Using JSON to return Column Names

I have the following test query I’m needing to make dynamic. Basically a stored procedure will be passed @json and it needs to return the column names that are passed in that variable. Is this possible and how could I do it? declare @json varchar(max) set @json = ‘[“FirstName”, “LastName”,”DOB”]’; select * from OPENJSON( @json […]

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