Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all 13329 articles
Browse latest View live

Run-time error '3075'

$
0
0
Hi guys,

I am currently stuck on this SQL command that seems to giving me no sense of answer..

The SQL is this:
INSERT INTO DatabaseBackupHistory(SourceFilePath,SourceDatabas eFileName,BackupFilePath,BackupDatabaseFileName,Ba ckupDatabaseDate,User,Activity) VALUES('" & Forms!Switchboard!CurrentPage!DefineSubForm!txtFil eURL & "','" & Forms!Switchboard!CurrentPage!DefineSubForm!txtfil ename & "','" & Forms!Switchboard!CurrentPage!DefineSubForm!txtFil ePathSave & "','" & Forms!Switchboard!CurrentPage!DefineSubForm!txtSav eFileName & "','" & Now & "','" & Forms!Login!activeuser & "','Back-ups " & Me.txtfilename & " database')"

The error message is:
Syntax error (missing operator) in query expression
"Some source file path\CurrentProject.accdb','CurrentProject.accdb".

Then I tried fixing/removing the double quotes, but whenever no error is found and the SQL is run by DoCmd.RunSQL the problem then is that it stores exactly the Now method and the activeuser but the rest are not.

Do anyone have idea what could be the problem? Thanks in advance...

Easy One using counts in wheres

$
0
0
Some reason I am stuck on this one.

Select Count(InspectionID) as NumberOfDupes,[Date],Location,PermitID,Inspector,[Type]
From Inspections
Where NumberOfDupes > 1 and Deleted <> 1
Group By [Date],Location,PermitID,Inspector,[Type]
Order By [Date], NumberOfDupes, Location, PermitID

and I get...

Msg 207, Level 16, State 1, Line 3
Invalid column name 'NumberOfDupes'.

I need to get a report of all duplicates. If there is only one occurrence then it is not a duplicate.

Table Structure...

CREATE TABLE [dbo].[Inspections] (
[InspectionID] int IDENTITY(1, 1) NOT NULL,
[Location] int NOT NULL,
[Date] datetime CONSTRAINT [DF_Inspections_Date] DEFAULT getdate() NOT NULL,
[Inspector] int NOT NULL,
[Travel] float CONSTRAINT [DF_Inspections_Travel] DEFAULT 0 NOT NULL,
[Time] float CONSTRAINT [DF_Inspections_Time] DEFAULT 0 NOT NULL,
[Type] int CONSTRAINT [DF_Inspections_Type] DEFAULT 1 NOT NULL,
[Violations] bit CONSTRAINT [DF_Inspections_Green] DEFAULT 0 NOT NULL,
[CorrectedOnDate] datetime NULL,
[CorrectedByDate] datetime NULL,
[NumberOfViolations] int DEFAULT 0 NULL,
[Mileage] float NULL,
[ReinspectionDate] datetime NULL,
[PermitID] int DEFAULT 0 NULL,
[PermitTypeID] int DEFAULT 0 NULL,
[Comments] varchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Deleted] bit DEFAULT 0 NULL,
[Passed] bit DEFAULT 0 NULL,
[Finaled] bit DEFAULT 0 NULL,
[LifeSafetyViolations] int DEFAULT 0 NULL,
[FireProtSysViolations] int DEFAULT 0 NULL,
[MinorViolations] int DEFAULT 0 NULL,
[SqrFootage] int DEFAULT 0 NULL,
[NewNotSynced] bit DEFAULT 0 NULL,
[AdminViolations] int DEFAULT 0 NULL,
[ModifiedOn] datetime NULL,
[ReInspectionFee] float NULL,
[LifeSafetyCorrectedBy] datetime NULL,
[FireProtSysCorrectedBy] datetime NULL,
[MinorCorrectedBy] datetime NULL,
[AdminCorrectedBy] datetime NULL,
[LifeSafetyCorrectedOn] datetime NULL,
[FireProtSysCorrectedOn] datetime NULL,
[MinorCorrectedOn] datetime NULL,
[AdminCorrectedOn] datetime NULL,
[RealMiles] float DEFAULT 0 NULL,
[RealTime] float DEFAULT 0 NULL,
[RealTravel] float DEFAULT 0 NULL,
[AHJID] int DEFAULT 0 NULL,
[FireProtViolationCorrected] int DEFAULT 0 NULL,
[HazardsCorrected] int DEFAULT 0 NULL,
[IsReinspection] bit DEFAULT 0 NULL,
[InspectionFee] money DEFAULT 0 NULL,
[ConstructionViolationCorrectedOn] datetime NULL,
[NumberOfCorrected] int DEFAULT 0 NULL,
[FireProtViolationOutstanding] int DEFAULT 0 NULL,
[HazardsOutstanding] int DEFAULT 0 NULL,
[NumberOfOutstanding] int DEFAULT 0 NULL,
[AveragedRealNumbers] bit DEFAULT 0 NULL,
[CTReportId] int NULL,
CONSTRAINT [PK_Inspections] PRIMARY KEY CLUSTERED ([InspectionID])
WITH (
PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
ON [PRIMARY]
GO

EXEC sp_addextendedproperty 'MS_Description', N'FID Number', N'schema', N'dbo', N'table', N'Inspections', N'column', N'Location'
GO

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [dbo].[Inspections_triu] ON [dbo].[Inspections]
WITH EXECUTE AS CALLER
FOR INSERT, UPDATE
AS
BEGIN
/* Trigger body */
IF @@ROWCOUNT=0 RETURN
UPDATE U SET ModifiedOn = GETDATE()
FROM INSPECTIONS U INNER JOIN INSERTED I ON U.InspectionId = I.InspectionId

END
GO

Multiple unique ways of executing a simple query?

$
0
0
I have to come up with 5 different ways (unique execution plans) to process the following query.
Find the items that are delivered by all suppliers.

My database holds the following tables:
QSPL – it holds a list of supplier names
SPLNO (number)
SPLNAME (varchar)

QDEL – it holds delivery items, suppliers, and departments
DELNO (number)
DELQTY (number)
ITEMNAME (varchar)
DEPTNAME (varchar)
SPLNO (number)

QITEM – it holds list of items
ITEMNAME (varchar)
ITEMTYPE (varchar)
ITEMCOLOR (varchar)

I was able to successfully come up with the following four unique queries.

1.
select itemname --, etc.
from qitem
where itemname not in
(select itemname
from qitem, qspl
where (char(splno)+itemname) not in
(select char(splno)+itemname
from qdel));

2.
select itemname --,etc.
from qitem
where not exists
(select *
from qspl
where not exists
(select *
from qdel
where qdel.itemname = qitem.itemname
and Qdel.splno = qspl.splno));

3.
select a.itemname --, etc
from qitem a join qdel b on a.itemname = b.itemname
group by a.itemname
having count (distinct splno) = (select count(*) from qspl);

4.
select itemname
from qdel
group by itemname
having count (distinct splno) = (select count(*) from qspl);


I have no idea what to do for a 5th unique query.
Does anyone have a clue?

I tried to put this question in the best possible context with significant detail, feedback is greatly appreciated.

Thanks
:beer:

Linked server to oracle.

$
0
0
Does anyone know what this error message means? How do I fix this error?
Msg 7308, Level 16, State 1, Procedure UFN_SRBRECR_LIST, Line 7
OLE DB provider 'MSDAORA' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.

I am trying to run some SQL in SQL Server 2008 that will retrieve data from an Oracle database running on Lynix .

Creating multiple amoritization tables, and summarizing

$
0
0
Hello all! I hope someone here can help me.

I am a very active user of a peer-to-peer lending site, and have funded over 700 loans over the past few years. The problem I have is that I have no way to accurately predict the payments I will receive as these loans are repaid.

What I want to do is import a table from excel that contains the information in each loan. The fields would be as follows:

Issue Date
Loan ID
Term (number of payments)
Purchase (amount I paid for the loan)
Payment Amount (monthly payment I get)

(The following will be filled in as the loan is fully paid)
Payoff Date
Total Paid
Profit (Total paid - purchase)
Profit Percent (profit/purchase)

From that table, I would like access to generate a sub-table, with the following:

-Loan ID (same as first table)
-Payment date (Issue date + 1 month for x number of months (term of loan))
-Payment amount (will equal payment amount in first table)

From there, I should be able to do a group-by query or report that shows the total payments for each month, not including the loans that have a pay-off date entered.

I found an excel template that will generate the list of payments, but I would have to run it manually on all 700 loans. There has to be a better way, right?

I really appreciate any & all advice I can get. My excel spreadsheet has worked out well enough, but this is getting too big to track easily.

Data Corruption

$
0
0
Has anyone ever had the database get corrupted but can't figure out what is causing the problem. Every once and a while i'll have one of the records get corrupted and the data in that record will have mostly Asian characters (don't know if it's Chinese, Japanese, or what) with some random ?<>?:!@#$ characters mixed in. This corrupted records will crash any queries or macros that run that access that data. You can't delete the record nor can you change any of the data in it that record through normal methods. I can do a " Compact and Repair" the database, delete the record, and all will function perfectly until the corruption occurs again. Does anyone have any insight as to why this is happening with a possible solution. Attached a pdf of the data in question.

Attached Files
File Type: pdf data.pdf (111.5 KB)

This action can't be carried out while processing a form or report event.

$
0
0
Hello,
I am trying to put the command: DoCmd.Close acForm, "AppointmentF", acCloseSaveYes in the lostfocus event in a textbox on my form AppointmentF. The plan is to have the form automatically close and save if the user tries to tab past this textbox. It is the bottom of the tab order in the form and I don't want them to be able to automatically create a new record if they simply keep tabbing and do not close the form. In the same event I also have Forms!MonthlyCalendarF!.SetFocus which is to set focus back to the main form MonthlyCalendarF. When I try this out and I tab out of the textbox I get the error message: This action can't be carried out while processing a form or report event. I cannot figure out why this is happening. Any help would be greatly appreciated. :)

Dlookup Syntax

$
0
0
I have been struggling with this for hours. I am unsure if I am taking the right approach or should do this another way. Any help would be greatly appreciated. This is for a user login form. I am making attempts to check and see if the password is valid against the username and if it is, then wanting to check to see if the [Password] is equal to the default word Password (assigned upon intially creating the record). Any help would be greatly appreciated. This is what I have been working and re-working. Thanks in advance.:o

Code:

If Me.txtPassword.Value = DLookup("[Password]", "tblUserLogin", "[Username] = ' & Me.cboUsername.Value and [Password]='Password' & "'"") Then

Splitting 1 column and inserting into multiple columns

$
0
0
Db2 9.7 FP 7 LUW

Hello,
I have a flat file (.csv) which come from legacy systems non-RDBMS. Some columns have multiple occurrences which needs to be split with integrity in DB2. Here is an example of what i'm trying to do:

ADDRESS
123abc~234bcd~345cde~456def~567efg
111aaa~222bbb~~~
999zzz~~~888yyy~

-There will always be a value before and after a ~ whether it is null or not. If null, it must insert as null in target column, which will be nullable.

Split the 5 occurrences and possibly set them in a variable and insert that variable into it's respective target column.

So essentially I should be able to loop through each record, find values before and after tilde's and insert those into target columns.

PASS Summit 2013

$
0
0
The PASS Summit 2013 is coming, and I will be attending!

Will anyone else from DBForums be there? If so, I'd like to "meet up" if we can!

Does anyone have questions that they'd like me to ask while I'm there? This is the world's largest, most focused event on Microsoft's Data technologies. This will be the opportunity of the year for getting access to and answers from the people who create new versions of SQL Server and the best known third-party tools to manipulate it!

Feel free to post questions for me to take to the Summit in search of answers, and if you are also going to the Summit please contact me to see if we can meet up!

-PatP

cbo Dropdown disappears

$
0
0
User of one of my existing db's alerted me to a problem that may be from a difference in access 2010 vs 2003.

I have a cbo that drops down as soon as it gets focus:
Private Sub cboMBName_GotFocus()
Me!cboMBName.dropdown
End sub

Prior to 2010, when the cbo was entered, the dropdown occurred and stayed dropped while the user typed, moving down the alphabetic selections appropriately. In this scenario, when the first several characters had narrowed the selection, the user could then click on a following selection if appropriate.

In the new environment (without changing any programming) the dropdown occurs as before but disappears as soon as typing starts. The user is required to click the dropdown arrow if he wants a slightly lower selection.

Is this now the expected result for .dropdown ? Is there a way to return to the older action?

Create Crystal report on top up SAP ECC6 tables and views

$
0
0
Hello,

I am very new to crystal report.I am trying to connect Crystal report 2011 SP4 to SAP ECC6 to fetch data from SAP ECC6 system to build a report.
I am able to connect with SAP system but while fetching data and showing in the crystal report SAP table having data type (Char[10]) converted into
string[0].
Data is not showing in crystal report.
Please find attachment.
Please help me............

help to format datetime

$
0
0
guys,

Need your help to format my date in crystal report.
my data source is came from SQL server database and i used crystal report to pulled out data. i need the result of my date in crystal report like the format of SQL. when download the file in excel data only the result has a am and pm. thanks in advance.



SQL Server format =“2012-06-21 10:09:26.000” --need this format in CR

Crystal Report format = 4/3/2009 4:00:00AM


jov.

IIF Statement pulling value from table

$
0
0
I am wanting to write an IIF statement that pulls value from another unrelated table.
Statement is something like this Variance: IIf([ListBalance] Between 1 And -1,"InVariance","OutofVariance")

I would like to beable to pull the 1 and -1 from a configuration table?
Any help appreciated.

thanks

Security

$
0
0
Is there an easy way to apply security to an application. Instead of capturing information about the users and assigning a security level can I prompt for password on certain functions? If so how. Thanks

Issues with Counting (DCount, Criteria, etc)

$
0
0
Hello,

I have a table that I would like to perform an Access query on, preferably avoiding VBA. Using Access 2010.

I have a table of records, with surrounding quantitative and qualitative data. What I'd like to do is count the total number of records for each business division, and then within each business division the number of records fulfilling two different criteria, and then perform a calculation on sums of values within records in each business division.

For instance, I have store A and B. Store A made 100 sales (# of records), and store B made 200 sales. Of those 100 and 200 sales, 30 and 40 sales respectively have a value of "Yes" in a 'Yes' or 'No' column. Of those 100 and 200 sales, 70 and 90 have a sale price that is neither blank or non-zero (not necessary to know how many of the 70 and 90 had yes/no). Lastly, I'd like to sum up the total value of sales over those 100 records and 200 records and subtract the total value of another variable. Let's say the difference is 300 and 400.

Outcome should be:

A / 100 / 30 / 70 / 300
B / 200 / 40 / 90 / 400

I tried using a standard Query, where I grouped by store name. Then I tried to add query columns with "Total: Count" for the other fields, but when I add Criteria values such as {<>"No"} or {>0} there's a "Data type mismatch in Criteria expression." If I include a Total: Group By column I can add the filter, but that adjusts the filter for my entire query (it will filter out all the "No" and non-zero records)

I tried DCount, where I entered a column with something like the following in the top column:

DCount("Sale Price","tblSales", "[Sale Price] > 0")

But that told me the total number of non-sales over all stores, not just A and B.

Not really sure what to do at this point. I could see myself creating multiple queries and building one query to sample all of them, but this record table is massive. Advice? Any additional info I can provide?

Sum Rows based on a condition

$
0
0
I'm using a db2 database (not sure of the version). My script is functional but I'm not producing the results I expect. I need to separate my aggregate totals in to 3 groups based on conditions in my case statement but for every project under the same project_name/id and building_name/id, I need the sum total under each bucket having only one row per project_name/id and building_name/id. I assume a group by of some sort or a recursive function would be the solution but I'm not quite sure. Would appreciate a push in the right direction. Here is my script. The attached thumbnails display the current results and desired output.

Code:

SELECT
        DP.DIM_PROJECT_ID,
        DP.PROJECT_NAME,
        DM.DIM_BUILDING_ID,
        DM.BUILDING_NAME,
        CASE WHEN ( DJ.GROUPS3 IN ('33.3% <= x <= 100%', '16.7% <= x < 33.3%') AND DA.TYPE_NAME = 'SALES') 
        THEN cast(sum(cast(FAT.TRANSACTION_AMOUNT as real)) as integer)
        WHEN (DJ.GROUPS3 IN ('60% <= x <= 100%', '20% <= x < 60%') AND DA.TYPE_NAME = 'SALES')
        THEN cast(sum(cast(FAT.TRANSACTION_AMOUNT as real)) as integer)
        ELSE '0'   
        END as CAPABILITY,     

        CASE WHEN (DJ.GROUPS3 = '0% <= x < 16.7%' AND DA.TYPE_NAME = 'SALES')
        THEN cast(sum(cast(FAT.TRANSACTION_AMOUNT as real)) as integer)
        WHEN (DJ.GROUPS3 = '0% <= x < 20%' AND DA.TYPE_NAME = 'SALES')
        THEN cast(sum(cast(FAT.TRANSACTION_AMOUNT as real)) as integer)
        ELSE '0'           
        END as GROUP_1,

        CASE WHEN (DJ.GROUPS3 = '16.7% <= x < 33.3%' AND DA.TYPE_NAME = 'SALES')
        THEN cast(sum(cast(FAT.TRANSACTION_AMOUNT as real)) as integer)
        WHEN (DJ.GROUPS3 = '20% <= x < 60%' AND DA.TYPE_NAME = 'SALES')
        THEN cast(sum(cast(FAT.TRANSACTION_AMOUNT as real)) as integer)   
        ELSE '0'       
        END as GROUP_2,

        CASE WHEN (DJ.GROUPS3 = '33.3% <= x <= 100%' AND DA.TYPE_NAME = 'SALES')
        THEN cast(sum(cast(FAT.TRANSACTION_AMOUNT as real)) as integer)
        WHEN (DJ.GROUPS3 = '60% <= x <= 100%' AND DA.TYPE_NAME = 'SALES')
        THEN cast(sum(cast(FAT.TRANSACTION_AMOUNT as real)) as integer)
        ELSE '0'           
        END as GROUP_3

FROM FACT_TABLE as FAT
RIGHT JOIN DIM_ALLOCATION DA ON FAT.DIM_ALLOCATION_ID = DA.DIM_ALLOCATION_ID
INNER JOIN DIM_PROJECT DP ON FAT.DIM_PROJECT_ID = DP.DIM_PROJECT_ID
INNER JOIN DIM_DATE DD ON FAT.ALLOCATION_START_DATE_DIM_ID = DD.DATE_KEY
INNER JOIN DIM_JOB DJ ON FAT.DIM_JOB_ID = DJ.DIM_JOB_ID
INNER JOIN DIM_BUILDING DM ON FAT.DIM_BUILDING_ID = DM.DIM_BUILDING_ID

WHERE
    DD.DATE_VALUE = '2013'
    AND DA.MACHINE_NAME IN ('ADMIN', 'INVISION')


GROUP BY DM.DIM_BUILDING_ID,
        DP.DIM_PROJECT_ID,
        DP.PROJECT_NAME,
        CAPABILITY,
        DM.BUILDING_NAME,
        DJ.GROUPS3,
        DA.TYPE_NAME
ORDER BY DP.PROJECT_NAME


Attached Images
File Type: png Capture1.PNG (20.9 KB)
File Type: png Capture.PNG (11.7 KB)

pulling a unbound calculated form field into a query

$
0
0
What expression would I use to pull an unbound form field into a query?

Thanks.

Restoring Table space backup

$
0
0
unfortunately my table space userspace1 is dropped but when I am trying to restore that tablespace from full backup image ,I am getting this error

SQL2549N The database was not restored because either all of the table spaces in the backup image are inaccessible, or one or more table space names in list of table space names to restore are invalid.

when I googled it I came to know that we will get this error we restore the tablespace from the tablespace level backup Image,but here I am getting same error .

so can we restore the the tablespace from the full backup image ,when it is dropped ?

Please advise me


thank you in advance

Need tool to query across multiple databases

$
0
0
I have a some SQL and Oracle databases that I need to be able to join and query across. I need a tool that will facilitate this easily and preferably free. For example database 1 has multiple sql 2008 tables but I want Cust_info table and the field meter and then in the oracle database I need the meteraccts table and the meternumber field...which are the joiner fields. I am having trouble find something that will do this easily...I have down loaded..dbvisualizer, anysqlmaestro, oracle developer..etc These will let me see the different databases but not query both...or at least I can't see how. Any help with a tool or with a sql syntax would be appreciated. I have tried to link the databases and join them but I'm missing something. Thanks
Viewing all 13329 articles
Browse latest View live