I agree with you, GIGO. But I am inheriting this system.
The Vendor who wrote this system for us obviously didn't know how to design a database.
I have to deal with tables with no primary key, never normalized data and no help from the vendor.
OK I get 256 records when I run that, maybe there ar4e 256 bad records. I was thinking that there was only one bad record and was trying to narrow it down.
the SQL I am running is this:
DECLARE @startingdate datetime;
DECLARE @endingdate datetime;
SET @startingdate = '01/01/2007';
SET @endingdate = '12/31/2007';
IF OBJECT_ID (N'dbo.Temp_ReportData', N'U') IS NOT NULL
DROP TABLE dbo.Temp_ReportData;
SELECT
ITEM AS NAME,
INVDATE AS...
Haw can I get the result set to not have NULLs?
my latest SQL:
Update .dbo.Temp_ReportData
SET JanAmt = JanAmt +
(Select SUM(ISNULL(cost,0)) FROM dbo.Temp_Detailstable
WHERE dbo.Temp_Detailstable.Cnumber = Temp_reportData.cnumber AND...
First let me explain that the final product will have #temp files. The reason I created database temp files is so I could have something to work with as an aid to development.
Anyway this is not being developed on the 'Live' database. It is only a copy. So I am not ruining anything.
I...
I wanted to update an entire column (January) in my report table. I need a different way to do this. I got this error when running the following:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an...
Ok the motivation for writing this trigger and stored procedure was because we don't have access to the application source code and can only tamper with the database as a way of correcting this problem.
Instead of Update, we could use INSERT, DELETE.
Or we could update all records thru a job...
The Cnumber is a 10 character Alphanumric field. The stored procedure will update only one conference.
This is what I have now and it passes the syntax check:
CREATE TRIGGER [fixcounts] ON [dbo].[REGISTR]
AFTER UPDATE
AS
DECLARE @The_Cnumber AS Varchar(10)
Select @The_Cnumber =...
This is what I have so far and it will not pass the syntax check.
CREATE TRIGGER [fixcounts] ON [dbo].[REGISTR]
FOR INSERT, UPDATE, DELETE
AS
EXEC ospreytraining2.dbo.UpdateOneConferenceCounts
@The_Cnumber = dbo.registr.cnumber;
The Non-profit I work for sells registrations to courses as the main business. Only once every 24 hours is a process run that updates the counts, and so occasionally there is overbooking. The reason is that it takes a long time to run, and this was a poor design anyway.
I want to add an...
I have a large SQL statement with a Union to another large SQL stmt. When I run it I see the data in the results pane of query analyzer. I want to put the results into a temp table to be able to write additional sql statements to update another table. Also to speed up execution I should...
My beginning of code is:
Create Procedure RevenueByMonth
@startingdate datetime,
@endingdate datetime
SET @startingdate = '01/01/2007'
SET @endingdate = '12/31/2007'
I am getting this error:
Server: Msg 156, Level 15, State 1, Procedure RevenueByMonth, Line 6
Incorrect syntax near the...
Only the first SQL statement seems to do anything. The second creates a temp table in my database and no temp table exists after execution. Do I need to put the word GO between each statement?
I have a very complex crosstab type of report I have been assigned to produce and my approach has been to create a temp file in the database with all the column headings and zeros in all the places where the numbers would go. What I want to do is to use several SQL statements to update the...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.