Viewing 15 posts - 376 through 390 (of 1,439 total)
Try using a database trigger
CREATE trigger mytrigger on database for create_table,alter_table,drop_table
AS
...
April 29, 2013 at 1:59 am
Both INSERT and UPDATE support the OUTPUT clause
UPDATE Target
SET Target.AlphaValue = Source.AlphaValue, Target.NumericValue = Source.NumericValue
OUTPUT inserted.*, deleted.*
FROM TargetDB.dbo.AdmFormData AS Target
INNER JOIN SourceDB.dbo.AdmFormData AS Source ON (Target.FormType = Source.FormType and Target.KeyField...
April 24, 2013 at 9:20 am
Use a separate INSERT and UPDATE statement, something like this
UPDATE Target
SET Target.AlphaValue = Source.AlphaValue, Target.NumericValue = Source.NumericValue
FROM TargetDB.dbo.AdmFormData AS Target
INNER JOIN SourceDB.dbo.AdmFormData AS Source ON (Target.FormType = Source.FormType and Target.KeyField...
April 24, 2013 at 8:14 am
I get a different error message
The insert column list used in the MERGE statement cannot contain multi-part identifiers. Use single part identifiers instead.
Try this instead
MERGE dbo.AdmFormData AS Target
USING dbo.AdmFormData AS...
April 24, 2013 at 7:07 am
Something like this??
DECLARE @t TABLE(DeliveryDate DATE,Assigned INT,Unassigned INT, Total INT)
INSERT INTO @t(DeliveryDate,Assigned,Unassigned)
VALUES
('2013-04-29',1,0),
('2013-04-29',1,1),
('2013-04-29',1,1),
('2013-04-29',1,1),
('2013-04-30',0,0),
('2013-04-30',0,1),
('2013-05-01',0,0);
SELECT DeliveryDate,Assigned,Unassigned,
SUM(Assigned + Unassigned) OVER(PARTITION BY DeliveryDate) Total
FROM @t
ORDER BY DeliveryDate
April 23, 2013 at 9:59 am
SELECT
(SELECT 'Field1' AS "@name", Field1 AS "text()" FOR XML PATH('ColumnValue'),TYPE),
(SELECT 'Field2' AS "@name", Field2 AS "text()" FOR XML PATH('ColumnValue'),TYPE),
(SELECT 'Field3'...
April 19, 2013 at 2:55 am
If you're using SQL Server 2012, you can do this
;with Data(ClassID, MemberID, Weight) as
(
select 'A', 1, 10 union all
select 'A', 2, 20 union all
select 'A', 3, 40 union all
select 'A',...
April 17, 2013 at 10:04 am
Also this
SELECT child.value('(parent::node()/ID/text())[1]', 'NVARCHAR(50)') AS [ID]
, child.value('(State/text())[1]', 'NVARCHAR(50)') AS [State]
, child.value('(Value/text())[1]', 'NVARCHAR(50)') AS [Value]
FROM [XmlTable]...
April 16, 2013 at 2:55 am
2Tall (4/12/2013)
OK, it looks like I was over thinking it.[Code]
UPDATE Documents
SET DocumentFileName = REPLACE(DocumentFileName,'TIF','pdf')
WHERE DocumentFileName LIKE '%.TIF' AND DocumentLinked = '1'
[/Code]
Can anyone see any potential issued with above code?
Kind Regards,
Phil.
That...
April 12, 2013 at 5:27 am
This uses a tally table, probably not very efficient though.
DECLARE @Plates TABLE(StartPlate INT, StopPlate INT);
INSERT INTO @Plates(StartPlate, StopPlate)
VALUES(1,12),(15,23);
DECLARE @BrokenPlates TABLE(StartPlate INT, StopPlate INT);
INSERT INTO @BrokenPlates(StartPlate, StopPlate)
VALUES(3,7),(15,18),(21,22);
WITH E1(N) AS (
...
April 10, 2013 at 3:37 am
Maybe this?
SELECT d.ID
FROM DATA d
LEFT OUTER JOIN NEW_DATA n ON n.CODE = d.CODE AND n.CNAME=d.CNAME
GROUP BY ID
HAVING COUNT(*) = COUNT(n.CNAME);
April 9, 2013 at 4:28 am
Try changing
INSERT INTO Build_list
(ContractID, SectionID, ItemID, Qty)
SELECT...
April 8, 2013 at 8:27 am
Another one to try
WITH Numbers(N) AS (
SELECT N
FROM ( VALUES(1),(2),(3),(4) ) Numbers(N)),
Recur(N,Combination) AS (
SELECT N, CAST(N AS VARCHAR(1000))
FROM Numbers
UNION ALL
SELECT n.N,CAST(r.Combination + ',' + CAST(n.N AS VARCHAR(10)) AS VARCHAR(1000))...
April 2, 2013 at 5:10 am
You can do this instead, although I don't think it will make much difference
WITH Results AS (
SELECT CustomerName, PostalCode
FROM @CustomerOffices
WHERE OfficeId BETWEEN @FromOfficeId AND @ToOfficeId)
SELECT 'Summary' as Summary,
...
April 2, 2013 at 3:14 am
Good job of posting sample data + results. Thanks.
SELECT 'Summary' as Summary,
STUFF((SELECT ',' + CustomerName AS "text()"
FROM @CustomerOffices
...
April 2, 2013 at 2:15 am
Viewing 15 posts - 376 through 390 (of 1,439 total)