|
If you mean that months are displayed as columns, is it always a quarter or can user select for example 6 months? If the amount of months is dynamic, I think you must rotate them horizontally when displaying the data (asp.net in this case).
|
|
|
|
|
Hello,
I have a problem with the exercise I am currently working with.
The database has 4 table:
PHASE
id Name
1 Morning
2 Afternoon
3 Evening
...
STAFF
id Name
1 John
2 Mary
...
SESSION
id FirstdayOfWeek DayOfWeek Phase
1 5 Jan 2009 Sat 1
2 5 Jan 2009 Sun 3
...
DUTY
Staff Session
1 1
2 2
...
The program is to make report about the number of times that a staff do his/her duty in each phase in a specific month chosen by the user. It may look like this:
REPORT
Staff: John (chosen by user)
Month: Jan 2009 (chosen by user)
Date Morning Afternoon Evening ...
10 Jan 2009 yes no no
11 Jan 2009 no no no
.....
Total 3 6 0
Can you tell me how to make the SQL that give a table like the one above (with Date, Morning, Afternoon, Evening columns) to send it to the Crystal Report? Is this possible in just one SQL query? Thank you in advance.
|
|
|
|
|
I think you should have a look at DATEPART[^] and CASE[^] combined with joins.
|
|
|
|
|
Hi Mika,
thank you for your answer. Of course I have already tried datepart, case and join and it works well with the current example. My problem is the '...' in my writing above. That means the database can be change and unfortunately, my report depends on the Phase table. The number of column, the name of each column, all are dynamic. Can you tell me how to do this in just one SQL query? If it is impossible, is there any solution like adding some more tables or writing some more code?
|
|
|
|
|
Have you tested PIVOT. If you already have and still not getting the desired result, I think you should use dynamic SQL either by creating a procedure or from the client. If I understood you correctly, first fetch all the phases, after that construct a SQL query with amount of columns based on phase table. After that, use that statement to return the data.
|
|
|
|
|
I have put TRY CATCH in my Stored Procedure but it fails when any invalid table or invalid column error occures and it prompts error msg directly in place of putting it in TRY CATCH Error Log.
Is there any way to catch such type of errors through TRY CATCH.
Please Let me know.....
Thanks in advance
With Thanks & Regards
Amit Sk Sharma
|
|
|
|
|
Unless you are using dynamic sql you will get compile time error and that's not possible to handle with try...catch. So by using dynamic sql you can catch the error at execution time.
|
|
|
|
|
i used "create database for attach" to attach an old database to the sqlserver but the database files (like *.mdf and *.ldf and etc) have to be in the previous folder (the old folder that i used to use it as my database folder)
how can i restore data without having to copy it in the old folder ?
i do not want to use backup and restore because they need to have a device and i do not know what can i do if the device deleted . do you know ?
|
|
|
|
|
reza assar wrote: to attach an old database to the sqlserver but the database files (like *.mdf and *.ldf and etc) have to be in the previous folder
They don't have to be in the original folder, but if you're moving the log file to a new location, I think you must use ATTACH_REBUILD_LOG .
From CREATE DATABASE[^]: "FOR ATTACH: Specifies that the database is created by attaching an existing set of operating system files. There must be a <filespec> entry that specifies the primary file. The only other <filespec> entries required are those for any files that have a different path from when the database was first created or last attached"
See also: How to: Move a Database Using Detach and Attach[^]
|
|
|
|
|
reza assar wrote: i do not want to use backup and restore because they need to have a device and i do not know what can i do if the device deleted . do you know ?
You don't need a device, you can backup and restore to a file. The UI is a bit confusing, as it's mainly intended for backup to an external device, but you simply change some radio buttons to get to the right place.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hi
i have a problem with a new component installed on my vs 2005
the component`s name is "devExpress"
i used it in one of my applications . but my application will crash when i start it on the other computers (the computers that does not have these components) how can i solve this problem ?
thanks in advance !
|
|
|
|
|
|
Hi
I need Script to backup selected database of SQL Server 2000. Script should have facility to add the database in the backup schedule in future.
Can any one help me out.
Regards
Vivek
|
|
|
|
|
To get you to the start, open Management Studio, create the backup and script it to a SQL Script.
You can also schedule the backup and then script the job which is created under the Sql Server Agent.
|
|
|
|
|
What is the datatype of the audio or video data to store in sql2005 database.
|
|
|
|
|
|
i m new candidate to learning vb.net. my que is database connectivity in vb .net using Access..?
|
|
|
|
|
Try connectionstrings.com
Search through the articles here and on Google, there are plenty of excellent samples around. Learn to do some research before dropping such an open question into a forum. When you run into a specific problem we will be more than happy to help.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
use oledb.
But i suspect that you did not buy a Book
try and get a Book that will guide you step by Step.
http://www.apress.com/book/view/143021614x[^]
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswam@its.co.za
|
|
|
|
|
i've a table contains name,cardid and the cardstatus.there are many cards for i customer,i want to check for each customer if he has a card with the cardstatus="bad" and if so need to return false.
can any one suggest me how to do this .
|
|
|
|
|
SELECT CASE ISNULL(COUNT(*),0) WHEN 0 THEN True ELSE False END FROM table WHERE Name=@name AND CardStatus='bad'
Or something like that?
|
|
|
|
|
Hello,
I have a Question related to SQL Server Connectivity .
I have my database on another PC and using the software created using VB.net 2005 on another PC, i.e. like Client Server.
I want to know whether connecting the SQL Server database directly from my application would give faster results or by creating a DSN connection on client machine and accessing the Data using Datasource would be faster.
Please anyone having idea about this.
Thank in Advance.
|
|
|
|
|
I think using .Net Framework's SqlConnection gives the best result as it is designed natively against Sql Server. It also provides more functionality than ODBC-based connections.
|
|
|
|
|
I'm using vb2005 connection to DB Ms Access.
If I have Columns in that DB it's typed Date/Time.Is it possible to rearrangement the Data(rows) in DB according the History.
it's mean if I have these Data
this is DB in Ms Access
A---B----C----H<br />
ZZ---FF---GG---2/12/2008<br />
QQ---UU---TT---1/12/2008<br />
RR---OO---PP---3/12/2008
To make this data like this
A---B----C----H<br />
QQ---UU---TT---1/12/2008<br />
ZZ---FF---GG---2/12/2008<br />
RR---OO---PP---3/12/2008
modified on Wednesday, December 31, 2008 6:59 AM
|
|
|
|
|
do a ORDER BY on the 'H' (date) column.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|