Ok this is difficult to phrase, so here goes… I am using MS SQL Server 2008 R2. I have a temp table that lets say has two already populated columns. There is a third empty column I want to populate based on the value of the first two columns. What I want to do is create a guid (using NEWUID())
Tag: sql-server
Carriage return symbol is removed from XML using OPENXML
It looks like SQL Server removes r characters when parsing XML. So when my stored procedure receives values in xml for saving, all line breaks are represented as n instead of rn. Is there any way …
How do I find duplicates across multiple columns?
So I want to do something like this sql code below: To produce the following, (but ignore where only name or only city match, it has to be on both columns): Answer Duplicated id for pairs name and city:
Know relationships between all the tables of database in SQL Server
I wish to all know how the tables in my database are related to each other (i.e PK/FK/UK) and hence i created a database diagram of all my tables in SQL Server. The diagram that was created was not easily readable and had to scroll (horizontally and sometimes vertically) to see the table on the other end. In short SQL’s
SQL Server – Return value after INSERT
I’m trying to get a the key-value back after an INSERT-statement. Example: I’ve got a table with the attributes name and id. id is a generated value. INSERT INTO table (name) VALUES(‘bob’); …
How can I resolve “The cursor was not declared” from SQL Server
I am connecting to SQL Server via Spring in WebSphere. I have a piece of pretty simple dynamic SQL (below) that is throwing “The cursor was not declared.” One of the settings for the data source that seems relevant is the “select mode” is “cursor”. I’m not really sure what I need to do to resolve the error. edit The
How to Troubleshoot Intermittent SQL Timeout Errors
We’ve been having a few instances per day where we get a slew of SQL Timeout errors from multiple applications (System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.) We have over 100 different applications on our network, both web and desktop apps. Everything from VB6 and Classic ASP to
How do you Select TOP x but still get a COUNT of the whole query?
I’m writing a webpage to interactively filter results based on filter criteria as it is specified by the user. I only want to return from SQL the TOP 20 rows but I want to know how many rows met the criteria (Count). I want to be able to tell the user: “here are the top 20 rows matching your criteria,
Bulk load data conversion error (truncation)
I am getting this error Bulk load data conversion error (truncation) for row 1, column 12 (is_download) here is the csv…it only has one row 30,Bill,Worthy,sales,,709888499,bat@bat.com,,”Im a a …
How to get second-highest salary employees in a table
It’s a question I got this afternoon: There a table contains ID, Name, and Salary of Employees, get names of the second-highest salary employees, in SQL Server Here’s my answer, I just wrote it in …