Viewing 15 posts - 5,581 through 5,595 (of 10,144 total)
prasan.dash83 (9/25/2012)
I have an MIS system where I have to run 15 queries and update 15 sheets which takes a lot of time as I need to make changes...
September 25, 2012 at 1:53 am
cemelma.20 (9/25/2012)
Bring 1 record randomly from each category
The code I posted does exactly that - it returns one randomly selected category row per project row. If this solution doesn't...
September 25, 2012 at 1:51 am
SELECT p.*, x.*
FROM Projects p
CROSS APPLY (
SELECT TOP 1 *
FROM ProjectCategory pc
WHERE pc.ProjectID = p.ProjectID
ORDER BY NEWID()
) x
September 24, 2012 at 9:51 am
High Plains Grifter (9/24/2012)
September 24, 2012 at 8:49 am
High Plains Grifter (9/24/2012)
Ok... Magic? I guess that one needs a google; I cannot explain that by looking!
There's a good explanation in BOL - the output datatype of REPLICATE depends...
September 24, 2012 at 8:41 am
High Plains Grifter (9/24/2012)
I see how those work; my concern is that using things like REPLACE(),LEN(),LEFT() on a text field of more than...
September 24, 2012 at 8:33 am
GSquared (9/24/2012)
IF OBJECT_ID(N'tempdb..#T') IS NOT NULL
DROP TABLE #T;
CREATE TABLE #T
(EntryID INT NOT NULL,
EntryTime DATETIME NOT...
September 24, 2012 at 8:30 am
-- sample data
DROP TABLE #Sample
CREATE TABLE #Sample (UserName VARCHAR(15), [Time] CHAR(8), FieldValue TEXT)
INSERT INTO #Sample (UserName, [Time], FieldValue)
SELECT 'Bob Hope', '12:00:00', 'We cannot do anything until 1 O''Clock - the...
September 24, 2012 at 8:04 am
jampabsatish (9/24/2012)
It works like a champThank you very much Chris !!
You're welcome, and thanks for the feedback. Note that both the problem and the solution appear earlier in this thread;
ssurve...
September 24, 2012 at 7:29 am
-- use NULLIF to convert 0 to NULL
-- conversion code 112 matches the input style
-- Char(8) matches the input length
SELECT
aprvdt,
ApprovalDate = CONVERT(DATETIME2,CAST(NULLIF(aprvdt,0) AS CHAR(8)),112) -- 112 matches the...
September 24, 2012 at 7:18 am
An alternative;
UPDATE a SET [Status] = 1
OUTPUT inserted.Id, inserted.EntityID, inserted.EntityType, inserted.EntityOperation
FROM (SELECT TOP (1) Id, EntityID, EntityType, EntityOperation, [Status]
FROM ATH_SyncEntities a
WHERE [Status] = 0
ORDER BY EntityType,...
September 24, 2012 at 6:26 am
S_Kumar_S (9/24/2012)
Here is sample script:
create table a(id int, nm varchar(200))
insert into a
select 1,'a'
insert into a
select 1,NULL
select * from a where nm not in('a')
I logically expect NULL records to be returned...
September 24, 2012 at 4:51 am
Having made some sense of the mess, you can play with different ways of getting the same result;
-- note how 'shop' and 'site' can be distinguished either in the output...
September 24, 2012 at 4:42 am
ananda.murugesan (9/19/2012)
Hi,Is it possible to change alternative way to modified this sql statement. its tooks 2.47 min for fetching 151 records,
...
There are several. Putting all those many many correlated subqueries...
September 24, 2012 at 4:21 am
a4apple (9/21/2012)
I have a proc, that is used as a job previously that pulls lot of data. From the past 2 days, it is getting failed due to the...
September 24, 2012 at 1:56 am
Viewing 15 posts - 5,581 through 5,595 (of 10,144 total)