Showing posts with label returning. Show all posts
Showing posts with label returning. Show all posts

Friday, March 30, 2012

Question about returning a smalldatetime from a Function

I've been working this for a while. Kind of new to SQL Server
functions and not seeing what I am doing wrong. I have this function

CREATE FUNCTION dbo.test (@.Group varchar(50))
RETURNS smalldatetime AS
BEGIN
Declare @.retVal varchar(10)
(SELECT @.retVal= MIN([date]) FROM dbo.t_master_schedules WHERE
(event_id = 13) AND (group_ =@.Group))
return convert(smalldatetime, @.retVal, 1)
END

The error I get is
Server: Msg 296, Level 16, State 3, Procedure test, Line 6
The conversion of char data type to smalldatetime data type resulted in
an out-of-range smalldatetime value.

1) I tried declaring @.retVal as a smalldatetime and get the error "Must
declare the variable '@.retVal'.'
2) If I run that same query in query analyzer (manually inserting the
parm) it returns 11/14/2006. That's what I want.

If I change the function to this and run it
CREATE FUNCTION dbo.test (@.Group varchar(50))
RETURNS varchar(50) AS
BEGIN
Declare @.retVal varchar(50)
(SELECT @.retVal= MIN([date]) FROM dbo.t_master_schedules WHERE
(event_id = 13) AND (group_ =@.Group))
return convert(smalldatetime, @.retVal, 1)
END

It now works but the return value is Nov 14 2006 12:00AM

What am I doing wrong?

TIASQL Server (alderran666@.gmail.com) writes:
> I've been working this for a while. Kind of new to SQL Server
> functions and not seeing what I am doing wrong. I have this function
> CREATE FUNCTION dbo.test (@.Group varchar(50))
> RETURNS smalldatetime AS
> BEGIN
> Declare @.retVal varchar(10)
> (SELECT @.retVal= MIN([date]) FROM dbo.t_master_schedules WHERE
> (event_id = 13) AND (group_ =@.Group))
> return convert(smalldatetime, @.retVal, 1)
> END
> The error I get is
> Server: Msg 296, Level 16, State 3, Procedure test, Line 6
> The conversion of char data type to smalldatetime data type resulted in
> an out-of-range smalldatetime value.
> 1) I tried declaring @.retVal as a smalldatetime and get the error "Must
> declare the variable '@.retVal'.'
> 2) If I run that same query in query analyzer (manually inserting the
> parm) it returns 11/14/2006. That's what I want.

What data type is t_master_schedules.date? If it is varchar(10), and
it returns 11/14/2006, the query looks, eh, funny to me. First,
11/14/2006 does not look like a date to me. :-) But even if I assume
that 11 is supposed to be a month, it seems strange that you consider
2006-11-14 to be less than 2004-12-12. Shouldn't your query read
MIN(convert(smalldatetime, [date], 101) in such case?

Alternatively, the column is datetime or smalldatetime, but in such
there is no need to incolve varchar at all.

Anyway, when I try:

select convert(smalldatetime, '11/14/2006', 1)

I get:

Server: Msg 295, Level 16, State 3, Line 1
Syntax error converting character string to smalldatetime data type.

Whereas

select convert(smalldatetime, '11/14/2006', 101)

returns 2006-11-14.

> If I change the function to this and run it
> CREATE FUNCTION dbo.test (@.Group varchar(50))
> RETURNS varchar(50) AS
> BEGIN
> Declare @.retVal varchar(50)
> (SELECT @.retVal= MIN([date]) FROM dbo.t_master_schedules WHERE
> (event_id = 13) AND (group_ =@.Group))
> return convert(smalldatetime, @.retVal, 1)
> END
> It now works but the return value is Nov 14 2006 12:00AM

Here you are first converting to smalldatetime, and then convert
back to varchar without any format specification, why you get this
default format.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||On 6 Jun 2006 01:50:03 -0700, SQL Server wrote:

(snip)
>1) I tried declaring @.retVal as a smalldatetime and get the error "Must
>declare the variable '@.retVal'.'

Hi SQL Server,

And yet, that is exactly what you should do. Never convert unless you
have to.

The error message you got is not a result of declaring @.retVal as a
smalldatetime, but a result of "something" that was off in the code when
you tried that. Unfortunately, you didn't post that version of the code,
so I can't tell you what went wrong. Maybe, if you still have tat
version archived, you could post it here?

Meanwhile, try if this works:

CREATE FUNCTION dbo.test (@.Group varchar(50))
RETURNS smalldatetime
AS
BEGIN
DECLARE @.retVal smalldatetime
SELECT @.retVal = MIN([date])
FROM dbo.t_master_schedules
WHERE event_id = 13
AND group_ = @.Group
RETURN @.retVal
END

--
Hugo Kornelis, SQL Server MVP|||Hugo Kornelis wrote:
> The error message you got is not a result of declaring @.retVal as a
> smalldatetime, but a result of "something" that was off in the code when
> you tried that. Unfortunately, you didn't post that version of the code,
> so I can't tell you what went wrong. Maybe, if you still have tat
> version archived, you could post it here?
> --
> Hugo Kornelis, SQL Server MVP

This is okay
CREATE FUNCTION dbo.test (@.Group varchar(50))
RETURNS varchar(50) AS
BEGIN
Declare @.retVal varchar(50)
(SELECT @.retVal= MIN([date]) FROM dbo.t_master_schedules WHERE
(event_id = 13) AND (group_ =@.Group))
return convert(smalldatetime, @.retVal, 1)
END

This is okay too (change Returns from varchar(50) to datetime)
CREATE FUNCTION dbo.test (@.Group varchar(50))
RETURNS datetime AS
BEGIN
Declare @.retVal varchar(50)
(SELECT @.retVal= MIN([date]) FROM dbo.t_master_schedules WHERE
(event_id = 13) AND (group_ =@.Group))
return convert(smalldatetime, @.retVal, 1)
END

But change it to this
This is okay too (change Returns from varchar(50) to datetime)
CREATE FUNCTION dbo.test (@.Group varchar(50))
RETURNS datetime AS
BEGIN
Declare @.retVal datetime
(SELECT @.retVal= MIN([date]) FROM dbo.t_master_schedules WHERE
(event_id = 13) AND (group_ =@.Group))
return convert(smalldatetime, @.retVal, 1)
END

Here is a link to a screen capture of the error.
http://i12.photobucket.com/albums/a...erran/error.jpg

the column [date] in the table t_master_schedules is a datetime.

I actually do want @.retVal to be a varchar because the end result
should be a string that shows the first date for a particular group and
the last date in a particular group. So I would be running a select
with a Max([date]) and returning a string

11/14/2006 and 02/03/2007

The problem is that I am not able to get the date formated into the
mm/dd/yyyy format that I want.|||SQL Server (alderran666@.gmail.com) writes:
> CREATE FUNCTION dbo.test (@.Group varchar(50))
> RETURNS datetime AS
> BEGIN
> Declare @.retVal datetime
> (SELECT @.retVal= MIN([date]) FROM dbo.t_master_schedules WHERE
> (event_id = 13) AND (group_ =@.Group))
> return convert(smalldatetime, @.retVal, 1)
> END
>...
> the column [date] in the table t_master_schedules is a datetime.
> I actually do want @.retVal to be a varchar because the end result
> should be a string that shows the first date for a particular group and
> the last date in a particular group. So I would be running a select
> with a Max([date]) and returning a string
> 11/14/2006 and 02/03/2007
> The problem is that I am not able to get the date formated into the
> mm/dd/yyyy format that I want.

If you want a string back, why do you then insist on converting to
smalldatetime? Should you not convert to char(10) and return char(10)?

Anyway, I would suggest that you scrap the function entirely. I don't
know where you use this function, but data access from scalar functions
should be avoided, as it can affect performance considerably if
you stick into a query. This is because the query more or less get
converted to a cursor behind the scenes. So it is much better to
integrate the logic in the main query.

As for the date formatting, you should avoid formatting dates in
SQL Server, but format them client side, so the the client's
regional settings are respected.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Erland Sommarskog wrote:

> If you want a string back, why do you then insist on converting to
> smalldatetime? Should you not convert to char(10) and return char(10)?
..
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx

All I want to know is how to return
08/29/2006

from
'2006-08-29 00:00:00.000'

Looking at the SQL Server Books Online help resource it appears to me
that the convert function should be able to do this. But this doesn't
work. Why not and how can I format that date the way I want in the
output. In VB I'd just use the format function. Is there something
similar in T-SQL?
print convert(datetime, '2006-08-29 00:00:00.000', 101)|||SQL Server (alderran666@.gmail.com) writes:
> All I want to know is how to return
> 08/29/2006
> from
> '2006-08-29 00:00:00.000'
> Looking at the SQL Server Books Online help resource it appears to me
> that the convert function should be able to do this. But this doesn't
> work. Why not and how can I format that date the way I want in the
> output. In VB I'd just use the format function. Is there something
> similar in T-SQL?
> print convert(datetime, '2006-08-29 00:00:00.000', 101)

That converts a string value to datetime. You want to convert a datetime
value to a string.

A datetime value is a internally a numeric value and does not have any
format. The format code in the above example tells SQL Server how to
interpret the string.

But as I said, while you can format date values to string in your SQL code,
you should avoid doing so. This should be done client-side, so that the
client's regional settings can be respected. I can tell you that if you
give me an app that spits out strings like 08/29/2006, you will have a bug
report back in ten seconds, because that is not a date as far as I'm
concerned.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspxsql

Monday, March 12, 2012

Question about Delete and Latency

I am in the process of returning a machine running SQL Server back to
our provider. However, I don't want them to retrieve any of our data
stored in the DB. So I have the following 2 options
a) delete the rows from tables
b) remove the MDB file
Which of the options is better?
If I just delete the rows, will the SQL Server delete them from the
MDB file immediately?
If I remove the MDB file, can anyone put it back?
For instance, the Exchange Server use SQL Server and deleting a
mailbox will retain the data for about 14 days. Is there a similar
provision in SQL Server that retains the data. I don't want our
provider to retrieve any of the data.
Many thanks for reading and looking forward to repliesOn 18.05.2007 15:40, soup_or_power@.yahoo.com wrote:
> I am in the process of returning a machine running SQL Server back to
> our provider. However, I don't want them to retrieve any of our data
> stored in the DB. So I have the following 2 options
> a) delete the rows from tables
> b) remove the MDB file
> Which of the options is better?
> If I just delete the rows, will the SQL Server delete them from the
> MDB file immediately?
> If I remove the MDB file, can anyone put it back?
> For instance, the Exchange Server use SQL Server and deleting a
> mailbox will retain the data for about 14 days. Is there a similar
> provision in SQL Server that retains the data. I don't want our
> provider to retrieve any of the data.
> Many thanks for reading and looking forward to replies
Depends in what state you have to give the machine back. If you don't
need to care for OS then the most thorough and simple is probably to
boot the machine using Knoppix or a similar CD/DVD distro and use dd
if=/dev/zero of=/dev/hda (for all disks) to erase all your hard disks.
Other than that there are special tools for safely erasing data, i.e.
you could overwrite your mdf and ldf files with zeros after you
deactivated your DB and before you drop the DB.
Kind regards
robert|||On May 18, 9:04 am, Robert Klemme <shortcut...@.googlemail.com> wrote:
> On 18.05.2007 15:40, soup_or_po...@.yahoo.com wrote:
>
>
> > I am in the process of returning a machine running SQL Server back to
> > our provider. However, I don't want them to retrieve any of our data
> > stored in the DB. So I have the following 2 options
> > a) delete the rows from tables
> > b) remove the MDB file
> > Which of the options is better?
> > If I just delete the rows, will the SQL Server delete them from the
> > MDB file immediately?
> > If I remove the MDB file, can anyone put it back?
> > For instance, the Exchange Server use SQL Server and deleting a
> > mailbox will retain the data for about 14 days. Is there a similar
> > provision in SQL Server that retains the data. I don't want our
> > provider to retrieve any of the data.
> > Many thanks for reading and looking forward to replies
> Depends in what state you have to give the machine back. If you don't
> need to care for OS then the most thorough and simple is probably to
> boot the machine using Knoppix or a similar CD/DVD distro and use dd
> if=/dev/zero of=/dev/hda (for all disks) to erase all your hard disks.
> Other than that there are special tools for safely erasing data, i.e.
> you could overwrite your mdf and ldf files with zeros after you
> deactivated your DB and before you drop the DB.
> Kind regards
> robert- Hide quoted text -
> - Show quoted text -
Hi Robert
Many thanks for your reply. Could you name the tools for safely
erasing data? Also how can I "deactive" the DB?
Regards|||On 18.05.2007 16:22, soup_or_power@.yahoo.com wrote:
> On May 18, 9:04 am, Robert Klemme <shortcut...@.googlemail.com> wrote:
>> On 18.05.2007 15:40, soup_or_po...@.yahoo.com wrote:
>>
>>
>> I am in the process of returning a machine running SQL Server back to
>> our provider. However, I don't want them to retrieve any of our data
>> stored in the DB. So I have the following 2 options
>> a) delete the rows from tables
>> b) remove the MDB file
>> Which of the options is better?
>> If I just delete the rows, will the SQL Server delete them from the
>> MDB file immediately?
>> If I remove the MDB file, can anyone put it back?
>> For instance, the Exchange Server use SQL Server and deleting a
>> mailbox will retain the data for about 14 days. Is there a similar
>> provision in SQL Server that retains the data. I don't want our
>> provider to retrieve any of the data.
>> Many thanks for reading and looking forward to replies
>> Depends in what state you have to give the machine back. If you don't
>> need to care for OS then the most thorough and simple is probably to
>> boot the machine using Knoppix or a similar CD/DVD distro and use dd
>> if=/dev/zero of=/dev/hda (for all disks) to erase all your hard disks.
>> Other than that there are special tools for safely erasing data, i.e.
>> you could overwrite your mdf and ldf files with zeros after you
>> deactivated your DB and before you drop the DB.
>> Kind regards
>> robert- Hide quoted text -
>> - Show quoted text -
> Hi Robert
> Many thanks for your reply. Could you name the tools for safely
> erasing data?
I don't have names. You will have to look for yourself. Sorry.
> Also how can I "deactive" the DB?
EM -> select DB -> all tasks -> detach database
robert|||"Robert Klemme" <shortcutter@.googlemail.com> wrote in message
news:5b5s08F2g0fupU1@.mid.individual.net...
> On 18.05.2007 16:22, soup_or_power@.yahoo.com wrote:
>> On May 18, 9:04 am, Robert Klemme <shortcut...@.googlemail.com> wrote:
>> On 18.05.2007 15:40, soup_or_po...@.yahoo.com wrote:
>>
>>
>> I am in the process of returning a machine running SQL Server back to
>> our provider. However, I don't want them to retrieve any of our data
>> stored in the DB. So I have the following 2 options
>> a) delete the rows from tables
>> b) remove the MDB file
>> Which of the options is better?
>> If I just delete the rows, will the SQL Server delete them from the
>> MDB file immediately?
>> If I remove the MDB file, can anyone put it back?
>> For instance, the Exchange Server use SQL Server and deleting a
>> mailbox will retain the data for about 14 days. Is there a similar
>> provision in SQL Server that retains the data. I don't want our
>> provider to retrieve any of the data.
>> Many thanks for reading and looking forward to replies
>> Depends in what state you have to give the machine back. If you don't
>> need to care for OS then the most thorough and simple is probably to
>> boot the machine using Knoppix or a similar CD/DVD distro and use dd
>> if=/dev/zero of=/dev/hda (for all disks) to erase all your hard disks.
>> Other than that there are special tools for safely erasing data, i.e.
>> you could overwrite your mdf and ldf files with zeros after you
>> deactivated your DB and before you drop the DB.
>> Kind regards
>> robert- Hide quoted text -
>> - Show quoted text -
>> Hi Robert
>> Many thanks for your reply. Could you name the tools for safely
>> erasing data?
> I don't have names. You will have to look for yourself. Sorry.
>> Also how can I "deactive" the DB?
> EM -> select DB -> all tasks -> detach database
>
Note that will leave the MDF and LDF files still on the server.
he's better of DELETING the database (assuming he can't format the drive or
something like that.)
> robert
--
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html|||On 19.05.2007 16:08, Greg D. Moore (Strider) wrote:
> "Robert Klemme" <shortcutter@.googlemail.com> wrote in message
> news:5b5s08F2g0fupU1@.mid.individual.net...
>> On 18.05.2007 16:22, soup_or_power@.yahoo.com wrote:
>> On May 18, 9:04 am, Robert Klemme <shortcut...@.googlemail.com> wrote:
>> On 18.05.2007 15:40, soup_or_po...@.yahoo.com wrote:
>>
>>
>> I am in the process of returning a machine running SQL Server back to
>> our provider. However, I don't want them to retrieve any of our data
>> stored in the DB. So I have the following 2 options
>> a) delete the rows from tables
>> b) remove the MDB file
>> Which of the options is better?
>> If I just delete the rows, will the SQL Server delete them from the
>> MDB file immediately?
>> If I remove the MDB file, can anyone put it back?
>> For instance, the Exchange Server use SQL Server and deleting a
>> mailbox will retain the data for about 14 days. Is there a similar
>> provision in SQL Server that retains the data. I don't want our
>> provider to retrieve any of the data.
>> Many thanks for reading and looking forward to replies
>> Depends in what state you have to give the machine back. If you don't
>> need to care for OS then the most thorough and simple is probably to
>> boot the machine using Knoppix or a similar CD/DVD distro and use dd
>> if=/dev/zero of=/dev/hda (for all disks) to erase all your hard disks.
>> Other than that there are special tools for safely erasing data, i.e.
>> you could overwrite your mdf and ldf files with zeros after you
>> deactivated your DB and before you drop the DB.
>> Kind regards
>> robert- Hide quoted text -
>> - Show quoted text -
>> Hi Robert
>> Many thanks for your reply. Could you name the tools for safely
>> erasing data?
>> I don't have names. You will have to look for yourself. Sorry.
>> Also how can I "deactive" the DB?
>> EM -> select DB -> all tasks -> detach database
> Note that will leave the MDF and LDF files still on the server.
> he's better of DELETING the database (assuming he can't format the drive or
> something like that.)
Yes, I know. That was just the explanation of *one* of the steps (see
my earlier posting).
robert

Question about Delete and Latency

I am in the process of returning a machine running SQL Server back to
our provider. However, I don't want them to retrieve any of our data
stored in the DB. So I have the following 2 options
a) delete the rows from tables
b) remove the MDB file
Which of the options is better?
If I just delete the rows, will the SQL Server delete them from the
MDB file immediately?
If I remove the MDB file, can anyone put it back?
For instance, the Exchange Server use SQL Server and deleting a
mailbox will retain the data for about 14 days. Is there a similar
provision in SQL Server that retains the data. I don't want our
provider to retrieve any of the data.
Many thanks for reading and looking forward to repliesOn 18.05.2007 15:40, soup_or_power@.yahoo.com wrote:
> I am in the process of returning a machine running SQL Server back to
> our provider. However, I don't want them to retrieve any of our data
> stored in the DB. So I have the following 2 options
> a) delete the rows from tables
> b) remove the MDB file
> Which of the options is better?
> If I just delete the rows, will the SQL Server delete them from the
> MDB file immediately?
> If I remove the MDB file, can anyone put it back?
> For instance, the Exchange Server use SQL Server and deleting a
> mailbox will retain the data for about 14 days. Is there a similar
> provision in SQL Server that retains the data. I don't want our
> provider to retrieve any of the data.
> Many thanks for reading and looking forward to replies
Depends in what state you have to give the machine back. If you don't
need to care for OS then the most thorough and simple is probably to
boot the machine using Knoppix or a similar CD/DVD distro and use dd
if=/dev/zero of=/dev/hda (for all disks) to erase all your hard disks.
Other than that there are special tools for safely erasing data, i.e.
you could overwrite your mdf and ldf files with zeros after you
deactivated your DB and before you drop the DB.
Kind regards
robert|||On May 18, 9:04 am, Robert Klemme <shortcut...@.googlemail.com> wrote:
> On 18.05.2007 15:40, soup_or_po...@.yahoo.com wrote:
>
>
>
>
>
>
>
>
> Depends in what state you have to give the machine back. If you don't
> need to care for OS then the most thorough and simple is probably to
> boot the machine using Knoppix or a similar CD/DVD distro and use dd
> if=/dev/zero of=/dev/hda (for all disks) to erase all your hard disks.
> Other than that there are special tools for safely erasing data, i.e.
> you could overwrite your mdf and ldf files with zeros after you
> deactivated your DB and before you drop the DB.
> Kind regards
> robert- Hide quoted text -
> - Show quoted text -
Hi Robert
Many thanks for your reply. Could you name the tools for safely
erasing data? Also how can I "deactive" the DB?
Regards|||On 18.05.2007 16:22, soup_or_power@.yahoo.com wrote:
> On May 18, 9:04 am, Robert Klemme <shortcut...@.googlemail.com> wrote:
> Hi Robert
> Many thanks for your reply. Could you name the tools for safely
> erasing data?
I don't have names. You will have to look for yourself. Sorry.

> Also how can I "deactive" the DB?
EM -> select DB -> all tasks -> detach database
robert|||"Robert Klemme" <shortcutter@.googlemail.com> wrote in message
news:5b5s08F2g0fupU1@.mid.individual.net...
> On 18.05.2007 16:22, soup_or_power@.yahoo.com wrote:
> I don't have names. You will have to look for yourself. Sorry.
>
> EM -> select DB -> all tasks -> detach database
>
Note that will leave the MDF and LDF files still on the server.
he's better of DELETING the database (assuming he can't format the drive or
something like that.)

> robert
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html|||On 19.05.2007 16:08, Greg D. Moore (Strider) wrote:
> "Robert Klemme" <shortcutter@.googlemail.com> wrote in message
> news:5b5s08F2g0fupU1@.mid.individual.net...
> Note that will leave the MDF and LDF files still on the server.
> he's better of DELETING the database (assuming he can't format the drive o
r
> something like that.)
Yes, I know. That was just the explanation of *one* of the steps (see
my earlier posting).
robert

Question about Delete and Latency

I am in the process of returning a machine running SQL Server back to
our provider. However, I don't want them to retrieve any of our data
stored in the DB. So I have the following 2 options
a) delete the rows from tables
b) remove the MDB file
Which of the options is better?
If I just delete the rows, will the SQL Server delete them from the
MDB file immediately?
If I remove the MDB file, can anyone put it back?
For instance, the Exchange Server use SQL Server and deleting a
mailbox will retain the data for about 14 days. Is there a similar
provision in SQL Server that retains the data. I don't want our
provider to retrieve any of the data.
Many thanks for reading and looking forward to replies
On 18.05.2007 15:40, soup_or_power@.yahoo.com wrote:
> I am in the process of returning a machine running SQL Server back to
> our provider. However, I don't want them to retrieve any of our data
> stored in the DB. So I have the following 2 options
> a) delete the rows from tables
> b) remove the MDB file
> Which of the options is better?
> If I just delete the rows, will the SQL Server delete them from the
> MDB file immediately?
> If I remove the MDB file, can anyone put it back?
> For instance, the Exchange Server use SQL Server and deleting a
> mailbox will retain the data for about 14 days. Is there a similar
> provision in SQL Server that retains the data. I don't want our
> provider to retrieve any of the data.
> Many thanks for reading and looking forward to replies
Depends in what state you have to give the machine back. If you don't
need to care for OS then the most thorough and simple is probably to
boot the machine using Knoppix or a similar CD/DVD distro and use dd
if=/dev/zero of=/dev/hda (for all disks) to erase all your hard disks.
Other than that there are special tools for safely erasing data, i.e.
you could overwrite your mdf and ldf files with zeros after you
deactivated your DB and before you drop the DB.
Kind regards
robert

Saturday, February 25, 2012

Question

Hello all,

I have the following dataset returning top 20 records for a day, changing daily

STATE

USER ID

SALES REP

SALES

QLD

6758

Liam Maddrell

12

QLD

6677

Lisa-Maree Findlay

11

QLD

6133

Benjamin Matthews

11

QLD

6299

Simon Tabet

11

QLD

6112

Deborah Williams

10

VIC

3428

Peter Mahar

10

QLD

5134

Russell Den Engelse

9

WA

5279

Julie Isitt

8

NSW

5677

Pranav Agarwal

8

NSW

6093

Rosa Delizia

8

QLD

6684

Ron Prasad

8

WA

7578

Francis Williams

8

Qld

7511

LigIA Borodi

7

QLD

6804

Rupert Ryan

7

QLD

6856

Maxwell MacLean

7

QLD

6904

Trent Sticklen

7

QLD

7236

Drazen Knezevic

7

QLD

7406

Amy Donaldson

7

NSW

5601

Michael Phillips

7

QLD

5940

Harnake guraya

7

I would like too now sum up the figures to get in a separate layout (total sales off the above reps by state)

Queensland 168

South
Australia

0

Western
Australia

176

Victoria

40

New South
Wales

15

Northern
Territory

0

I have tried a different dataset but it doesnt allow me to do this due to the use off top 20 in the query which needs to be grouped by state this time and to do that it doesnt know the topn 20 records.

...I am trying to figure out a way by using textboxes , tables etc, I have managed to get the results coming out in a table using grouping by state and sum of the values but because there are no records for Sth Australia and Northern Territory these are not on the list...and i need these also in the list...can someone please help

thanks

Can someone help me with some code to achieve the above ?

thanks

|||

I don't have code for you, but in your query, you need to specify something like isnull(NorthernTerritory,0)

This will return a 0 (zero) instead of a null and then the data should show up on your report.

Since you are doing a topN, why don't you use a group by in your report?

|||

I cant do a group by as a rep can have more than 1 sale and to get the top 20 it is adding up all his sales already

ie

wa John 20 item 15

wa john 15 item 20

To get the top 20 i add the sum off the values together to get the rep...

ie

wa john 35

if i group by state john will be treated as 2 records and the numbers wont be for the top 20 sales rep...but just the top 20 sales

thanks for trying Smile can anyone else help?

|||

Hi,

I found it hard to understand why cant you use grouping and othere data sets,

I have a solution but It is an ugly one.... (-:

first change your Data set to return a sum colums
by addind a join in your SQL to a query tha group by the State and sum the sales

after you do that you will have all the results you need in the same data set

now you jost have to add the colums to the feilds and use the First function in the expresions to

get the currect total sales for the state

STATE

USER ID

SALES REP

SALES sum

QLD

6758

Liam Maddrell

12 168

QLD

6677

Lisa-Maree Findlay

11 168

QLD

6133

Benjamin Matthews

11 168

QLD

6299

Simon Tabet

11

QLD

6112

Deborah Williams

10

VIC

3428

Peter Mahar

10

QLD

5134

Russell Den Engelse

9

WA

5279

Julie Isitt

8

NSW

5677

Pranav Agarwal

8

NSW

6093

Rosa Delizia

8

QLD

6684

Ron Prasad

8

WA

7578

Francis Williams

8

Qld

7511

LigIA Borodi

7

QLD

6804

Rupert Ryan

7

QLD

6856

Maxwell MacLean

7

QLD

6904

Trent Sticklen

7

QLD

7236

Drazen Knezevic

7

QLD

7406

Amy Donaldson

7

NSW

5601

Michael Phillips

7

QLD

5940

Harnake guraya

7