T-SQL Update From Order By

I am trying to write a Stored Procedure that will give me Audit information between a date range. The Audit table stores the Audit Date, Column Name and Old Value. I want to display the Old Value and the New Value in the result set. I need to get the new value from the next […]

How To Return PDF From Database In a WCF-Rest Service

I’m doing a WCF-REST service using C#, which connects with a database in SQL Server to return several tables. Now, I need that my service returns a PDF File, which is stored at the table, in a varbinary(MAX) field. I’m doing some research but I can’t found something like I need. How can I implement […]

Parsing XML from a select statement

I have a column in my table with XML that looks like this: <Notes> <Note> <Author>test</Author> <AuthorInitials>JJJ</AuthorInitials> <Contents>Test treatment notes 3</Contents> <DateCreated>2013-07-17T14:43:00</DateCreated> <DateModified>2013-07-17T14:43:00</DateModified> </Note> <Note> <Author>test</Author> <AuthorInitials>JJJ</AuthorInitials> <Contents>This is the intial notes test for tasks</Contents> <DateCreated>2013-07-17T14:36:00</DateCreated> <DateModified>2013-07-17T14:36:00</DateModified> </Note> <Notes> <Note> <Author>test</Author> <AuthorInitials>JJJ</AuthorInitials> <Contents>Test 4 of Task Notes</Contents> <DateCreated>2013-07-17T14:57:00</DateCreated> <DateModified>2013-07-17T14:57:00</DateModified> </Note> <Note> <Author>test</Author> <AuthorInitials>JJJ</AuthorInitials> <Contents>This is […]

Duplicate rows with information merged and then remove duplicates

I have a table called customers which gets info populated from a form not all fields are required (this is because the form generates asf / xml with the inputted info) and I would like to be able to merge duplicates into one row then delete the duplicates. Here is my table CID | LastName […]

Insert xml data into SQL server via SqlBulkCopy with powershell (casting error)

I’m getting a “cast not valid” error when trying to insert a data table containing xml using sqlbulckcopy. I cast the DataColumn that will hold the xml data to type System.Xml.XmlNode is that incorrect? Looking here it just says the .NET Framework type is xml. Here is an example of the xml I want to […]

Write SQL Code to automate the changing of the parameter year and period

If the day of the current date = 14 then the values of the parameter need to change. The month and possibly year will need to advance by 1 – May need to consider that on the 14th day of the month there may be a technical problem that prevents this process from running. Example […]

Select distinct from a table foreach value from another

I have a view that gets the status for each category for each venue. I need to display all of the above, but only the latest in the status for each category for each venue. A general idea could be, for each item in a shop, there is a status. So for the cucumbers, letters, […]

IF ELSE IF ELSE IF… Code wants to get smarter

I tried a lot to get this code smarter… as you see… it’s always the same… one variable can have 6 different values… which decides in which column some other value will be written… if the recordset still exists I make an “update…” else I make an “insert into…” I tried to do some dynamic […]

Full text search and domain names

I stumbled accross an issue with full text search in columns which may contains domain names on a Microsoft SQL Server 2012. A table cell containing example.com is added to the full text catalog by the term example and com. The latter makes it impossible to search for a domain name, as any entry containing […]

TSQL Creating a Table using another User Defined Type?

I have a stored procedure that receives a (n) list of filters stored as GUIDs. What I need is a stored procedure that will receive an (n) list of an (n) list of filters so that I can return comparisons each (n) list of filters. Is this possible, and how would you script it? For […]

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