Showing posts with label databas. Show all posts
Showing posts with label databas. Show all posts

Thursday, March 29, 2012

End Date and Beginning date in an ADP

Can anyone pleae help me, I inheited this databas which is an MDB and I have to convert it to an ADP (Sql server is the engine) and I need for my users to be able to enter a end date and a beginning date when they first open a report so they can see from the end of the month to the beginning in one report. This is Accesses code as an MDB

Code Snippet

[code]SELECT [Main Table].[IR Number], [Main Table].Date, [Main Table].Inspector, [Main Table].Area, [Main Table].Violation, [Main Table].[Violation Type], [Main Table].Loss, [Main Table].[Loss Type], [Main Table].Employee, [Main Table].Action, [Main Table].[Action Type], [Main Table].Notes
FROM [Main Table]
WHERE ((([Main Table].Date) Between [Enter the Start Date] And [Enter the End Date]))
ORDER BY [Main Table].[IR Number]

SELECT [Main Table].[IR Number], [Main Table].[Date], [Main Table].Inspector, [Main Table].Area, [Main Table].Violation, [Main Table].[Violation Type], [Main Table].Loss, [Main Table].[Loss Type], [Main Table].Employee, [Main Table].[Action], [Main Table].[Action Type], [Main Table].Notes
FROM [Main Table]
WHERE ((([Main Table].[Date] Between [Enter the Start Date] And [Enter the End Date]))
ORDER BY [IR Number]
GO

And here is SQL Servers code the only problem is that when I run this in the Query analyzer it gives me an error message that says, can anyone help me please?

"Server: Msg 207, Level 16, State 3, Line 1
Invalid column name 'Enter the Start Date'.
Server: Msg 207, Level 16, State 1, Line 1
Invalid column name 'Enter the End Date'."

Change the [Enter the start date] placeholders to parameters (@.StartDate @.EndDate)|||

Oh thank you so much is this what you mean?

Code Snippet

SELECT [IR Number], Date, Inspector, Area, Violation, [Violation Type], Loss, [Loss Type], Employee, Action, Notes, [Action Type]
FROM dbo.[Main Table]
WHERE (Date = @.StartDate) AND (Date = @.EndDate)

|||

You can still use the BETWEEN clause

Code Snippet

SELECT [IR Number], Date, Inspector, Area, Violation, [Violation Type], Loss, [Loss Type], Employee, Action, Notes, [Action Type]
FROM dbo.[Main Table]
WHERE Date IS BETWEEN @.StartDate AND @.EndDate

|||

Whoops, the 'IS' should not be in there

Code Snippet

SELECT [IR Number], Date, Inspector, Area, Violation, [Violation Type], Loss, [Loss Type], Employee, Action, Notes, [Action Type]
FROM dbo.[Main Table]
WHERE Date BETWEEN @.StartDate AND @.EndDate

|||

BRUCE YOU ARE THE BEST THANK YOU SO MUCH YOU DONT KNOW HOW LONG I HAVE BEEN WRESTLING WITH THIS

I inherited this database and I have queries that have to be converted from an MDB to an ADP and its not easy.

thank you so much

sql

Sunday, February 26, 2012

Enabling "Auto create statistics" / "Auto update statistics" at the tempdb databas

Should I enable the "Auto create statistics" and "Auto update statistics" parameters at the tempdb database? I've heard that it's necessary to increase tempdb performance. Could you confirm if it's true?
Thanks in advance.
VagnerStatistics is very important for performance. SQL Server uses this info when
it decides whther to use an index or not. You should have the auto
parameters set to on in all databases. Well, if you are not using tempdb a
lot, then it is not so important for tempdb, but I would set them on anyway.
--
Dejan Sarka, SQL Server MVP
Please reply only to the newsgroups.
"Vagner Cuccino" <anonymous@.discussions.microsoft.com> wrote in message
news:A324064F-3E90-4E6D-B851-3AE1B3F7825A@.microsoft.com...
> Should I enable the "Auto create statistics" and "Auto update statistics"
parameters at the tempdb database? I've heard that it's necessary to
increase tempdb performance. Could you confirm if it's true?
> Thanks in advance.
>
> Vagner
>|||"Dejan Sarka" <dejan_please_reply_to_newsgroups.sarka@.avtenta.si> wrote in
message news:OJjT2l%23vDHA.2304@.TK2MSFTNGP12.phx.gbl...
> Statistics is very important for performance. SQL Server uses this info
when
> it decides whther to use an index or not. You should have the auto
> parameters set to on in all databases. Well, if you are not using tempdb a
> lot, then it is not so important for tempdb, but I would set them on
anyway.
I would agree with you for new systems. For older systems previously based
and tweaked on earlier SQL Server versions like 6.5, especially real time
OLTP apps, I would suggest not unless you're in a position to open the code
up and re-tweak the app.
In general, auto create and update statistics will make older tweaked apps
run worse than before!
But bear in mind for both new and legacy applications, the serious
consideration that auto create and update stats don't do full scans, which
for anything more than fairly trivial amounts of data can be a significant
performance problem. The optimiser may choose a non-optimum execution plan
as it is basing its decision on a potentially non-representative sample of
data. You need to understand your data's distribution and cardinality to
make a call on this. In addition often there is some mutuality between
distinct column values in a table, for example if you have status flags or
values. In these cases it is often well worth manually creating composite
statistics to help the optimiser understand this.
Kind Regards, Howard