Showing posts with label value. Show all posts
Showing posts with label value. Show all posts

Monday, March 26, 2012

Foreach Loop - Value back to 0

Hi,

Let's say you have a Data Flow Task that connects to a Foreach Loop, looping through the data.

Somewhere inside the Foreach Loop, you set an int variable MyInt to a value.

My question:

Is it possable when each iteration begins to set MyInt to 0?

Thanks in advance.

Is the foreach loop evaluating the same variable, or are you using the variable for something else?

Script tasks can assign values to variables.|||Can you set a value of a variable inside an expression?|||

MrHat wrote:

Can you set a value of a variable inside an expression?

No.|||But you could set it by running "SELECT ? = 0" inside an Execute SQL task at the start of your loop, and assigning that output parameter to your variable.

ForEach DataFlow Task

I want to be able to loop through a view and execute a dataflow task for each record. I would like to pass the value of a column to the dataflow task to be used as a parameter in a data reader.

How can I do this?

Danny Crowell wrote:

I want to be able to loop through a view and execute a dataflow task for each record. I would like to pass the value of a column to the dataflow task to be used as a parameter in a data reader.

How can I do this?

I don't understand...could you clarify it?

What do you mean with 'loop through a view'? or you mean the rows in a view?...Then how is that you want t pass a column as parameter?

|||

Danny Crowell wrote:

I want to be able to loop through a view and execute a dataflow task for each record. I would like to pass the value of a column to the dataflow task to be used as a parameter in a data reader.

How can I do this?

Load an Execute SQL task with the SQL for the view into an OBJECT-typed variable. Then, using a foreach loop against that ADO recordset, you can grab a column and stick its contents into another variable that you can use in the foreach loop-contained data flow.|||Here is an artilce from Brian Knight that helped me with this.
http://www.whiteknighttechnology.com/cs/blogs/brian_knight/archive/2006/03/03/126.aspx

forcing string value in table

Hi just wondering if there is a way to have a script that creates a table
write in a desired string for the first table entry?
I have an application that I am allowing the de-activation of a record. I
could not allow a delete since this could result in an orphan record. So
basically the table at startup (when first created) would look like
****************************
* pri key * varchar (20)*
****************************
* 1 * Not Active *
****************************
the application would add records to the table as it is used.
Paul G
Software engineer.
Paul, I'm not clear on what you need.
if not exists (select 'x' from information_schema.tables where table_name =
'mytable' and table_type = 'base table')
create table mytable (id int identity(1,1), status varchar(20))
if not exists (select 'x' from mytable)
insert into mytable (status) select 'Not Active'
Is this close?
Also, do you not have foreign key constraints defined in your data model?
"Paul" <Paul@.discussions.microsoft.com> wrote in message
news:4F1222EF-14CF-49C4-B5E7-6F40E3CEE138@.microsoft.com...
> Hi just wondering if there is a way to have a script that creates a table
> write in a desired string for the first table entry?
> I have an application that I am allowing the de-activation of a record. I
> could not allow a delete since this could result in an orphan record. So
> basically the table at startup (when first created) would look like
> ****************************
> * pri key * varchar (20)*
> ****************************
> * 1 * Not Active *
> ****************************
> the application would add records to the table as it is used.
>
> --
> Paul G
> Software engineer.
|||Hi thanks for the response. Its primary key is a foriegn key in another
table, this is why I can not delete a record. I also have a few constraints,
below is from Query analyzer script object. Just would like to put in for
the first record the string "Not Active" so perhaps what you listed should
work.
CREATE TABLE [DML$POC_T] (
[POC_ID] [int] IDENTITY (1, 1) NOT NULL ,
[POC_Name_VC] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
CONSTRAINT [PK_DML$POC_T] PRIMARY KEY CLUSTERED
(
[POC_ID]
) ON [PRIMARY] ,
CONSTRAINT [IX_DML$POC_T] UNIQUE NONCLUSTERED
(
[POC_Name_VC]
) ON [PRIMARY]
) ON [PRIMARY]
GO
"Armando Prato" wrote:

> Paul, I'm not clear on what you need.
> if not exists (select 'x' from information_schema.tables where table_name =
> 'mytable' and table_type = 'base table')
> create table mytable (id int identity(1,1), status varchar(20))
> if not exists (select 'x' from mytable)
> insert into mytable (status) select 'Not Active'
> Is this close?
> Also, do you not have foreign key constraints defined in your data model?
> "Paul" <Paul@.discussions.microsoft.com> wrote in message
> news:4F1222EF-14CF-49C4-B5E7-6F40E3CEE138@.microsoft.com...
>
>

forcing string value in table

Hi just wondering if there is a way to have a script that creates a table
write in a desired string for the first table entry?
I have an application that I am allowing the de-activation of a record. I
could not allow a delete since this could result in an orphan record. So
basically the table at startup (when first created) would look like
****************************
* pri key * varchar (20)*
****************************
* 1 * Not Active *
****************************
the application would add records to the table as it is used.
Paul G
Software engineer.Paul, I'm not clear on what you need.
if not exists (select 'x' from information_schema.tables where table_name =
'mytable' and table_type = 'base table')
create table mytable (id int identity(1,1), status varchar(20))
if not exists (select 'x' from mytable)
insert into mytable (status) select 'Not Active'
Is this close?
Also, do you not have foreign key constraints defined in your data model?
"Paul" <Paul@.discussions.microsoft.com> wrote in message
news:4F1222EF-14CF-49C4-B5E7-6F40E3CEE138@.microsoft.com...
> Hi just wondering if there is a way to have a script that creates a table
> write in a desired string for the first table entry?
> I have an application that I am allowing the de-activation of a record. I
> could not allow a delete since this could result in an orphan record. So
> basically the table at startup (when first created) would look like
> ****************************
> * pri key * varchar (20)*
> ****************************
> * 1 * Not Active *
> ****************************
> the application would add records to the table as it is used.
>
> --
> Paul G
> Software engineer.|||Hi thanks for the response. Its primary key is a foriegn key in another
table, this is why I can not delete a record. I also have a few constraints
,
below is from Query analyzer script object. Just would like to put in for
the first record the string "Not Active" so perhaps what you listed should
work.
CREATE TABLE [DML$POC_T] (
[POC_ID] [int] IDENTITY (1, 1) NOT NULL ,
[POC_Name_VC] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NO
T NULL ,
CONSTRAINT [PK_DML$POC_T] PRIMARY KEY CLUSTERED
(
[POC_ID]
) ON [PRIMARY] ,
CONSTRAINT [IX_DML$POC_T] UNIQUE NONCLUSTERED
(
[POC_Name_VC]
) ON [PRIMARY]
) ON [PRIMARY]
GO
"Armando Prato" wrote:

> Paul, I'm not clear on what you need.
> if not exists (select 'x' from information_schema.tables where table_name
=
> 'mytable' and table_type = 'base table')
> create table mytable (id int identity(1,1), status varchar(20))
> if not exists (select 'x' from mytable)
> insert into mytable (status) select 'Not Active'
> Is this close?
> Also, do you not have foreign key constraints defined in your data model?
> "Paul" <Paul@.discussions.microsoft.com> wrote in message
> news:4F1222EF-14CF-49C4-B5E7-6F40E3CEE138@.microsoft.com...
>
>

forcing string value in table

Hi just wondering if there is a way to have a script that creates a table
write in a desired string for the first table entry?
I have an application that I am allowing the de-activation of a record. I
could not allow a delete since this could result in an orphan record. So
basically the table at startup (when first created) would look like
****************************
* pri key * varchar (20)*
****************************
* 1 * Not Active *
****************************
the application would add records to the table as it is used.
--
Paul G
Software engineer.Paul, I'm not clear on what you need.
if not exists (select 'x' from information_schema.tables where table_name ='mytable' and table_type = 'base table')
create table mytable (id int identity(1,1), status varchar(20))
if not exists (select 'x' from mytable)
insert into mytable (status) select 'Not Active'
Is this close?
Also, do you not have foreign key constraints defined in your data model?
"Paul" <Paul@.discussions.microsoft.com> wrote in message
news:4F1222EF-14CF-49C4-B5E7-6F40E3CEE138@.microsoft.com...
> Hi just wondering if there is a way to have a script that creates a table
> write in a desired string for the first table entry?
> I have an application that I am allowing the de-activation of a record. I
> could not allow a delete since this could result in an orphan record. So
> basically the table at startup (when first created) would look like
> ****************************
> * pri key * varchar (20)*
> ****************************
> * 1 * Not Active *
> ****************************
> the application would add records to the table as it is used.
>
> --
> Paul G
> Software engineer.|||Hi thanks for the response. Its primary key is a foriegn key in another
table, this is why I can not delete a record. I also have a few constraints,
below is from Query analyzer script object. Just would like to put in for
the first record the string "Not Active" so perhaps what you listed should
work.
CREATE TABLE [DML$POC_T] (
[POC_ID] [int] IDENTITY (1, 1) NOT NULL ,
[POC_Name_VC] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
CONSTRAINT [PK_DML$POC_T] PRIMARY KEY CLUSTERED
(
[POC_ID]
) ON [PRIMARY] ,
CONSTRAINT [IX_DML$POC_T] UNIQUE NONCLUSTERED
(
[POC_Name_VC]
) ON [PRIMARY]
) ON [PRIMARY]
GO
"Armando Prato" wrote:
> Paul, I'm not clear on what you need.
> if not exists (select 'x' from information_schema.tables where table_name => 'mytable' and table_type = 'base table')
> create table mytable (id int identity(1,1), status varchar(20))
> if not exists (select 'x' from mytable)
> insert into mytable (status) select 'Not Active'
> Is this close?
> Also, do you not have foreign key constraints defined in your data model?
> "Paul" <Paul@.discussions.microsoft.com> wrote in message
> news:4F1222EF-14CF-49C4-B5E7-6F40E3CEE138@.microsoft.com...
> > Hi just wondering if there is a way to have a script that creates a table
> > write in a desired string for the first table entry?
> > I have an application that I am allowing the de-activation of a record. I
> > could not allow a delete since this could result in an orphan record. So
> > basically the table at startup (when first created) would look like
> > ****************************
> > * pri key * varchar (20)*
> > ****************************
> > * 1 * Not Active *
> > ****************************
> > the application would add records to the table as it is used.
> >
> >
> > --
> > Paul G
> > Software engineer.
>
>

Friday, March 23, 2012

forcing an identity to be even\odd

Hi
I am not able to implement even odd series, the tables
are generating autonumbers with 'last value + 2' for the
next value (inspite of saying identity seed is 2 and
increment is 2). thisway, if the last value on
a 'supposed' even table is turming odd if the last merged
value is odd. is their a way to force newly generated
autonumbers to be only odd in odd table and only even in
even table. something like a formula?
Thanks
Svur
SVur,
this is how I set it up. On the publisher I set the seed at 1 and increment
at 2 to give odd numbers. I replicated this table to the subscriber. After
initialization I dropped the subscription. On the 'subscriber' I changed the
seed and increment to 2 and 2. I recreated the subscriber using the nosync
option and it all worked OK. You could also probably do this more directly
using @.creation_script on sp_addmergearticle.
HTH,
Paul Ibison
|||Hi Paul,
I tried to implement the way you described, but for some
reason, the identity of the new value is always the
current value + 2, irrespective of what the seed is.
I have no clue as to what goes into @.creation_script, i
have not been able to find any articles online aswell.
i would appreciate if you could help me out with this
Thanks
SVur
>--Original Message--
>SVur,
>this is how I set it up. On the publisher I set the seed
at 1 and increment
>at 2 to give odd numbers. I replicated this table to the
subscriber. After
>initialization I dropped the subscription. On
the 'subscriber' I changed the
>seed and increment to 2 and 2. I recreated the
subscriber using the nosync
>option and it all worked OK. You could also probably do
this more directly
>using @.creation_script on sp_addmergearticle.
>HTH,
>Paul Ibison
>
>.
>
|||SVur,
please script out your initial table and I'll have a go at creating a script
for you.
Regards,
Paul Ibison
|||Hi paul,
Please find the script below:
/****** Object: Table [dbo].[Tasks] Script Date:
7/1/2004 11:34:42 AM ******/
CREATE TABLE [dbo].[Tasks] (
[TaskID] [int] IDENTITY (1, 2) NOT FOR
REPLICATION NOT NULL ,
[UnitOfMeasure] [varchar] (70) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[TaskDesc] [varchar] (100) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[GUID] uniqueidentifier ROWGUIDCOL NOT NULL
) ON [PRIMARY]
GO
Thanks,
SVur
>--Original Message--
>SVur,
>please script out your initial table and I'll have a go
at creating a script
>for you.
>Regards,
>Paul Ibison
>
>.
>
|||Thanks SVur. At the moment we have two threads going essentially the same
issue (hadn't associated your name) so please let's leave this thread and
continue the previous one where I have posted my answer.
Regards,
Paul Ibison

Monday, March 12, 2012

Foramtting chart axis colour using expression

I have a chart on a report that shows value in £ on the Y Axis. The values can be both positive and negative. I would like to have the negative labels to show in red and the positive in black. What is the expression syntax to achieve this? i know it will be an IIF statement, but what is the syntax to show the Y Axis label as <0?

eg if i was doing this for a field it would be iif(Field!Fieldname.value <0, "RED","BLACK") but what would i replace the FIELD!Fieldname.vaue with so the expression would change the Y Axis label.


Thanks in advance for any help

Dave Munro

Hi Dave,

I'm a brazillian guy, but i try to help you !

First of all, You will have to create a code to fill the bars.

REPORT - REPORT PROPERTIES - CODE (tab)

Function ColorBar(VlField) As String
Dim Bar_Colour as String
if VlField > 0 then
Bar_Colour = "BLACK"
Else
Bar_Colour = "RED"
End if

Return Bar_Colour

Afther that, click in chart and set the properties.

click in TAB (VALUES) - VALUE - edit - Appearance (Tab) - Series Style - Fill - expression (color)

=code.ColorBar(Fields!XXXXXX.Value)

OK....

Bye,

Nitrini

Foramtting chart axis colour using expression

I have a chart on a report that shows value in £ on the Y Axis. The values can be both positive and negative. I would like to have the negative labels to show in red and the positive in black. What is the expression syntax to achieve this? i know it will be an IIF statement, but what is the syntax to show the Y Axis label as <0?

eg if i was doing this for a field it would be iif(Field!Fieldname.value <0, "RED","BLACK") but what would i replace the FIELD!Fieldname.vaue with so the expression would change the Y Axis label.


Thanks in advance for any help

Dave Munro

Hi Dave,

I'm a brazillian guy, but i try to help you !

First of all, You will have to create a code to fill the bars.

REPORT - REPORT PROPERTIES - CODE (tab)

Function ColorBar(VlField) As String
Dim Bar_Colour as String
if VlField > 0 then
Bar_Colour = "BLACK"
Else
Bar_Colour = "RED"
End if

Return Bar_Colour

Afther that, click in chart and set the properties.

click in TAB (VALUES) - VALUE - edit - Appearance (Tab) - Series Style - Fill - expression (color)

=code.ColorBar(Fields!XXXXXX.Value)

OK....

Bye,

Nitrini

FOR XML PATH NULL Element

Hi there,
I'm using sp with FOR XML PATH('Employee'), ELEMENTS to return XML Data
from SQL Server 2005.
If row return null value return xml does not return element.
Can it be returned xml element even it contains null?
Ex
i'm getting this
<employee>
<id>1</id>
<image>1.jpg</image>
</employee>
<employee>
<id>2</id>
</employee>
i want this:)
<employee>
<id>1</id>
<image>1.jpg</image>
</employee>
<employee>
<id>2</id>
<image/>
</employee>
*** Sent via Developersdex http://www.examnotes.net ***Hello Zoka,
You could do something like this:
SELECT
..
e.image AS "image/node()"
,'' AS "image/node()" -- Same as above :-), now "image/node()" is never
NULL :-)
..
FROM ... AS e
FOR XML PATH('employee')
HTH
/ Tobias|||
Hi there,
I tried this functionality but does not solve the problem.
*** Sent via Developersdex http://www.examnotes.net ***|||
Sorry Tobias,
This solves my problem, thanks:))
I haven't drink coffe when i first try the script:)
Regards,
Zoka
*** Sent via Developersdex http://www.examnotes.net ***

Friday, March 9, 2012

FOR XML EXPLICIT and optional attributes

If attributes of an element are optional can XML Explicit be used to
only return such attrubutes if their value is not null. eg. to return
something like:
<Person Name = "Paul" BicycleBrand = "Raliegh">
<Person Name = "John" CarBrand = "Ford">
Rather than
<Person Name = "Paul" BicycleBrand = "Raliegh" CarBrand = "">
<Person Name = "John" BicycleBrand = "" CarBrand = "Ford">
?It is the default behaviour of FOR XML EXPLICIT to map null value to absent
attributes.
Best regards
Michael
<paul.l@.paloma.co.uk> wrote in message
news:1115912643.596304.92390@.o13g2000cwo.googlegroups.com...
> If attributes of an element are optional can XML Explicit be used to
> only return such attrubutes if their value is not null. eg. to return
> something like:
> <Person Name = "Paul" BicycleBrand = "Raliegh">
> <Person Name = "John" CarBrand = "Ford">
> Rather than
> <Person Name = "Paul" BicycleBrand = "Raliegh" CarBrand = "">
> <Person Name = "John" BicycleBrand = "" CarBrand = "Ford">
> ?
>|||Thanks
Michael Rys [MSFT] wrote:
> It is the default behaviour of FOR XML EXPLICIT to map null value to
absent
> attributes.
> Best regards
> Michael
> <paul.l@.paloma.co.uk> wrote in message
> news:1115912643.596304.92390@.o13g2000cwo.googlegroups.com...
to
return|||Thanks. Thought it might be simple.
Michael Rys [MSFT] wrote:
> It is the default behaviour of FOR XML EXPLICIT to map null value to
absent
> attributes.
> Best regards
> Michael
> <paul.l@.paloma.co.uk> wrote in message
> news:1115912643.596304.92390@.o13g2000cwo.googlegroups.com...
to
return

Wednesday, March 7, 2012

FOR XML EXPLICIT and optional attributes

If attributes of an element are optional can XML Explicit be used to
only return such attrubutes if their value is not null. eg. to return
something like:
<Person Name = "Paul" BicycleBrand = "Raliegh">
<Person Name = "John" CarBrand = "Ford">
Rather than
<Person Name = "Paul" BicycleBrand = "Raliegh" CarBrand = "">
<Person Name = "John" BicycleBrand = "" CarBrand = "Ford">
?
It is the default behaviour of FOR XML EXPLICIT to map null value to absent
attributes.
Best regards
Michael
<paul.l@.paloma.co.uk> wrote in message
news:1115912643.596304.92390@.o13g2000cwo.googlegro ups.com...
> If attributes of an element are optional can XML Explicit be used to
> only return such attrubutes if their value is not null. eg. to return
> something like:
> <Person Name = "Paul" BicycleBrand = "Raliegh">
> <Person Name = "John" CarBrand = "Ford">
> Rather than
> <Person Name = "Paul" BicycleBrand = "Raliegh" CarBrand = "">
> <Person Name = "John" BicycleBrand = "" CarBrand = "Ford">
> ?
>
|||Thanks
Michael Rys [MSFT] wrote:
> It is the default behaviour of FOR XML EXPLICIT to map null value to
absent[vbcol=seagreen]
> attributes.
> Best regards
> Michael
> <paul.l@.paloma.co.uk> wrote in message
> news:1115912643.596304.92390@.o13g2000cwo.googlegro ups.com...
to[vbcol=seagreen]
return[vbcol=seagreen]
|||Thanks. Thought it might be simple.
Michael Rys [MSFT] wrote:
> It is the default behaviour of FOR XML EXPLICIT to map null value to
absent[vbcol=seagreen]
> attributes.
> Best regards
> Michael
> <paul.l@.paloma.co.uk> wrote in message
> news:1115912643.596304.92390@.o13g2000cwo.googlegro ups.com...
to[vbcol=seagreen]
return[vbcol=seagreen]

Sunday, February 26, 2012

For NULL

Hello Everybody
When I do Insert query for table targeting selected columns
it has to store NULL value for rest of the columns,
without going into design and click NULL for each column ,
is there any other way to set once for all, that is to be
applicable to all tables?On Mar 22, 10:20 pm, spaulsa...@.yahoo.co.in wrote:
> Hello Everybody
> When I do Insert query for table targeting selected columns
> it has to store NULL value for rest of the columns,
> without going into design and click NULL for each column ,
> is there any other way to set once for all, that is to be
> applicable to all tables?
Select the table and columns from information_schema.columns and write
a query to ALTER TABLE ALTER COLUMN with NULL

For NULL

Hello Everybody
When I do Insert query for table targeting selected columns
it has to store NULL value for rest of the columns,
without going into design and click NULL for each column ,
is there any other way to set once for all, that is to be
applicable to all tables?
On Mar 22, 10:20 pm, spaulsa...@.yahoo.co.in wrote:
> Hello Everybody
> When I do Insert query for table targeting selected columns
> it has to store NULL value for rest of the columns,
> without going into design and click NULL for each column ,
> is there any other way to set once for all, that is to be
> applicable to all tables?
Select the table and columns from information_schema.columns and write
a query to ALTER TABLE ALTER COLUMN with NULL

For NULL

Hello Everybody
When I do Insert query for table targeting selected columns
it has to store NULL value for rest of the columns,
without going into design and click NULL for each column ,
is there any other way to set once for all, that is to be
applicable to all tables?On Mar 22, 10:20 pm, spaulsa...@.yahoo.co.in wrote:
> Hello Everybody
> When I do Insert query for table targeting selected columns
> it has to store NULL value for rest of the columns,
> without going into design and click NULL for each column ,
> is there any other way to set once for all, that is to be
> applicable to all tables?
Select the table and columns from information_schema.columns and write
a query to ALTER TABLE ALTER COLUMN with NULL

Sunday, February 19, 2012

For Each in SQL?

Hi. using SQL Server 2000 here.

What I want to do is pretty much execute a stored procedure, giving it the value of a field.

The thing is, since I am still learning SQL, I am new to this and have no idea how it should be done....

The way this has to be is, execute a query (SELECT someField FROM SomeTable)

then, foreach record for this someField column, I want to be able to get the someField value, and give it to a stored proc as a parameter (EXEC sp_whatever @.p1)

how would I achieve this? is this possible?

First off, this is generally a bad idea if you can avoid it. Most of the time if you can rewrite it to where it acts in a single statement, that is the best way.

However, if you are stuck with the stored procedure:

create table test
(
testId int primary key
)
go
insert into test
select 1
union all
select 2
union all
select 3
go

declare @.cursor cursor, @.testId int
set @.cursor = cursor for select testId from test
open @.cursor

while 1=1
begin
fetch from @.cursor into @.testId
if @.@.fetch_status <> 0
break
exec sp_whatever @.testId --also, you should shy away from using sp_ as a
--procedure name as this is the standard for
--system objects

end

|||

ah ok, if you say its generally the bad way, which is what I assumed, please tell me a better way of doing this.

The current situation is.... I will need to send out emails to a list of email addresses from my ASP.NET site.

Since I do not want the user to have to wait impatiently, as there could be several hundred email addresses, I want SQL Server to take care of it and thought perhaps this would be the best way - create a job and run it, and this job will send out the emails using a stored proc.

What do you think? What is the best practice? I always want to use best practice. should such a thing be done in SQL?

|||

Hi...

Thats a valid use for cursors... But i try to avoid them like there is no tomorrow.

Anyway... Since sending an email is a "slow" process you should consider decoupling it from your procedure that gets called when a "user" does anything. If he is requesting 1000 email to be send, and your sql server will stop responding for that time, then the user might think that your website is broken...

This can be done in 2 ways... One in SQL 2005 would be the service broker (Check BOL), and a solution in SQL 2000 would be that you create an email table, populate it (without a cursor) when the user wants to send his email, and then process it asyncronically (spelling?) in a job thats executing regulary (You can use a cursor in this job...

But make sure you only use the type of cursor you realy need).

Another solution to avoid cursors would be that you can do a select top 1 in a while loot and evaluating rowcount...

|||Many thanks, wow soo many things to consider. *overload*|||

Hatzi74 wrote:

This can be done in 2 ways... One in SQL 2005 would be the service broker (Check BOL), and a solution in SQL 2000 would be that you create an email table, populate it (without a cursor) when the user wants to send his email, and then process it asyncronically (spelling?) in a job thats executing regulary (You can use a cursor in this job...

I would suggest the email queue table for either version. It is just simpler to work with in your other code, since you can do a simple insert (and more than one row at a time!)

Also, in 2005 the email isn't sent immediately, so it is a pretty fast call to the db_send_mail procedure. (and it can be rolled back if you are in a transaction: http://spaces.msn.com/drsql/blog/cns!80677FB08B3162E4!913.entry)

Hatzi74 wrote:

But make sure you only use the type of cursor you realy need).

Agreed.

Hatzi74 wrote:

Another solution to avoid cursors would be that you can do a select top 1 in a while loot and evaluating rowcount.

While this can be a bit faster in some situations, it is best to just avoid looping altogether if possible :)

|||

Many thanks

fortunatly I found another way of doing this, after following and using the example, without having to use SQL *pheeww* so yes, great replies but was bad practice.

thread should really be removed to prevent people using bad practice lol