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

TSQ-Statement

$
0
0
Hello,

I have got four tables.

PURCHASE
PurchaseID Date ProductID CustomerID
1 2012-02-01 1 1
2 2012-02-02 2 2
3 2012-02-03 3 3

PRODUCT
ProductID ProductName ProductPrice ProductTypeID
1 Michelin X4t 2000 150.00 1
2 Craftsman 6000T 97.00 2
3 Duracell AAA 6 Pack 12.00 3


PRODUCT TYPE
ProductTypeID ProductTypeName
1 Automobile Tires
2 Drills
3 Batteries
4 Motor Oil

CUSTOMER
CustomerID FirstName LastName PhoneNumber EmailAddress
1 Steve Smith 6045554567 ssmith@hotmail.com
2 John McLean 7675679876 johnm@gmail.com
3 Peter Harrington 6045762934 petedog@yahoo.ca


Using the sample data as a guide, how would you write a TSQL statement that lists the number of each product type purchased by each customer for the month of February 2012. Here is what the resulting data set would look like:

CustomerID FirstName LastName NumAutoTires NumDrills NumBatteries NumMotorOil
1 Steve Smith 4 0 10 1
2 John McLean 2 2 0 18
3 Peter Harrington 1 1 2 4
4 Wendy Foster 4 0 8 0

Thanks a lot.

dbBee - Turn Excel Spreadsheet or Access Database into a powerful online application

$
0
0
Whatever you do, there is something that you need or wish to share with your customers, business partners, members of an organization, support club, friends or any kind of your target audience.

Now, everybody knows how to use Excel and many know how to use Access, but when it comes to publishing it on the Internet, things start to complicate.

Well, not any more!

dbBee is frustration-free software for simple and easy publishing, maintaining and sharing data stored in your MS® Excel® Spreadsheet or MS® Access® database. It enables an average user to publish his Excel workbook or Access database without any programming knowledge and without any changes to the original file (Excel workbook or Access database). Furthermore the user can easily and effortlessly create an application for adding, updating and deleting records (rows) or the one that will enable collecting data online from visitors of his website. And all that will take less time than what's needed to explain an idea to a programmer.

With dbBee database can easily be published, searched and sorted, populated with new data, maintained. dbBee system does not alter the structure of original document, so one can allow visitors to add data to it, download it and use it for whatever purpose.

dbBee includes fully featured free plan, that can be used both for personal and commercial purpose. The paid plans are usage-based and one does not need to delete an account or projects in periods of inactivity. When account is not active, only public parts of the projects become unavailable (deployed applications work only when account is active).


More info http://www.dbbee.com/

Date formatting

$
0
0
Hello all,

I have to make an expression which will allow me to convert the form of one of my date columns so that it will eb coherent for my next query.

This is what i tried
' Mois: Format([001- Format OF 7-15-29]![' Mois];""mm/yyyy")

But it doesn't work !

What i'm looking for is 01/2015 and so on so forth

Any ideas ?

Stored procedure does not set isolation on session

$
0
0
Hi,
I am trying to set the default isolation and lock time out for a datasource.
I have tried datasource properties, but the driver we are using in production does not support these.
We also do not have a WebLogic-specific datasource property for these.
This can be achieved however by setting the "Init SQL" property of the datasource to "SQL set isolation to ?".
My problem is that i need both the isolation and the lock timeout set.
Enter the stored procedure ...
If i am able to write a stored procedure that does both of these things then i can set the "Init SQL" to "SQL execute procedure iso_lock()"
This however does not work.
If i open a connection / session to DB2 and manually execute the isolation or lock timeout, it takes effect.
if however i open a connection and manually execute the stored procedure, it does not take effect.
I have also tried using the EXECUTE IMMEDIATE method inside the stored procedure and this also does not work.
The stored procedure code is shown below.

CREATE PROCEDURE "schema"."iso_lock"
()
BEGIN
set isolation to UR;
set lock timeout to 10;
END

#Deleted All Access versions with SQL 2012

$
0
0
Hi all - New problem

I have Access 97, 2010 and 2013

When i create a DSN to SQL 2012 in any of these versions - I see my tables.

But when ever I open these tables all i see is the #deleted

The row or record count is correct but every field says #deleted. If I use a standard Access query - same result

If I use a passthrough - I see the data

If I open a table and see all the #deleted records - i can still enter a row of data but a refresh changes the row to #deleted

If i run a make table query the records are written into a local table and the data is viewable.

Any Ideas?

Report manager Error:the requested url

$
0
0
Hello I am trying deploy reports on the report manager but I keep getting this message.
Attached Images

Stored procedure dynamic where clause poor performance

$
0
0
Hello all,

Can someone explain me why the SQL below is taking too long to respond?
I've built a Stored procedure with 5 input parameters and the idea is to dynamic use them.
The table is large about 3 million records.

SELECT column1,
column2
FROM tableA
WHERE (PARAMETER IS NULL OR column3 = PARAMETER)


Please note if I remove the condition "PARAMETER IS NULL OR" the search is extremely fast.

Database engineers begging for feedback

$
0
0
A bunch of us engineers working on SQL Server would like to learn more about real-world experiences and challenges people have with databases. We would love to hear from startups building cloud applications who don’t use SQL Server -- we don’t often get feedback from this segment of users.
We are not selling or marketing anything – just engineers who would like to listen about what you like and don’t like about databases that you use and the challenges you have to deal with.

Take the 4-question survey https://www.surveymonkey.com/s/7RG87MP if you are willing to share your knowledge.

Tony

Newbie question: what is an activator?

$
0
0
Hello,

I'm a consultant with an iSeries background starting in a role managing software environments at a client using Sybase, which I don't have experience in. The platform is Solaris (as-is) and RHEL (to-be)
I normally find I can grasp enough about a technology once I can translate the native terms into concepts I am already familiar with.
I am being asked can my team "create an activator on this host which points at this database" or "I can't see the activator for this test environment, can you re-start it?" While I have a team of people who do the doing, I don't understand what I'm asking them to do. :-(
To that end I am trying to understand what an "activator" is and what it is analogous to in iSeries or other platforms. I can't find reference to it on search engines or reference material, and the Sybase on-line help site has been down for the last few days.
Any newb help this group can offer would be much appreciated.

manual firing threshold procedure

$
0
0
hi guys, i've created a threshold procedure on one of my database. how do i test my threshold procedure if it is working. Thanks

how to download query data from mySQL

$
0
0
Hi, I have a non-profit website that I've developed with PHP. I'm trying to make the logged in users can output letters in Word with selected data from a query in MySQL. I've tried to use PHPWord, the letters outputted with no data in the letters. Also I tried used PHP COM, but Hostforlife won't let me restart the server because it is shared.
Lastly I wrote a SELECT query with INTO OUTFILE '$file' to create a CSV which the users could download and use to merge into Word, but because the database user does not have FILE access, it produces this error:

Error: Access denied for user 'blabla'@'localhost' (using password: YES)

I think Hostforlife will not allow FILE privileges on a shared server. So, how can I get around this. Somehow I want to be able to at least write the query and download the data. Javascript? jQuery? or Something else? Any of you can help me?

Thanks in advance :)

Db2cmd on Linux

$
0
0
Hi,

In one of my Db2 java procedure I am using a command like this & this

db2cmd -c -w -i db2 list database directory.

As I m using this command on windows. It is working good.
According to docs it is applicable only on windows.

Can someone tell me is there any exact same command , so that I can use that on LINUX.
I mean db2cmd on linux environment.


Thanks

SQL Server 2008 Linked Server to Sybase 15.5

$
0
0
Cannot create an instance of OLE DB provider "ASEOLEDB" for linked server "[SERVER_NAME]"

The current setup:
Our primary database is on Sybase, I needed to extract hierarchical (nested) XML from multiple tables on Sybase. Although Sybase ASE 15.5 has `FOR XML` query capability it does now allow nested XML format. So we used the 'FOR XML', XML functionality in SQL Server (as we had a SQL Server 2008 database available which is used for a smaller system) to query Sybase tables through a Linked Server connection.

Our sample nested XML Format is similar to:

<personCol>
<person>
<id>1111</id>
<name>John</name>
<age>21</age>
<sex>M</sex>
<addressCol>
<address>
<type>home</type>
<address>XXXX</address>
</address>
<address>
<type>work</type>
<address>YYYYY</address>
</address>
<address>
<type>delivery</type>
<address>XXXXXX</address>
</address>
</addressCol>
<status>single</status>
<phoneCol>
<phone>
<type>home</type>
<number>11111111</number>
</phone>
</phoneCol>
<note>Note 1</note>
</person>
<person>
<id>2222</id>
<name>Mary</name>
<age>45</age>
<sex>F</sex>
<addressCol>
<address>
<type>home</type>
<address>XXXX</address>
</address>
</addressCol>
<status>single</status>
<phoneCol>
<phone>
<type>home</type>
<number>22222222</number>
</phone>
<phone>
<type>work</type>
<number>3333333</number>
</phone>
</phoneCol>
<note>Note 1</note>
</person>
</personCol>

The Issue:

Everything is working perfectly when extracting data to XML format from Sybase via SQL Server. The issue is when the SQL Server machine is rebooted, the connection to Sybase can not be re-established automatically after the reboot. I get the following error from the executable that calls the SQL Server query:
Cannot create an instance of OLE DB provider "ASEOLEDB" for linked server "[SERVER_NAME]".

Once I execute the following command on the SQL Server it re-establishes a connection and it then works again until the machine is rebooted again:

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'[SERVERNAME]', @locallogin = NULL , @useself = N'False', @rmtuser = N'DEV_IIS_USER', @rmtpassword = N'password'

I've tried:

- Ensuring the SQL Server services are set to Automatic start when the machine reboots.

- Setup with the Server as following:


EXEC master.dbo.sp_addlinkedserver @server = N'[SERVERNAME]', @srvproduct=N'[SERVERNAME]', @provider=N'ASEOLEDB', @datasrc=N'[SERVERNAME]'

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'[SERVERNAME]',@useself=N'False',@locallogin=NULL,@rmtuser=N'DE V_IIS_USER',@rmtpassword='########'

EXEC master.dbo.sp_serveroption @server=N'[SERVERNAME]', @optname=N'collation compatible', @optvalue=N'false'

EXEC master.dbo.sp_serveroption @server=N'[SERVERNAME]', @optname=N'data access', @optvalue=N'true'

EXEC master.dbo.sp_serveroption @server=N'[SERVERNAME]', @optname=N'dist', @optvalue=N'false'

EXEC master.dbo.sp_serveroption @server=N'[SERVERNAME]', @optname=N'pub', @optvalue=N'false'

EXEC master.dbo.sp_serveroption @server=N'[SERVERNAME]', @optname=N'rpc', @optvalue=N'false'

EXEC master.dbo.sp_serveroption @server=N'[SERVERNAME]', @optname=N'rpc out', @optvalue=N'false'

EXEC master.dbo.sp_serveroption @server=N'[SERVERNAME]', @optname=N'sub', @optvalue=N'false'

EXEC master.dbo.sp_serveroption @server=N'[SERVERNAME]', @optname=N'connect timeout', @optvalue=N'0'

EXEC master.dbo.sp_serveroption @server=N'[SERVERNAME]', @optname=N'collation name', @optvalue=null

EXEC master.dbo.sp_serveroption @server=N'[SERVERNAME]', @optname=N'lazy schema validation', @optvalue=N'false'

EXEC master.dbo.sp_serveroption @server=N'[SERVERNAME]', @optname=N'query timeout', @optvalue=N'0'

EXEC master.dbo.sp_serveroption @server=N'[SERVERNAME]', @optname=N'use remote collation', @optvalue=N'true'

- Also tried:

sp_configure 'remote login timeout', 300

reconfigure with override

db2 plsql code on db2/400

$
0
0
Hi,

I have a question as we have developed some plsql procedures on Db2 10.5 on windows & linux. This is purely plsql code. as we need to run these procedures on all the databases under a particular instance.

My requirement is can I use the same plsql code on Db2/400. I mean on ISERIES. On Iseries database concepts are some what like LIBRARY, SOURCE PHYSICAL file, PHYSICAL file , LOGICAL FILE etc.

Can some one please tell me what is the database hierarchy of normal db2 server & db2/400. Will the code work on db2/400.

Thanks

alter column table on large table

$
0
0
Hi Guys, do you have recommended steps in altering table column on a large table more than 50millions rows, table has 5 nonclustered and 1 clustered index and 5 way partition.

Much appreciated on your inputs. TIA

DB2 FP back out

$
0
0
I have installed 9.7 fp7 on top of 9.7 fp2. If I want to go back to fp2, is it possible, if yes then what is the process?

Please tell for both DB2 v9.7 and V10.1, LUW.:beer:

ODBC Error

$
0
0
HI all I am having an issue with the odbc driver on our new LAB Wizard application, it uses sql server 2014 on the back end which is located on our server. When a user inputs a number which is an add, after the they print they get this error message concerning the ODBC driver, the programming said it has to do with how many long the characters are in each field, so I changed the nvarchar(30) to nvarchar(50) which he said to do but they are still getting that error. Anyone have any suggestions, Apparently the app writes to the database as well as a log file (text file).

Help I have no idea what the issue is.
Attached Images

Help me check the answers please

$
0
0
Hi there, I am very new to this forum. I had a databases exam today in the university. I have a report of the questions and answers and answers I choose.Can you please help me check, if I choose the right answers,
Here are the questions:

Please select all correct sentences (may be just one).
1. With a single DataBase Management System (DBMS) we cannot create and maintain different databases.
2. We must define a unique Database Schema for each database.
3. We cannot store information until the Data Base Schema is defined.
Answer1=2;3;
Kommentare:


Frage 2 : "Basic Relational DM " [2 Punkte]
Please select all correct sentences (may be just one).
1: Each relation may have multiple primary key.
2: Each relation may have multiple candidate key.
3: Each relation has exactly one primary key.
Answer2=3;
Kommentare:



Frage 3 : "Data Updating and Normalization" [2 Punkte]
Consider the following example:
Please select all correct sentences (may be just one).
Unbenannt.JPG
1: This relation IS NOT in Third Normal Form (3NF).
2: This relation IS in Third Normal Form (3NF).
3: We need to know functional dependencies to give an answer.
4: We need to know all rows (tuples) of the relation to give an answer.
Answer3=1;4;
Kommentare:



Frage 4 : "Relational Algebra (1)" [2 Punkte]
Unbenannt.JPG
Please select a correct sentence.
For the Join operation:
1. The schema of the resultant relation does not depend on the schemas of the source relations.
2. The schema of the resultant relation is equal to the schema of the first source relation.
3. The schema of the resultant relation is an union of all domains defined in source relations.
Answer4=3;
Kommentare:



Frage 5 : "Relational Algebra (2)" [2 Punkte]
Unbenannt.JPG
Please select a correct sentence.
1: A resultant relation of the Join operation does not contain null values at all.
2: A resultant relation of the Join operation does not contain null values under common column(s).
3: A resultant relation of the Join operation may contain null values under any column.
Answer5=1;

Kommentare:


Frage 6 : "Relational Calculus (1)" [2 Punkte]
Unbenannt.JPG
Query: "Get names of such products which were sold to London".
C == Customer, T == Transaction, P == Product
(P.Pname): ???
Please select the omitted WFF ( ???)
1. T C (P.P# = T.P# And T.C# = C.C# And C.Ccity=London)
2. T P (P.P# = T.P# And T.C# = C.C# And C.Ccity=London)
3. T C (P.P# = T.P# And T.C# = C.C# And C.Ccity=London)
Answer6=2;




Frage 7 : "Relational Calculus (2)" [2 Punkte]
Unbenannt.JPG
Query: "Get names of such customers who bought the product number 1, or bought any product which costs more than 1000".
a == Cname, b == C#, c == P#, d == Price
get (a) : b c d ???
Please select the omitted WFF( ???)
1. (Customer(a,b) And Transaction(b,c) And c=1 Or Product(c,d) & d >1000)
2. (Customer(a,b) And Transaction(b,c) And ( c=1 Or Product(c,d) & d>1000))
3. (Customer(a,b) And (Transaction(b,c) And c=1 Or Product(c,d) & d>1000))
Answer7=2;
Kommentare:





Frage 8 : "Data Sub-Language SQL (1)" [4 Punkte]

Unbenannt.JPG
Please define an SQL Query: "Get names of products, dates and total price of such transactions which dealt with customers from London".
Select Pname, Date, Qnt*Price
From Transaction, Product
Where Transaction.C# In (Select C# From Customer Where Ccity = London)






Frage 9 : "Data Sub-Language SQL (2)" [1 Punkte]
Unbenannt.JPG
Query: "Find a total number of such customers who bought the Product 1 and a total number of such customers who bought the Product 2".
Please select a correct definition of the query
Select P#, COUNT(*) From Transaction
Where P#=1 Or P#=2 Group By P#
1.
Select P#, COUNT(*) From Customer Where C# In
(Select C# From Transaction Where P#=1 OR P#=2)
Group By P#
2.
Select P#, COUNT(C#) From Transaction
Where P#=1 Or P#=2
3.
Answer9=2;
Kommentare:



Frage 10 : "Data Sub-Language QBE" [1 Punkte]

Unbenannt.JPG
Query: "Get names of all customers in London or Paris".
Please select the omitted example element( ?)
1. P.Y
2. P.X
3. X
Answer10=1;
Kommentare:





Sorry for my bad englisch.
I hope for an answer.
Attached Images

Displaying record in a form

$
0
0
Having problems with getting the form to display all the records in the current database. When I look in the table it shows the records. But in the form is only shows the current record or and records that have been add at that time. When I close the form and reopen the form it says showing record 1 of 1. Is there a way through vba to correct this problem with the form. I have check is there is not filter set.

Recovering Stored procedure?

$
0
0
I have accidentally dropped the Stored procedure form my Database.
But now i want to recover it . Is there any process to recover dropped procedure??

Please help ..:eek:
Viewing all 13329 articles
Browse latest View live