FOR XML causing high cardinality in update statement.
Wasn't really sure how to word this, but here it goes. I have a simple update statement that uses a sub-query to concatenate a column from a record set using the most recently recommended fashion of...
View ArticleExecute store procedure based on table results
I need to exec a stored procedure for each row in a table where one column is null. The stored procedure inserts data into a second table and then sets the null column to the PK value of the second...
View ArticleWhat is the easiest way to transpose/pivot one column of data from a table?...
what is the easiest/simplest way to transpose/pivot this data? (using sql server 2008)create table #tmpA(fld1 varchar(10))insert into #tmpA select 'a' union all select 'b' union all select 'c' union...
View ArticleError : The label 'http' has already been declared. Label names must be...
Hi all, I have created one SP for sending mail with formatting the HTML code inside script whenever i am individually declaring it and printing its expected but the problem at time of executing SP...
View ArticleExpanding IP values based on subnet mask with increased complexity.
Hello Forum Members/Gurus' Background: I have a IP range as: 1.2.3.0/255.255.255.0I want the following output:1.2.3.0 1.2.3.1 1.2.3.2 . . 1.2.3.254 1.2.3.255Proposed script by Patrick Hurst works like...
View ArticleSelect on one column and return as two colums
I have an InventoryStock table structured like:ItemCodeLocationCodeUnitsInStockItem1Location11Item1Location22Item2Location13Item2Location24I would like run a SELECT statement that will...
View Articleproblem with using Case statement and a variable - need to results of the...
I am trying add up all the sales if the RepID matches the the specialtyrepid and add all those values to be the value for the column name SpecialtySalesRepforPRS.. example if the SalesRepID is 51 and...
View ArticleGroup by clause based on condition
tblScore contains score for each problem id problemID score ------------------------ 1 1 10 2 2 30 tblSubmission contains problem submissions for each...
View Articledelete row or sheet in excel from query
i want to delete row in excel file from query because when i insert data in 2nd time, data is not insert in proper place for exampleINSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel...
View Articleemployee attendance Query using 3 tables left innerjoins
I Have 3 tablesdbo.Emp_setting name data type allownulls Empset_id int Unchecked personal_id int Unchecked DesignationID int Checked DivisionID int Checked Emp_status char(1) Checked Emp_TypeId int...
View ArticleSQL Server Query
Hi All,Sql query is behaving the abnormally.... Query-1SELECT * FROM Employees AS E FULL OUTER JOIN Departments AS D ON D.Deptno =E.deptno...
View ArticleError on using count aggregate function inside sum
I have the following query : select a.username, count(a.problemID) as NumberOfSubmission, Q_Score = sum( case when a.accepted = 0 then -2 when count(a.accepted) > 1 then -1 else 20 end) from...
View ArticleBCP Query returns NULL result
I have a single client server (first of 43) who have something misconfigured apparently that prevents simple bcp query to execute. The query doesn't return errors as I have seen when security is an...
View Articlecan you make a key with delete cascade when there is no primary key?
I have a table with a primary key, and also a field called 'tpid', which is sometimes null, and sometimes has an integer value in it. This integer value corresponds a primary key in another table, and...
View ArticleTracing down data flow within an DB
Hello,pls, many times I was wandering if there is an practical way of performing subject's issue. Namely,1) if there is an App without source code, on production server and2) corresponding DB, that is...
View ArticleSQL Server Management Studio experiences lock timeout when using SELECT INTO
Whenever I execute a long-running SELECT INTO statement and while it is running I try to use the SQL Server Management Studio object browser to view tables or other objects, I get a lock timeout error....
View ArticleSplit data into groups
Hello, can anyone make a suggestion on how to make this work fasterAny advice would be greatUSE [test] GO CREATE TABLE [dbo].[PeopleX]([P1] [int] NULL,[P2] [int] NULL,[Grup] [int] NULL ) ON [PRIMARY]...
View ArticleTSQL to know if an update was run at a specific time
Hello,I am using SQL 2008 R2 SE and would like to know if I will be able to trace with a tsql if a record in a table was updated from an older time. Like in table abc if a record was updated on jan1,...
View ArticleOR condition - help!
Script for the sample data as belowcreate table #Country ( InvestorID int, PermResTax1 varchar(50), PermResTax2 varchar(50), Citizenship1 varchar(50), Citizenship2 varchar(50), CountryBirth...
View ArticleGroup By In SQL Server
Hello Friends,i have some problem in group by functionality of sql server 2008 r2.my sample script is as below : -- Table Variable Declaration declare @tbl table(Name nvarchar(50)); -- Insert Value...
View Article