Showing posts with label record. Show all posts
Showing posts with label record. Show all posts

Thursday, March 8, 2012

aggregate question

In the below structure, if I wanted to get the Id of the comment for
each Generic record having the latest comment time, how would I do that
not using a subquery?

Table: Generic
Id
Description

Table: Comment
Id
GenericId
CommentTime

Currently I have something like the following:

Select
Generic.Id, Max(Comment.CommentTime) /*,Comment.Id for max comment
time comment record*/
From
Generic
INNER JOIN Comment ON Generic.Id = Comment.GenericId
Group By
Generic.Id

To get it, I could do a sub query, using the above query as its source
and joining on the max comment time, but I was wondering if there was a
way to do it without a sub query. Keep in mind that I am looking for a
set of Generic records and not looking for only a single record (so
select top top 1 with order by won't work)You need to take what you have and use it as a subquery as you've
suggested. Other than the subquery, there's no way in SQL to say "give
me the id column from the right table where some other column in the
right table has it's max value".

The reason you can't do that is simple: what id would you get back
from the right table if the maximum value occured in more than one row?|||On 3 Nov 2005 08:41:10 -0800, pb648174 wrote:

>In the below structure, if I wanted to get the Id of the comment for
>each Generic record having the latest comment time, how would I do that
>not using a subquery?
>Table: Generic
>Id
>Description
>Table: Comment
>Id
>GenericId
>CommentTime
>Currently I have something like the following:
>Select
> Generic.Id, Max(Comment.CommentTime) /*,Comment.Id for max comment
>time comment record*/
>From
> Generic
> INNER JOIN Comment ON Generic.Id = Comment.GenericId
>Group By
> Generic.Id
>To get it, I could do a sub query, using the above query as its source
>and joining on the max comment time, but I was wondering if there was a
>way to do it without a sub query. Keep in mind that I am looking for a
>set of Generic records and not looking for only a single record (so
>select top top 1 with order by won't work)

Hi pb648174,

You can do this in two ways.

1. Using a correlated subquery (probably the solution you already had in
mind, since you write: "if there was a way to do it without a sub
query", but I'll give it anyway)

SELECT g.Id, c.CommentTime, c.Id
FROM Generic AS g
INNER JOIN Comment AS c
ON c.GenericId = g.Id
WHERE c.CommentTime = (SELECT MAX(c2.CommentTime)
FROM Comment AS c2
WHERE c2.GenericId = c.GenericId)

2. Using a derived table. This is a subquery as well, but it's not
correlated, and it's used in the FROM clause, in place of a table or
view name:

SELECT g.Id, c.CommentTime, c.Id
FROM Generic AS g
INNER JOIN (SELECT GenericId, MAX(CommentTime) AS MaxCommentTime
FROM Comment
GROUP BY GenericId) AS c2
ON c2.GenericId = g.Id
INNER JOIN Comment AS c
ON c.GenericId = g.Id
AND c.CommentTime = c2.MaxCommentTime

(Note: both queries are untested - see www.aspfaq.com/5006 if you prefer
a tested reply)

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)|||Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. If you had done this right and realized tht ther are
no magical, universal "id' things in RDBMS, would the schema look like
this?

CREATE TABLE Generic
(generic_id INTEGER NOT NULL PRIMARY KEY,
description VARCHAR(30) NOT NULL,
..);

CREATE TABLE Comments
(generic_id INTEGER NOT NULL
REFERENCES Generic (generic_id)
comment_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
-- where is the comment??
PRIMARY KEY (generic_id, comment_time));

>> but I was wondering if there was a way to do it without a subquery. <<

No, not unless you move comment time into Gerneric.|||Thanks, Celko. Helpful and on-topic as always.

Friday, February 24, 2012

AFTER Trigger

SalesMan Account
SID AcctType AID AID AcctName
1 0 1 1 myName
2 1 2 2 hisName
I need a trigger that when the AcctType is set to 2, it will delete record 2
(AID 2)(hisName) in the Account table.
Hi
create trigger my_tr on SalesMan for update
as
begin
if update(Acctype)
begin
delete Account where id in (select id from deleted where
deleted.aid=Account.aid)
end
end
"morphius" <morphius@.discussions.microsoft.com> wrote in message
news:76172D5C-A425-40D3-B48B-BD0A78CCEA61@.microsoft.com...
> SalesMan Account
> SID AcctType AID AID AcctName
> 1 0 1 1 myName
> 2 1 2 2 hisName
> I need a trigger that when the AcctType is set to 2, it will delete record
> 2
> (AID 2)(hisName) in the Account table.
|||I think this trigger does not specify that AcctType has been changed to 2,
so may delete more than expected.
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:ewomg08kIHA.1204@.TK2MSFTNGP03.phx.gbl...
> Hi
> create trigger my_tr on SalesMan for update
> as
> begin
> if update(Acctype)
> begin
> delete Account where id in (select id from deleted where
> deleted.aid=Account.aid)
> end
> end
>
> "morphius" <morphius@.discussions.microsoft.com> wrote in message
> news:76172D5C-A425-40D3-B48B-BD0A78CCEA61@.microsoft.com...
>
|||> when the AcctType is set to 2
When which AcctType is set to 2? The row with SID 1? The row with SID 2?
If SID 1, why should it delete SID 2? What shows me that rows 1 and 2 are
related in any way?
"morphius" <morphius@.discussions.microsoft.com> wrote in message
news:76172D5C-A425-40D3-B48B-BD0A78CCEA61@.microsoft.com...
> SalesMan Account
> SID AcctType AID AID AcctName
> 1 0 1 1 myName
> 2 1 2 2 hisName
> I need a trigger that when the AcctType is set to 2, it will delete record
> 2
> (AID 2)(hisName) in the Account table.
|||Good catch Aaron, I have just missed it :-))
create table t1 (c int not null primary key,c2 int)
insert into t1 values (1,1)
insert into t1 values (2,10)
insert into t1 values (3,20)
insert into t1 values (4,30)
create table t2 (c int ,c2 char(1))
insert into t2 values (1,'a')
insert into t2 values (1,'b')
insert into t2 values (2,'c')
insert into t2 values (3,'d')
insert into t2 values (4,'f')
alter trigger my_tr on t1 for update
as
begin
if update(c2)
begin
delete t2 where exists (select * from
inserted i where i.c=t2.c and i.c2=2)
end
end
update t1 set c2=20 where c=1
--did not delete
select * from t2
update t1 set c2=2 where c=1
--does
select * from t2
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uJgw9Q$kIHA.1204@.TK2MSFTNGP03.phx.gbl...
>I think this trigger does not specify that AcctType has been changed to 2,
>so may delete more than expected.
>
>
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:ewomg08kIHA.1204@.TK2MSFTNGP03.phx.gbl...
>

Sunday, February 19, 2012

After restoring the Database getting this message "Cannot Modify record"

Good Morning Friends
I am in real soup. I am new to SQL server 7.0 and Visual basic 6.0. I
have got one application developed by some software agency using VB 6.0
and sql server 7.0. Since last 6 years everything worked
Three days my SQLserver machine crashed because of hard disk failure.
After much effort of two days I restored all the data from the
backup.In our Application primarily there are two sections Members and
Agency. Everything working fine in the Members section i.e browsing,
modification, deletion of records etc. But in the agency section only
browsing of record is working if I want to Edit the record and then
press the save button it gives the error message " Cannot Modify
Record, Please close the screen and reopen. All changes will be lost."
Actions Taken till now:
1. Change the deafult db to "ABC" for the user "CFC" Logging into the
SQLserver. This was the arrangement before crashing.
2. Granted the server role "db owner", "db creator" to the user "CFC".
3. Checked the tables permission of Members section (Where Modify is
working) as well as agency section (Where Modify is not working), both
the tables have same kind of permission.
4. Tried to get answer on google but of no help.
Please help me urgently.
Thanks
Deepak SinhaSo the application is not reporting the actual SQL Server error message?
Without that information, you are shooting in the dark. I suggest you run a
SQL Profiler trace and also include Errors/Exceptions. This will hopefully
help identify the cause of the error.
You mention that you restored from backup. Was this a SQL Server backup?
Did you reinstall SQL Server?
Hope this helps.
Dan Guzman
SQL Server MVP
"microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
news:1154755197.215422.79810@.75g2000cwc.googlegroups.com...
> Good Morning Friends
> I am in real soup. I am new to SQL server 7.0 and Visual basic 6.0. I
> have got one application developed by some software agency using VB 6.0
> and sql server 7.0. Since last 6 years everything worked
> Three days my SQLserver machine crashed because of hard disk failure.
> After much effort of two days I restored all the data from the
> backup.In our Application primarily there are two sections Members and
> Agency. Everything working fine in the Members section i.e browsing,
> modification, deletion of records etc. But in the agency section only
> browsing of record is working if I want to Edit the record and then
> press the save button it gives the error message " Cannot Modify
> Record, Please close the screen and reopen. All changes will be lost."
> Actions Taken till now:
> 1. Change the deafult db to "ABC" for the user "CFC" Logging into the
> SQLserver. This was the arrangement before crashing.
> 2. Granted the server role "db owner", "db creator" to the user "CFC".
> 3. Checked the tables permission of Members section (Where Modify is
> working) as well as agency section (Where Modify is not working), both
> the tables have same kind of permission.
> 4. Tried to get answer on google but of no help.
> Please help me urgently.
> Thanks
> Deepak Sinha
>|||Thanks for ur reply Guzman.
1. Yes It was a SQL server backup
2. I did not reinstall SQL server .
I will run a SQL profiler trace and get back.
Thanks again.
Deepak
Dan Guzman wrote:[vbcol=seagreen]
> So the application is not reporting the actual SQL Server error message?
> Without that information, you are shooting in the dark. I suggest you run
a
> SQL Profiler trace and also include Errors/Exceptions. This will hopefull
y
> help identify the cause of the error.
> You mention that you restored from backup. Was this a SQL Server backup?
> Did you reinstall SQL Server?
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
> news:1154755197.215422.79810@.75g2000cwc.googlegroups.com...|||How do I run SQL profiler with Errors/Exceptions included? By "Errors"
do you mean those Errors which I am getting in the application i.e
"Cannot Modify..." ! If yes How do I include this message in the
profiler, becse I do not see there any option for inclusion of my error
message. Please guide.
Deepak
microsoft . public . sqlserver wrote:[vbcol=seagreen]
> Thanks for ur reply Guzman.
> 1. Yes It was a SQL server backup
> 2. I did not reinstall SQL server .
> I will run a SQL profiler trace and get back.
> Thanks again.
> Deepak
> Dan Guzman wrote:|||> How do I run SQL profiler with Errors/Exceptions included? By "Errors"
> do you mean those Errors which I am getting in the application i.e
> "Cannot Modify..." !
The 'Cannot Modify' message is not a SQL Server error message; it is a
generic message generated by the VB6 application, probably in response to a
SQL Server error. Hopefully, the trace will allow you to identify the
actual SQL Server error so that you can take corrective action.
I don't have SQL 7 Profiler available but I believe the steps are similar to
SQL 2000 Profiler. There should be an Errors and Warnings event class.
Include all those events.
Hope this helps.
Dan Guzman
SQL Server MVP
"microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
news:1154777520.843807.294740@.i3g2000cwc.googlegroups.com...
> How do I run SQL profiler with Errors/Exceptions included? By "Errors"
> do you mean those Errors which I am getting in the application i.e
> "Cannot Modify..." ! If yes How do I include this message in the
> profiler, becse I do not see there any option for inclusion of my error
> message. Please guide.
> Deepak
> microsoft . public . sqlserver wrote:
>|||Sir,
On running SQL profiler with Error/Exceptions included It is showing
"Error: 16821, Severity: 16, State: 1" it is also giving another error
message
"Operating system Error 87., The Parameter is incorrect"
All these error messages in front of the database ID master while my
application is running on the database "ABC"
When I
Dan Guzman wrote:[vbcol=seagreen]
> The 'Cannot Modify' message is not a SQL Server error message; it is a
> generic message generated by the VB6 application, probably in response to
a
> SQL Server error. Hopefully, the trace will allow you to identify the
> actual SQL Server error so that you can take corrective action.
> I don't have SQL 7 Profiler available but I believe the steps are similar
to
> SQL 2000 Profiler. There should be an Errors and Warnings event class.
> Include all those events.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
> news:1154777520.843807.294740@.i3g2000cwc.googlegroups.com...|||Dear Sir
I ran the SQL profiler and I got these error messages
1. Error 16821, Severity: 16, state: 1
2. Operating system Error 87., The parameter is incorrect
3. sp_executesql N'UPDATE "INSDB".."INS_M_agency" SET
"reg_code"=@.P1,"agen_name"=@.P2,"agen_place"=@.P3,"estb_date"=@.P4,'', ''
go
When I ran the above SQL statement in the Query Analyzer It is giving
Error message "Server: Msg 170, Level 15, State 1, Line 1"
" Line 1: Incorrect syntax near 'INSDB'."
4. UPDATE "INSDB".."INS_M_agency" SET
"reg_code"=@.P1,"agen_name"=@.P2,"agen_place"=@.P3,"estb_date"=@.P4
g0
5. After the hard disk crash at the time of restoration I got this
Error message "[SQL-DMO] You must be logged in as 'sa' or a member of
sysadmin, or a member of dbcreator" to get rid of this problem I
downloaded SQL server Service pack 2 from microsoft site and installed
it. After the restoration every other part of the application working
except this. I doubt is it because of the service pack 2 ? Can I
upgrade it to service pack 3 or 4 or I can uninstall service pack 2.
Please guide
Thanks
Deepak Sinha
microsoft . public . sqlserver wrote:[vbcol=seagreen]
> Sir,
> On running SQL profiler with Error/Exceptions included It is showing
> "Error: 16821, Severity: 16, State: 1" it is also giving another error
> message
> "Operating system Error 87., The Parameter is incorrect"
> All these error messages in front of the database ID master while my
> application is running on the database "ABC"
> When I
> Dan Guzman wrote:|||> except this. I doubt is it because of the service pack 2 ? Can I
> upgrade it to service pack 3 or 4 or I can uninstall service pack 2.
I suggest you install SP4 since that's the final service pack for SQL 7.
Otherwise, you should run the same service pack as the original system.
That may be the underlying cause of these errors.
Hope this helps.
Dan Guzman
SQL Server MVP
"microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
news:1154857843.655253.136200@.m73g2000cwd.googlegroups.com...
> Dear Sir
> I ran the SQL profiler and I got these error messages
> 1. Error 16821, Severity: 16, state: 1
> 2. Operating system Error 87., The parameter is incorrect
> 3. sp_executesql N'UPDATE "INSDB".."INS_M_agency" SET
> "reg_code"=@.P1,"agen_name"=@.P2,"agen_place"=@.P3,"estb_date"=@.P4,'', ''
> go
> When I ran the above SQL statement in the Query Analyzer It is giving
> Error message "Server: Msg 170, Level 15, State 1, Line 1"
> " Line 1: Incorrect syntax near 'INSDB'."
>
> 4. UPDATE "INSDB".."INS_M_agency" SET
> "reg_code"=@.P1,"agen_name"=@.P2,"agen_place"=@.P3,"estb_date"=@.P4
> g0
> 5. After the hard disk crash at the time of restoration I got this
> Error message "[SQL-DMO] You must be logged in as 'sa' or a member of
> sysadmin, or a member of dbcreator" to get rid of this problem I
> downloaded SQL server Service pack 2 from microsoft site and installed
> it. After the restoration every other part of the application working
> except this. I doubt is it because of the service pack 2 ? Can I
> upgrade it to service pack 3 or 4 or I can uninstall service pack 2.
> Please guide
> Thanks
> Deepak Sinha
> microsoft . public . sqlserver wrote:
>|||I downloaded and installed the service pack 3 now my Enterprise Manager
is not starting after giving the previous user name(tre) and
password(****). It is saying "Connection failed check SQL server
registration properties" When I edit the reg. properties by giving
previous user-id and pwd it is saying "cannot open default database
'<ID>' . using master database instead". I tried changing default
database at the command prompt
C:\mssql7\binn>isql -E -d
1>use master
2>go
1>sp_defaultdb tre, insdb
2>go
Default database changed
1>exit
When I go back to Enterprise Manager it is still same. I am in a real
mess.
Pl. Guide.
Deepka
Dan Guzman wrote:[vbcol=seagreen]
> I suggest you install SP4 since that's the final service pack for SQL 7.
> Otherwise, you should run the same service pack as the original system.
> That may be the underlying cause of these errors.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
> news:1154857843.655253.136200@.m73g2000cwd.googlegroups.com...|||Do you get any messages when you access the database?

>isql -E -d
>USE insdb
>GO
>exit
Hope this helps.
Dan Guzman
SQL Server MVP
"microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
news:1154869759.625272.196410@.m73g2000cwd.googlegroups.com...
>I downloaded and installed the service pack 3 now my Enterprise Manager
> is not starting after giving the previous user name(tre) and
> password(****). It is saying "Connection failed check SQL server
> registration properties" When I edit the reg. properties by giving
> previous user-id and pwd it is saying "cannot open default database
> '<ID>' . using master database instead". I tried changing default
> database at the command prompt
> C:\mssql7\binn>isql -E -d
> 1>use master
> 2>go
> 1>sp_defaultdb tre, insdb
> 2>go
> Default database changed
> 1>exit
> When I go back to Enterprise Manager it is still same. I am in a real
> mess.
> Pl. Guide.
> Deepka
> Dan Guzman wrote:
>

After restoring the Database getting this message "Cannot Modify record"

Good Morning Friends
I am in real soup. I am new to SQL server 7.0 and Visual basic 6.0. I
have got one application developed by some software agency using VB 6.0
and sql server 7.0. Since last 6 years everything worked
Three days my SQLserver machine crashed because of hard disk failure.
After much effort of two days I restored all the data from the
backup.In our Application primarily there are two sections Members and
Agency. Everything working fine in the Members section i.e browsing,
modification, deletion of records etc. But in the agency section only
browsing of record is working if I want to Edit the record and then
press the save button it gives the error message " Cannot Modify
Record, Please close the screen and reopen. All changes will be lost."
Actions Taken till now:
1. Change the deafult db to "ABC" for the user "CFC" Logging into the
SQLserver. This was the arrangement before crashing.
2. Granted the server role "db owner", "db creator" to the user "CFC".
3. Checked the tables permission of Members section (Where Modify is
working) as well as agency section (Where Modify is not working), both
the tables have same kind of permission.
4. Tried to get answer on google but of no help.
Please help me urgently.
Thanks
Deepak SinhaSo the application is not reporting the actual SQL Server error message?
Without that information, you are shooting in the dark. I suggest you run a
SQL Profiler trace and also include Errors/Exceptions. This will hopefully
help identify the cause of the error.
You mention that you restored from backup. Was this a SQL Server backup?
Did you reinstall SQL Server?
--
Hope this helps.
Dan Guzman
SQL Server MVP
"microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
news:1154755197.215422.79810@.75g2000cwc.googlegroups.com...
> Good Morning Friends
> I am in real soup. I am new to SQL server 7.0 and Visual basic 6.0. I
> have got one application developed by some software agency using VB 6.0
> and sql server 7.0. Since last 6 years everything worked
> Three days my SQLserver machine crashed because of hard disk failure.
> After much effort of two days I restored all the data from the
> backup.In our Application primarily there are two sections Members and
> Agency. Everything working fine in the Members section i.e browsing,
> modification, deletion of records etc. But in the agency section only
> browsing of record is working if I want to Edit the record and then
> press the save button it gives the error message " Cannot Modify
> Record, Please close the screen and reopen. All changes will be lost."
> Actions Taken till now:
> 1. Change the deafult db to "ABC" for the user "CFC" Logging into the
> SQLserver. This was the arrangement before crashing.
> 2. Granted the server role "db owner", "db creator" to the user "CFC".
> 3. Checked the tables permission of Members section (Where Modify is
> working) as well as agency section (Where Modify is not working), both
> the tables have same kind of permission.
> 4. Tried to get answer on google but of no help.
> Please help me urgently.
> Thanks
> Deepak Sinha
>|||Thanks for ur reply Guzman.
1. Yes It was a SQL server backup
2. I did not reinstall SQL server .
I will run a SQL profiler trace and get back.
Thanks again.
Deepak
Dan Guzman wrote:
> So the application is not reporting the actual SQL Server error message?
> Without that information, you are shooting in the dark. I suggest you run a
> SQL Profiler trace and also include Errors/Exceptions. This will hopefully
> help identify the cause of the error.
> You mention that you restored from backup. Was this a SQL Server backup?
> Did you reinstall SQL Server?
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
> news:1154755197.215422.79810@.75g2000cwc.googlegroups.com...
> > Good Morning Friends
> >
> > I am in real soup. I am new to SQL server 7.0 and Visual basic 6.0. I
> > have got one application developed by some software agency using VB 6.0
> > and sql server 7.0. Since last 6 years everything worked
> > Three days my SQLserver machine crashed because of hard disk failure.
> > After much effort of two days I restored all the data from the
> > backup.In our Application primarily there are two sections Members and
> > Agency. Everything working fine in the Members section i.e browsing,
> > modification, deletion of records etc. But in the agency section only
> > browsing of record is working if I want to Edit the record and then
> > press the save button it gives the error message " Cannot Modify
> > Record, Please close the screen and reopen. All changes will be lost."
> > Actions Taken till now:
> > 1. Change the deafult db to "ABC" for the user "CFC" Logging into the
> > SQLserver. This was the arrangement before crashing.
> > 2. Granted the server role "db owner", "db creator" to the user "CFC".
> > 3. Checked the tables permission of Members section (Where Modify is
> > working) as well as agency section (Where Modify is not working), both
> > the tables have same kind of permission.
> > 4. Tried to get answer on google but of no help.
> >
> > Please help me urgently.
> >
> > Thanks
> >
> > Deepak Sinha
> >|||How do I run SQL profiler with Errors/Exceptions included? By "Errors"
do you mean those Errors which I am getting in the application i.e
"Cannot Modify..." ! If yes How do I include this message in the
profiler, becse I do not see there any option for inclusion of my error
message. Please guide.
Deepak
microsoft . public . sqlserver wrote:
> Thanks for ur reply Guzman.
> 1. Yes It was a SQL server backup
> 2. I did not reinstall SQL server .
> I will run a SQL profiler trace and get back.
> Thanks again.
> Deepak
> Dan Guzman wrote:
> > So the application is not reporting the actual SQL Server error message?
> > Without that information, you are shooting in the dark. I suggest you run a
> > SQL Profiler trace and also include Errors/Exceptions. This will hopefully
> > help identify the cause of the error.
> >
> > You mention that you restored from backup. Was this a SQL Server backup?
> > Did you reinstall SQL Server?
> >
> > --
> > Hope this helps.
> >
> > Dan Guzman
> > SQL Server MVP
> >
> > "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
> > news:1154755197.215422.79810@.75g2000cwc.googlegroups.com...
> > > Good Morning Friends
> > >
> > > I am in real soup. I am new to SQL server 7.0 and Visual basic 6.0. I
> > > have got one application developed by some software agency using VB 6.0
> > > and sql server 7.0. Since last 6 years everything worked
> > > Three days my SQLserver machine crashed because of hard disk failure.
> > > After much effort of two days I restored all the data from the
> > > backup.In our Application primarily there are two sections Members and
> > > Agency. Everything working fine in the Members section i.e browsing,
> > > modification, deletion of records etc. But in the agency section only
> > > browsing of record is working if I want to Edit the record and then
> > > press the save button it gives the error message " Cannot Modify
> > > Record, Please close the screen and reopen. All changes will be lost."
> > > Actions Taken till now:
> > > 1. Change the deafult db to "ABC" for the user "CFC" Logging into the
> > > SQLserver. This was the arrangement before crashing.
> > > 2. Granted the server role "db owner", "db creator" to the user "CFC".
> > > 3. Checked the tables permission of Members section (Where Modify is
> > > working) as well as agency section (Where Modify is not working), both
> > > the tables have same kind of permission.
> > > 4. Tried to get answer on google but of no help.
> > >
> > > Please help me urgently.
> > >
> > > Thanks
> > >
> > > Deepak Sinha
> > >|||> How do I run SQL profiler with Errors/Exceptions included? By "Errors"
> do you mean those Errors which I am getting in the application i.e
> "Cannot Modify..." !
The 'Cannot Modify' message is not a SQL Server error message; it is a
generic message generated by the VB6 application, probably in response to a
SQL Server error. Hopefully, the trace will allow you to identify the
actual SQL Server error so that you can take corrective action.
I don't have SQL 7 Profiler available but I believe the steps are similar to
SQL 2000 Profiler. There should be an Errors and Warnings event class.
Include all those events.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
news:1154777520.843807.294740@.i3g2000cwc.googlegroups.com...
> How do I run SQL profiler with Errors/Exceptions included? By "Errors"
> do you mean those Errors which I am getting in the application i.e
> "Cannot Modify..." ! If yes How do I include this message in the
> profiler, becse I do not see there any option for inclusion of my error
> message. Please guide.
> Deepak
> microsoft . public . sqlserver wrote:
>> Thanks for ur reply Guzman.
>> 1. Yes It was a SQL server backup
>> 2. I did not reinstall SQL server .
>> I will run a SQL profiler trace and get back.
>> Thanks again.
>> Deepak
>> Dan Guzman wrote:
>> > So the application is not reporting the actual SQL Server error
>> > message?
>> > Without that information, you are shooting in the dark. I suggest you
>> > run a
>> > SQL Profiler trace and also include Errors/Exceptions. This will
>> > hopefully
>> > help identify the cause of the error.
>> >
>> > You mention that you restored from backup. Was this a SQL Server
>> > backup?
>> > Did you reinstall SQL Server?
>> >
>> > --
>> > Hope this helps.
>> >
>> > Dan Guzman
>> > SQL Server MVP
>> >
>> > "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
>> > news:1154755197.215422.79810@.75g2000cwc.googlegroups.com...
>> > > Good Morning Friends
>> > >
>> > > I am in real soup. I am new to SQL server 7.0 and Visual basic 6.0. I
>> > > have got one application developed by some software agency using VB
>> > > 6.0
>> > > and sql server 7.0. Since last 6 years everything worked
>> > > Three days my SQLserver machine crashed because of hard disk failure.
>> > > After much effort of two days I restored all the data from the
>> > > backup.In our Application primarily there are two sections Members
>> > > and
>> > > Agency. Everything working fine in the Members section i.e browsing,
>> > > modification, deletion of records etc. But in the agency section only
>> > > browsing of record is working if I want to Edit the record and then
>> > > press the save button it gives the error message " Cannot Modify
>> > > Record, Please close the screen and reopen. All changes will be
>> > > lost."
>> > > Actions Taken till now:
>> > > 1. Change the deafult db to "ABC" for the user "CFC" Logging into the
>> > > SQLserver. This was the arrangement before crashing.
>> > > 2. Granted the server role "db owner", "db creator" to the user
>> > > "CFC".
>> > > 3. Checked the tables permission of Members section (Where Modify is
>> > > working) as well as agency section (Where Modify is not working),
>> > > both
>> > > the tables have same kind of permission.
>> > > 4. Tried to get answer on google but of no help.
>> > >
>> > > Please help me urgently.
>> > >
>> > > Thanks
>> > >
>> > > Deepak Sinha
>> > >
>|||Sir,
On running SQL profiler with Error/Exceptions included It is showing
"Error: 16821, Severity: 16, State: 1" it is also giving another error
message
"Operating system Error 87., The Parameter is incorrect"
All these error messages in front of the database ID master while my
application is running on the database "ABC"
When I
Dan Guzman wrote:
> > How do I run SQL profiler with Errors/Exceptions included? By "Errors"
> > do you mean those Errors which I am getting in the application i.e
> > "Cannot Modify..." !
> The 'Cannot Modify' message is not a SQL Server error message; it is a
> generic message generated by the VB6 application, probably in response to a
> SQL Server error. Hopefully, the trace will allow you to identify the
> actual SQL Server error so that you can take corrective action.
> I don't have SQL 7 Profiler available but I believe the steps are similar to
> SQL 2000 Profiler. There should be an Errors and Warnings event class.
> Include all those events.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
> news:1154777520.843807.294740@.i3g2000cwc.googlegroups.com...
> > How do I run SQL profiler with Errors/Exceptions included? By "Errors"
> > do you mean those Errors which I am getting in the application i.e
> > "Cannot Modify..." ! If yes How do I include this message in the
> > profiler, becse I do not see there any option for inclusion of my error
> > message. Please guide.
> >
> > Deepak
> >
> > microsoft . public . sqlserver wrote:
> >> Thanks for ur reply Guzman.
> >> 1. Yes It was a SQL server backup
> >> 2. I did not reinstall SQL server .
> >>
> >> I will run a SQL profiler trace and get back.
> >> Thanks again.
> >>
> >> Deepak
> >> Dan Guzman wrote:
> >> > So the application is not reporting the actual SQL Server error
> >> > message?
> >> > Without that information, you are shooting in the dark. I suggest you
> >> > run a
> >> > SQL Profiler trace and also include Errors/Exceptions. This will
> >> > hopefully
> >> > help identify the cause of the error.
> >> >
> >> > You mention that you restored from backup. Was this a SQL Server
> >> > backup?
> >> > Did you reinstall SQL Server?
> >> >
> >> > --
> >> > Hope this helps.
> >> >
> >> > Dan Guzman
> >> > SQL Server MVP
> >> >
> >> > "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
> >> > news:1154755197.215422.79810@.75g2000cwc.googlegroups.com...
> >> > > Good Morning Friends
> >> > >
> >> > > I am in real soup. I am new to SQL server 7.0 and Visual basic 6.0. I
> >> > > have got one application developed by some software agency using VB
> >> > > 6.0
> >> > > and sql server 7.0. Since last 6 years everything worked
> >> > > Three days my SQLserver machine crashed because of hard disk failure.
> >> > > After much effort of two days I restored all the data from the
> >> > > backup.In our Application primarily there are two sections Members
> >> > > and
> >> > > Agency. Everything working fine in the Members section i.e browsing,
> >> > > modification, deletion of records etc. But in the agency section only
> >> > > browsing of record is working if I want to Edit the record and then
> >> > > press the save button it gives the error message " Cannot Modify
> >> > > Record, Please close the screen and reopen. All changes will be
> >> > > lost."
> >> > > Actions Taken till now:
> >> > > 1. Change the deafult db to "ABC" for the user "CFC" Logging into the
> >> > > SQLserver. This was the arrangement before crashing.
> >> > > 2. Granted the server role "db owner", "db creator" to the user
> >> > > "CFC".
> >> > > 3. Checked the tables permission of Members section (Where Modify is
> >> > > working) as well as agency section (Where Modify is not working),
> >> > > both
> >> > > the tables have same kind of permission.
> >> > > 4. Tried to get answer on google but of no help.
> >> > >
> >> > > Please help me urgently.
> >> > >
> >> > > Thanks
> >> > >
> >> > > Deepak Sinha
> >> > >
> >|||Dear Sir
I ran the SQL profiler and I got these error messages
1. Error 16821, Severity: 16, state: 1
2. Operating system Error 87., The parameter is incorrect
3. sp_executesql N'UPDATE "INSDB".."INS_M_agency" SET
"reg_code"=@.P1,"agen_name"=@.P2,"agen_place"=@.P3,"estb_date"=@.P4,'', ''
go
When I ran the above SQL statement in the Query Analyzer It is giving
Error message "Server: Msg 170, Level 15, State 1, Line 1"
" Line 1: Incorrect syntax near 'INSDB'."
4. UPDATE "INSDB".."INS_M_agency" SET
"reg_code"=@.P1,"agen_name"=@.P2,"agen_place"=@.P3,"estb_date"=@.P4
g0
5. After the hard disk crash at the time of restoration I got this
Error message "[SQL-DMO] You must be logged in as 'sa' or a member of
sysadmin, or a member of dbcreator" to get rid of this problem I
downloaded SQL server Service pack 2 from microsoft site and installed
it. After the restoration every other part of the application working
except this. I doubt is it because of the service pack 2 ? Can I
upgrade it to service pack 3 or 4 or I can uninstall service pack 2.
Please guide
Thanks
Deepak Sinha
microsoft . public . sqlserver wrote:
> Sir,
> On running SQL profiler with Error/Exceptions included It is showing
> "Error: 16821, Severity: 16, State: 1" it is also giving another error
> message
> "Operating system Error 87., The Parameter is incorrect"
> All these error messages in front of the database ID master while my
> application is running on the database "ABC"
> When I
> Dan Guzman wrote:
> > > How do I run SQL profiler with Errors/Exceptions included? By "Errors"
> > > do you mean those Errors which I am getting in the application i.e
> > > "Cannot Modify..." !
> >
> > The 'Cannot Modify' message is not a SQL Server error message; it is a
> > generic message generated by the VB6 application, probably in response to a
> > SQL Server error. Hopefully, the trace will allow you to identify the
> > actual SQL Server error so that you can take corrective action.
> >
> > I don't have SQL 7 Profiler available but I believe the steps are similar to
> > SQL 2000 Profiler. There should be an Errors and Warnings event class.
> > Include all those events.
> >
> > --
> > Hope this helps.
> >
> > Dan Guzman
> > SQL Server MVP
> >
> > "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
> > news:1154777520.843807.294740@.i3g2000cwc.googlegroups.com...
> > > How do I run SQL profiler with Errors/Exceptions included? By "Errors"
> > > do you mean those Errors which I am getting in the application i.e
> > > "Cannot Modify..." ! If yes How do I include this message in the
> > > profiler, becse I do not see there any option for inclusion of my error
> > > message. Please guide.
> > >
> > > Deepak
> > >
> > > microsoft . public . sqlserver wrote:
> > >> Thanks for ur reply Guzman.
> > >> 1. Yes It was a SQL server backup
> > >> 2. I did not reinstall SQL server .
> > >>
> > >> I will run a SQL profiler trace and get back.
> > >> Thanks again.
> > >>
> > >> Deepak
> > >> Dan Guzman wrote:
> > >> > So the application is not reporting the actual SQL Server error
> > >> > message?
> > >> > Without that information, you are shooting in the dark. I suggest you
> > >> > run a
> > >> > SQL Profiler trace and also include Errors/Exceptions. This will
> > >> > hopefully
> > >> > help identify the cause of the error.
> > >> >
> > >> > You mention that you restored from backup. Was this a SQL Server
> > >> > backup?
> > >> > Did you reinstall SQL Server?
> > >> >
> > >> > --
> > >> > Hope this helps.
> > >> >
> > >> > Dan Guzman
> > >> > SQL Server MVP
> > >> >
> > >> > "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
> > >> > news:1154755197.215422.79810@.75g2000cwc.googlegroups.com...
> > >> > > Good Morning Friends
> > >> > >
> > >> > > I am in real soup. I am new to SQL server 7.0 and Visual basic 6.0. I
> > >> > > have got one application developed by some software agency using VB
> > >> > > 6.0
> > >> > > and sql server 7.0. Since last 6 years everything worked
> > >> > > Three days my SQLserver machine crashed because of hard disk failure.
> > >> > > After much effort of two days I restored all the data from the
> > >> > > backup.In our Application primarily there are two sections Members
> > >> > > and
> > >> > > Agency. Everything working fine in the Members section i.e browsing,
> > >> > > modification, deletion of records etc. But in the agency section only
> > >> > > browsing of record is working if I want to Edit the record and then
> > >> > > press the save button it gives the error message " Cannot Modify
> > >> > > Record, Please close the screen and reopen. All changes will be
> > >> > > lost."
> > >> > > Actions Taken till now:
> > >> > > 1. Change the deafult db to "ABC" for the user "CFC" Logging into the
> > >> > > SQLserver. This was the arrangement before crashing.
> > >> > > 2. Granted the server role "db owner", "db creator" to the user
> > >> > > "CFC".
> > >> > > 3. Checked the tables permission of Members section (Where Modify is
> > >> > > working) as well as agency section (Where Modify is not working),
> > >> > > both
> > >> > > the tables have same kind of permission.
> > >> > > 4. Tried to get answer on google but of no help.
> > >> > >
> > >> > > Please help me urgently.
> > >> > >
> > >> > > Thanks
> > >> > >
> > >> > > Deepak Sinha
> > >> > >
> > >|||> except this. I doubt is it because of the service pack 2 ? Can I
> upgrade it to service pack 3 or 4 or I can uninstall service pack 2.
I suggest you install SP4 since that's the final service pack for SQL 7.
Otherwise, you should run the same service pack as the original system.
That may be the underlying cause of these errors.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
news:1154857843.655253.136200@.m73g2000cwd.googlegroups.com...
> Dear Sir
> I ran the SQL profiler and I got these error messages
> 1. Error 16821, Severity: 16, state: 1
> 2. Operating system Error 87., The parameter is incorrect
> 3. sp_executesql N'UPDATE "INSDB".."INS_M_agency" SET
> "reg_code"=@.P1,"agen_name"=@.P2,"agen_place"=@.P3,"estb_date"=@.P4,'', ''
> go
> When I ran the above SQL statement in the Query Analyzer It is giving
> Error message "Server: Msg 170, Level 15, State 1, Line 1"
> " Line 1: Incorrect syntax near 'INSDB'."
>
> 4. UPDATE "INSDB".."INS_M_agency" SET
> "reg_code"=@.P1,"agen_name"=@.P2,"agen_place"=@.P3,"estb_date"=@.P4
> g0
> 5. After the hard disk crash at the time of restoration I got this
> Error message "[SQL-DMO] You must be logged in as 'sa' or a member of
> sysadmin, or a member of dbcreator" to get rid of this problem I
> downloaded SQL server Service pack 2 from microsoft site and installed
> it. After the restoration every other part of the application working
> except this. I doubt is it because of the service pack 2 ? Can I
> upgrade it to service pack 3 or 4 or I can uninstall service pack 2.
> Please guide
> Thanks
> Deepak Sinha
> microsoft . public . sqlserver wrote:
>> Sir,
>> On running SQL profiler with Error/Exceptions included It is showing
>> "Error: 16821, Severity: 16, State: 1" it is also giving another error
>> message
>> "Operating system Error 87., The Parameter is incorrect"
>> All these error messages in front of the database ID master while my
>> application is running on the database "ABC"
>> When I
>> Dan Guzman wrote:
>> > > How do I run SQL profiler with Errors/Exceptions included? By
>> > > "Errors"
>> > > do you mean those Errors which I am getting in the application i.e
>> > > "Cannot Modify..." !
>> >
>> > The 'Cannot Modify' message is not a SQL Server error message; it is a
>> > generic message generated by the VB6 application, probably in response
>> > to a
>> > SQL Server error. Hopefully, the trace will allow you to identify the
>> > actual SQL Server error so that you can take corrective action.
>> >
>> > I don't have SQL 7 Profiler available but I believe the steps are
>> > similar to
>> > SQL 2000 Profiler. There should be an Errors and Warnings event class.
>> > Include all those events.
>> >
>> > --
>> > Hope this helps.
>> >
>> > Dan Guzman
>> > SQL Server MVP
>> >
>> > "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
>> > news:1154777520.843807.294740@.i3g2000cwc.googlegroups.com...
>> > > How do I run SQL profiler with Errors/Exceptions included? By
>> > > "Errors"
>> > > do you mean those Errors which I am getting in the application i.e
>> > > "Cannot Modify..." ! If yes How do I include this message in the
>> > > profiler, becse I do not see there any option for inclusion of my
>> > > error
>> > > message. Please guide.
>> > >
>> > > Deepak
>> > >
>> > > microsoft . public . sqlserver wrote:
>> > >> Thanks for ur reply Guzman.
>> > >> 1. Yes It was a SQL server backup
>> > >> 2. I did not reinstall SQL server .
>> > >>
>> > >> I will run a SQL profiler trace and get back.
>> > >> Thanks again.
>> > >>
>> > >> Deepak
>> > >> Dan Guzman wrote:
>> > >> > So the application is not reporting the actual SQL Server error
>> > >> > message?
>> > >> > Without that information, you are shooting in the dark. I suggest
>> > >> > you
>> > >> > run a
>> > >> > SQL Profiler trace and also include Errors/Exceptions. This will
>> > >> > hopefully
>> > >> > help identify the cause of the error.
>> > >> >
>> > >> > You mention that you restored from backup. Was this a SQL Server
>> > >> > backup?
>> > >> > Did you reinstall SQL Server?
>> > >> >
>> > >> > --
>> > >> > Hope this helps.
>> > >> >
>> > >> > Dan Guzman
>> > >> > SQL Server MVP
>> > >> >
>> > >> > "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in
>> > >> > message
>> > >> > news:1154755197.215422.79810@.75g2000cwc.googlegroups.com...
>> > >> > > Good Morning Friends
>> > >> > >
>> > >> > > I am in real soup. I am new to SQL server 7.0 and Visual basic
>> > >> > > 6.0. I
>> > >> > > have got one application developed by some software agency using
>> > >> > > VB
>> > >> > > 6.0
>> > >> > > and sql server 7.0. Since last 6 years everything worked
>> > >> > > Three days my SQLserver machine crashed because of hard disk
>> > >> > > failure.
>> > >> > > After much effort of two days I restored all the data from the
>> > >> > > backup.In our Application primarily there are two sections
>> > >> > > Members
>> > >> > > and
>> > >> > > Agency. Everything working fine in the Members section i.e
>> > >> > > browsing,
>> > >> > > modification, deletion of records etc. But in the agency section
>> > >> > > only
>> > >> > > browsing of record is working if I want to Edit the record and
>> > >> > > then
>> > >> > > press the save button it gives the error message " Cannot Modify
>> > >> > > Record, Please close the screen and reopen. All changes will be
>> > >> > > lost."
>> > >> > > Actions Taken till now:
>> > >> > > 1. Change the deafult db to "ABC" for the user "CFC" Logging
>> > >> > > into the
>> > >> > > SQLserver. This was the arrangement before crashing.
>> > >> > > 2. Granted the server role "db owner", "db creator" to the user
>> > >> > > "CFC".
>> > >> > > 3. Checked the tables permission of Members section (Where
>> > >> > > Modify is
>> > >> > > working) as well as agency section (Where Modify is not
>> > >> > > working),
>> > >> > > both
>> > >> > > the tables have same kind of permission.
>> > >> > > 4. Tried to get answer on google but of no help.
>> > >> > >
>> > >> > > Please help me urgently.
>> > >> > >
>> > >> > > Thanks
>> > >> > >
>> > >> > > Deepak Sinha
>> > >> > >
>> > >
>|||I downloaded and installed the service pack 3 now my Enterprise Manager
is not starting after giving the previous user name(tre) and
password(****). It is saying "Connection failed check SQL server
registration properties" When I edit the reg. properties by giving
previous user-id and pwd it is saying "cannot open default database
'<ID>' . using master database instead". I tried changing default
database at the command prompt
C:\mssql7\binn>isql -E -d
1>use master
2>go
1>sp_defaultdb tre, insdb
2>go
Default database changed
1>exit
When I go back to Enterprise Manager it is still same. I am in a real
mess.
Pl. Guide.
Deepka
Dan Guzman wrote:
> > except this. I doubt is it because of the service pack 2 ? Can I
> > upgrade it to service pack 3 or 4 or I can uninstall service pack 2.
> I suggest you install SP4 since that's the final service pack for SQL 7.
> Otherwise, you should run the same service pack as the original system.
> That may be the underlying cause of these errors.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
> news:1154857843.655253.136200@.m73g2000cwd.googlegroups.com...
> > Dear Sir
> > I ran the SQL profiler and I got these error messages
> > 1. Error 16821, Severity: 16, state: 1
> > 2. Operating system Error 87., The parameter is incorrect
> > 3. sp_executesql N'UPDATE "INSDB".."INS_M_agency" SET
> > "reg_code"=@.P1,"agen_name"=@.P2,"agen_place"=@.P3,"estb_date"=@.P4,'', ''
> > go
> >
> > When I ran the above SQL statement in the Query Analyzer It is giving
> > Error message "Server: Msg 170, Level 15, State 1, Line 1"
> > " Line 1: Incorrect syntax near 'INSDB'."
> >
> >
> > 4. UPDATE "INSDB".."INS_M_agency" SET
> > "reg_code"=@.P1,"agen_name"=@.P2,"agen_place"=@.P3,"estb_date"=@.P4
> > g0
> >
> > 5. After the hard disk crash at the time of restoration I got this
> > Error message "[SQL-DMO] You must be logged in as 'sa' or a member of
> > sysadmin, or a member of dbcreator" to get rid of this problem I
> > downloaded SQL server Service pack 2 from microsoft site and installed
> > it. After the restoration every other part of the application working
> > except this. I doubt is it because of the service pack 2 ? Can I
> > upgrade it to service pack 3 or 4 or I can uninstall service pack 2.
> >
> > Please guide
> >
> > Thanks
> > Deepak Sinha
> >
> > microsoft . public . sqlserver wrote:
> >> Sir,
> >>
> >> On running SQL profiler with Error/Exceptions included It is showing
> >> "Error: 16821, Severity: 16, State: 1" it is also giving another error
> >> message
> >> "Operating system Error 87., The Parameter is incorrect"
> >> All these error messages in front of the database ID master while my
> >> application is running on the database "ABC"
> >> When I
> >> Dan Guzman wrote:
> >> > > How do I run SQL profiler with Errors/Exceptions included? By
> >> > > "Errors"
> >> > > do you mean those Errors which I am getting in the application i.e
> >> > > "Cannot Modify..." !
> >> >
> >> > The 'Cannot Modify' message is not a SQL Server error message; it is a
> >> > generic message generated by the VB6 application, probably in response
> >> > to a
> >> > SQL Server error. Hopefully, the trace will allow you to identify the
> >> > actual SQL Server error so that you can take corrective action.
> >> >
> >> > I don't have SQL 7 Profiler available but I believe the steps are
> >> > similar to
> >> > SQL 2000 Profiler. There should be an Errors and Warnings event class.
> >> > Include all those events.
> >> >
> >> > --
> >> > Hope this helps.
> >> >
> >> > Dan Guzman
> >> > SQL Server MVP
> >> >
> >> > "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
> >> > news:1154777520.843807.294740@.i3g2000cwc.googlegroups.com...
> >> > > How do I run SQL profiler with Errors/Exceptions included? By
> >> > > "Errors"
> >> > > do you mean those Errors which I am getting in the application i.e
> >> > > "Cannot Modify..." ! If yes How do I include this message in the
> >> > > profiler, becse I do not see there any option for inclusion of my
> >> > > error
> >> > > message. Please guide.
> >> > >
> >> > > Deepak
> >> > >
> >> > > microsoft . public . sqlserver wrote:
> >> > >> Thanks for ur reply Guzman.
> >> > >> 1. Yes It was a SQL server backup
> >> > >> 2. I did not reinstall SQL server .
> >> > >>
> >> > >> I will run a SQL profiler trace and get back.
> >> > >> Thanks again.
> >> > >>
> >> > >> Deepak
> >> > >> Dan Guzman wrote:
> >> > >> > So the application is not reporting the actual SQL Server error
> >> > >> > message?
> >> > >> > Without that information, you are shooting in the dark. I suggest
> >> > >> > you
> >> > >> > run a
> >> > >> > SQL Profiler trace and also include Errors/Exceptions. This will
> >> > >> > hopefully
> >> > >> > help identify the cause of the error.
> >> > >> >
> >> > >> > You mention that you restored from backup. Was this a SQL Server
> >> > >> > backup?
> >> > >> > Did you reinstall SQL Server?
> >> > >> >
> >> > >> > --
> >> > >> > Hope this helps.
> >> > >> >
> >> > >> > Dan Guzman
> >> > >> > SQL Server MVP
> >> > >> >
> >> > >> > "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in
> >> > >> > message
> >> > >> > news:1154755197.215422.79810@.75g2000cwc.googlegroups.com...
> >> > >> > > Good Morning Friends
> >> > >> > >
> >> > >> > > I am in real soup. I am new to SQL server 7.0 and Visual basic
> >> > >> > > 6.0. I
> >> > >> > > have got one application developed by some software agency using
> >> > >> > > VB
> >> > >> > > 6.0
> >> > >> > > and sql server 7.0. Since last 6 years everything worked
> >> > >> > > Three days my SQLserver machine crashed because of hard disk
> >> > >> > > failure.
> >> > >> > > After much effort of two days I restored all the data from the
> >> > >> > > backup.In our Application primarily there are two sections
> >> > >> > > Members
> >> > >> > > and
> >> > >> > > Agency. Everything working fine in the Members section i.e
> >> > >> > > browsing,
> >> > >> > > modification, deletion of records etc. But in the agency section
> >> > >> > > only
> >> > >> > > browsing of record is working if I want to Edit the record and
> >> > >> > > then
> >> > >> > > press the save button it gives the error message " Cannot Modify
> >> > >> > > Record, Please close the screen and reopen. All changes will be
> >> > >> > > lost."
> >> > >> > > Actions Taken till now:
> >> > >> > > 1. Change the deafult db to "ABC" for the user "CFC" Logging
> >> > >> > > into the
> >> > >> > > SQLserver. This was the arrangement before crashing.
> >> > >> > > 2. Granted the server role "db owner", "db creator" to the user
> >> > >> > > "CFC".
> >> > >> > > 3. Checked the tables permission of Members section (Where
> >> > >> > > Modify is
> >> > >> > > working) as well as agency section (Where Modify is not
> >> > >> > > working),
> >> > >> > > both
> >> > >> > > the tables have same kind of permission.
> >> > >> > > 4. Tried to get answer on google but of no help.
> >> > >> > >
> >> > >> > > Please help me urgently.
> >> > >> > >
> >> > >> > > Thanks
> >> > >> > >
> >> > >> > > Deepak Sinha
> >> > >> > >
> >> > >
> >|||Do you get any messages when you access the database?
>isql -E -d
>USE insdb
>GO
>exit
--
Hope this helps.
Dan Guzman
SQL Server MVP
"microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
news:1154869759.625272.196410@.m73g2000cwd.googlegroups.com...
>I downloaded and installed the service pack 3 now my Enterprise Manager
> is not starting after giving the previous user name(tre) and
> password(****). It is saying "Connection failed check SQL server
> registration properties" When I edit the reg. properties by giving
> previous user-id and pwd it is saying "cannot open default database
> '<ID>' . using master database instead". I tried changing default
> database at the command prompt
> C:\mssql7\binn>isql -E -d
> 1>use master
> 2>go
> 1>sp_defaultdb tre, insdb
> 2>go
> Default database changed
> 1>exit
> When I go back to Enterprise Manager it is still same. I am in a real
> mess.
> Pl. Guide.
> Deepka
> Dan Guzman wrote:
>> > except this. I doubt is it because of the service pack 2 ? Can I
>> > upgrade it to service pack 3 or 4 or I can uninstall service pack 2.
>> I suggest you install SP4 since that's the final service pack for SQL 7.
>> Otherwise, you should run the same service pack as the original system.
>> That may be the underlying cause of these errors.
>> --
>> Hope this helps.
>> Dan Guzman
>> SQL Server MVP
>> "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in message
>> news:1154857843.655253.136200@.m73g2000cwd.googlegroups.com...
>> > Dear Sir
>> > I ran the SQL profiler and I got these error messages
>> > 1. Error 16821, Severity: 16, state: 1
>> > 2. Operating system Error 87., The parameter is incorrect
>> > 3. sp_executesql N'UPDATE "INSDB".."INS_M_agency" SET
>> > "reg_code"=@.P1,"agen_name"=@.P2,"agen_place"=@.P3,"estb_date"=@.P4,'', ''
>> > go
>> >
>> > When I ran the above SQL statement in the Query Analyzer It is giving
>> > Error message "Server: Msg 170, Level 15, State 1, Line 1"
>> > " Line 1: Incorrect syntax near 'INSDB'."
>> >
>> >
>> > 4. UPDATE "INSDB".."INS_M_agency" SET
>> > "reg_code"=@.P1,"agen_name"=@.P2,"agen_place"=@.P3,"estb_date"=@.P4
>> > g0
>> >
>> > 5. After the hard disk crash at the time of restoration I got this
>> > Error message "[SQL-DMO] You must be logged in as 'sa' or a member of
>> > sysadmin, or a member of dbcreator" to get rid of this problem I
>> > downloaded SQL server Service pack 2 from microsoft site and installed
>> > it. After the restoration every other part of the application working
>> > except this. I doubt is it because of the service pack 2 ? Can I
>> > upgrade it to service pack 3 or 4 or I can uninstall service pack 2.
>> >
>> > Please guide
>> >
>> > Thanks
>> > Deepak Sinha
>> >
>> > microsoft . public . sqlserver wrote:
>> >> Sir,
>> >>
>> >> On running SQL profiler with Error/Exceptions included It is showing
>> >> "Error: 16821, Severity: 16, State: 1" it is also giving another error
>> >> message
>> >> "Operating system Error 87., The Parameter is incorrect"
>> >> All these error messages in front of the database ID master while my
>> >> application is running on the database "ABC"
>> >> When I
>> >> Dan Guzman wrote:
>> >> > > How do I run SQL profiler with Errors/Exceptions included? By
>> >> > > "Errors"
>> >> > > do you mean those Errors which I am getting in the application i.e
>> >> > > "Cannot Modify..." !
>> >> >
>> >> > The 'Cannot Modify' message is not a SQL Server error message; it is
>> >> > a
>> >> > generic message generated by the VB6 application, probably in
>> >> > response
>> >> > to a
>> >> > SQL Server error. Hopefully, the trace will allow you to identify
>> >> > the
>> >> > actual SQL Server error so that you can take corrective action.
>> >> >
>> >> > I don't have SQL 7 Profiler available but I believe the steps are
>> >> > similar to
>> >> > SQL 2000 Profiler. There should be an Errors and Warnings event
>> >> > class.
>> >> > Include all those events.
>> >> >
>> >> > --
>> >> > Hope this helps.
>> >> >
>> >> > Dan Guzman
>> >> > SQL Server MVP
>> >> >
>> >> > "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in
>> >> > message
>> >> > news:1154777520.843807.294740@.i3g2000cwc.googlegroups.com...
>> >> > > How do I run SQL profiler with Errors/Exceptions included? By
>> >> > > "Errors"
>> >> > > do you mean those Errors which I am getting in the application i.e
>> >> > > "Cannot Modify..." ! If yes How do I include this message in the
>> >> > > profiler, becse I do not see there any option for inclusion of my
>> >> > > error
>> >> > > message. Please guide.
>> >> > >
>> >> > > Deepak
>> >> > >
>> >> > > microsoft . public . sqlserver wrote:
>> >> > >> Thanks for ur reply Guzman.
>> >> > >> 1. Yes It was a SQL server backup
>> >> > >> 2. I did not reinstall SQL server .
>> >> > >>
>> >> > >> I will run a SQL profiler trace and get back.
>> >> > >> Thanks again.
>> >> > >>
>> >> > >> Deepak
>> >> > >> Dan Guzman wrote:
>> >> > >> > So the application is not reporting the actual SQL Server error
>> >> > >> > message?
>> >> > >> > Without that information, you are shooting in the dark. I
>> >> > >> > suggest
>> >> > >> > you
>> >> > >> > run a
>> >> > >> > SQL Profiler trace and also include Errors/Exceptions. This
>> >> > >> > will
>> >> > >> > hopefully
>> >> > >> > help identify the cause of the error.
>> >> > >> >
>> >> > >> > You mention that you restored from backup. Was this a SQL
>> >> > >> > Server
>> >> > >> > backup?
>> >> > >> > Did you reinstall SQL Server?
>> >> > >> >
>> >> > >> > --
>> >> > >> > Hope this helps.
>> >> > >> >
>> >> > >> > Dan Guzman
>> >> > >> > SQL Server MVP
>> >> > >> >
>> >> > >> > "microsoft . public . sqlserver" <dpk.sinha@.gmail.com> wrote in
>> >> > >> > message
>> >> > >> > news:1154755197.215422.79810@.75g2000cwc.googlegroups.com...
>> >> > >> > > Good Morning Friends
>> >> > >> > >
>> >> > >> > > I am in real soup. I am new to SQL server 7.0 and Visual
>> >> > >> > > basic
>> >> > >> > > 6.0. I
>> >> > >> > > have got one application developed by some software agency
>> >> > >> > > using
>> >> > >> > > VB
>> >> > >> > > 6.0
>> >> > >> > > and sql server 7.0. Since last 6 years everything worked
>> >> > >> > > Three days my SQLserver machine crashed because of hard disk
>> >> > >> > > failure.
>> >> > >> > > After much effort of two days I restored all the data from
>> >> > >> > > the
>> >> > >> > > backup.In our Application primarily there are two sections
>> >> > >> > > Members
>> >> > >> > > and
>> >> > >> > > Agency. Everything working fine in the Members section i.e
>> >> > >> > > browsing,
>> >> > >> > > modification, deletion of records etc. But in the agency
>> >> > >> > > section
>> >> > >> > > only
>> >> > >> > > browsing of record is working if I want to Edit the record
>> >> > >> > > and
>> >> > >> > > then
>> >> > >> > > press the save button it gives the error message " Cannot
>> >> > >> > > Modify
>> >> > >> > > Record, Please close the screen and reopen. All changes will
>> >> > >> > > be
>> >> > >> > > lost."
>> >> > >> > > Actions Taken till now:
>> >> > >> > > 1. Change the deafult db to "ABC" for the user "CFC" Logging
>> >> > >> > > into the
>> >> > >> > > SQLserver. This was the arrangement before crashing.
>> >> > >> > > 2. Granted the server role "db owner", "db creator" to the
>> >> > >> > > user
>> >> > >> > > "CFC".
>> >> > >> > > 3. Checked the tables permission of Members section (Where
>> >> > >> > > Modify is
>> >> > >> > > working) as well as agency section (Where Modify is not
>> >> > >> > > working),
>> >> > >> > > both
>> >> > >> > > the tables have same kind of permission.
>> >> > >> > > 4. Tried to get answer on google but of no help.
>> >> > >> > >
>> >> > >> > > Please help me urgently.
>> >> > >> > >
>> >> > >> > > Thanks
>> >> > >> > >
>> >> > >> > > Deepak Sinha
>> >> > >> > >
>> >> > >
>> >
>

Monday, February 13, 2012

AFTER INSERT TRIGGER PLEASE HELP

I need to set up a trigger that updates a field in a record directly
after it is inserted. I have been burning some serious cycles on this
and can't figure it out. Any help would be apreciated.
Here is what I have so far:
CREATE TRIGGER DateMod ON tablename
AFTER INSERT
AS
DECLARE @.RECORDID VARCHAR (20)
SELECT @.RECORDID = SELECT MAX(recordid) FROM tablename
UPDATE field2_newdate SET field2_newdate = (field1_olddate)+1
WHERE recordid = @.RECORDID;
As you can tell by the code, I am a newbie to sql triggers. Because of
this, I will provide a
more detailed explanation of what I am trying to accomplish.
****************************************
********************************
tablename
(before update)This is what the end result should look like
recordid field1_olddate field2_newdate
1 01/01/2000 02/02/2000
****************************************
********************************
Now lets add a record:
recordid field1_olddate field2_newdate
2 01/04/2000
****************************************
*******************************
The trigger should add 1 day to the field1_olddate and set the value of
field2_newdate to 01/05/2000
I need the trigger to add one day to the date in the field1_olddate and
then update field2_newdate in the same record with the new value
directly after the record is submitted.
Please help!
sql trigger newbiesteven@.mindspring.com,
The trigger is executed per statement instead per row, so you have to keep
in mind that the statement could take several rows. Try:
CREATE TRIGGER DateMod ON tablename
AFTER INSERT
AS
UPDATE tablename
SET field2_newdate = (select dateadd(day, 1, i.field1_olddate) from inserted
as i where i.recordid = tablename.recordid)
where exists(select * from inserted as i where i.recordid =
tablename.recordid)
go
AMB
"steven@.mindspring.com" wrote:

> I need to set up a trigger that updates a field in a record directly
> after it is inserted. I have been burning some serious cycles on this
> and can't figure it out. Any help would be apreciated.
> Here is what I have so far:
> CREATE TRIGGER DateMod ON tablename
> AFTER INSERT
> AS
> DECLARE @.RECORDID VARCHAR (20)
> SELECT @.RECORDID = SELECT MAX(recordid) FROM tablename
> UPDATE field2_newdate SET field2_newdate = (field1_olddate)+1
> WHERE recordid = @.RECORDID;
>
> As you can tell by the code, I am a newbie to sql triggers. Because of
> this, I will provide a
> more detailed explanation of what I am trying to accomplish.
>
> ****************************************
********************************
> tablename
> (before update)This is what the end result should look like
> recordid field1_olddate field2_newdate
> 1 01/01/2000 02/02/2000
>
> ****************************************
********************************
> Now lets add a record:
>
> recordid field1_olddate field2_newdate
> 2 01/04/2000
> ****************************************
*******************************
> The trigger should add 1 day to the field1_olddate and set the value of
> field2_newdate to 01/05/2000
> I need the trigger to add one day to the date in the field1_olddate and
> then update field2_newdate in the same record with the new value
> directly after the record is submitted.
> Please help!
> sql trigger newbie
>|||Thank you. You are a GOD! Your code works perfectly. Could you pleas
point me toward a good resource to learn about sql triggers?
Thanks again

AFTER INSERT trigger not firing in SQL 2005

Nothing fancy; just a trigger on a sharepoint table that supposed to
write a record to another SQL table.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER TRIGGER [TV_UpdateFileSyncProgress]
ON [dbo].[Docs]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;

BEGIN
IF EXISTS (SELECT null FROM inserted WHERE DirName like
'csm/%/Shared Documents')

BEGIN
IF NOT EXISTS (SELECT null FROM inserted INNER JOIN
TV_FileSyncProgress fp ON LOWER(RTRIM(fp.LeafName)) =
LOWER(RTRIM(Replace(Replace(inserted.DirName,'csm/',''),'/Shared
Documents','') + '\' + inserted.LeafName)))

BEGIN
INSERT INTO TV_FileSyncProgress (InternalOrigin, ExternalOrigin,
ChangeType, SiteId, DirName, LeafName, FlagForDelete)
SELECT
0,1,1,SiteId,'F:\common\Extranet\',Replace(Replace (DirName,'csm/',''),'/Shared
Documents','') + '\' + LeafName,0 FROM inserted

END

END

END

ENDibrettferguson@.gmail.com wrote:

Quote:

Originally Posted by

Nothing fancy; just a trigger on a sharepoint table that supposed to
write a record to another SQL table.
>
>
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
>
ALTER TRIGGER [TV_UpdateFileSyncProgress]
ON [dbo].[Docs]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
>
BEGIN
IF EXISTS (SELECT null FROM inserted WHERE DirName like
'csm/%/Shared Documents')
>
BEGIN
IF NOT EXISTS (SELECT null FROM inserted INNER JOIN
TV_FileSyncProgress fp ON LOWER(RTRIM(fp.LeafName)) =
LOWER(RTRIM(Replace(Replace(inserted.DirName,'csm/',''),'/Shared
Documents','') + '\' + inserted.LeafName)))
>
BEGIN
INSERT INTO TV_FileSyncProgress (InternalOrigin, ExternalOrigin,
ChangeType, SiteId, DirName, LeafName, FlagForDelete)
SELECT
0,1,1,SiteId,'F:\common\Extranet\',Replace(Replace (DirName,'csm/',''),'/Shared
Documents','') + '\' + LeafName,0 FROM inserted
>
END
>
END
>
END
>
END


Figured it out.

A bug in my win service was deleting the records as they were being
inserted in the destination table.

Neat.

(Today, I would like to own a lawn care business... yes, a lawn care
business. )

After insert trigger exec sp problems

Hi all,

I have an sp that sends cdomail which requires 4 variables.
I want an after insert trigger that fills in the values for the sp from the record just submitted, how can i do that?

Sp code
CREATE PROCEDURE [dbo].[sp_send_cdosysmail]
@.From varchar(100) ,
@.To varchar(100) ,
@.Subject varchar(100)=" ",
@.Body varchar(4000) =" "
/************************************************** *******************

This stored procedure takes the parameters and sends an e-mail.
All the mail configurations are hard-coded in the stored procedure.
Comments are added to the stored procedure where necessary.
References to the CDOSYS objects are at the following MSDN Web site:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_messaging.asp

************************************************** *********************/
AS
Declare @.iMsg int
Declare @.hr int
Declare @.source varchar(255)
Declare @.description varchar(500)
Declare @.output varchar(1000)

--************* Create the CDO.Message Object ************************
EXEC @.hr = sp_OACreate 'CDO.Message', @.iMsg OUT

--***************Configuring the Message Object ******************
-- This is to configure a remote SMTP server.
-- http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_schema_configuration_sendusing.asp
EXEC @.hr = sp_OASetProperty @.iMsg, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusing").Value','2'
-- This is to configure the Server Name or IP address.
-- Replace MailServerName by the name or IP of your SMTP Server.
EXEC @.hr = sp_OASetProperty @.iMsg, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value', 'smtp.bbeyond.nl'

-- Save the configurations to the message object.
EXEC @.hr = sp_OAMethod @.iMsg, 'Configuration.Fields.Update', null

-- Set the e-mail parameters.
EXEC @.hr = sp_OASetProperty @.iMsg, 'To', @.To
EXEC @.hr = sp_OASetProperty @.iMsg, 'From', @.From
EXEC @.hr = sp_OASetProperty @.iMsg, 'Subject', @.Subject

-- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.
EXEC @.hr = sp_OASetProperty @.iMsg, 'HTMLBody', @.Body
EXEC @.hr = sp_OAMethod @.iMsg, 'Send', NULL

-- Sample error handling.
IF @.hr <>0
select @.hr
BEGIN
EXEC @.hr = sp_OAGetErrorInfo NULL, @.source OUT, @.description OUT
IF @.hr = 0
BEGIN
SELECT @.output = ' Source: ' + @.source
PRINT @.output
SELECT @.output = ' Description: ' + @.description
PRINT @.output
END
ELSE
BEGIN
PRINT ' sp_OAGetErrorInfo failed.'
RETURN
END
END

-- Do some error handling after each step if you have to.
-- Clean up the objects created.
EXEC @.hr = sp_OADestroy @.iMsg

GOTry:

CREATE TRIGGER your_trigger_name ON dbo.your_table_name
FOR INSERT
AS

SET NOCOUNT ON

DECLARE @.From varchar(100) ,
DECLARE @.To varchar(100) ,
DECLARE @.Subject varchar(100),
DECLARE @.Body varchar(4000)

SELECT @.From = i.From, @.To = i.To, @.Subject = i.Subject, @.Body = i.Body FROM inserted i

EXEC sp_send_cdosysmail @.From, @.To, @.Subject, @.Body

SET NOCOUNT OFF|||Thanx Man you where really really helpful!|||the best way would be not to do so.
instead store the records in a staging table and then configure a job to send the mails.|||Do you have an example for me?|||Try:

CREATE TRIGGER your_trigger_name ON dbo.your_table_name
FOR INSERT
AS

SET NOCOUNT ON

DECLARE @.From varchar(100) ,
DECLARE @.To varchar(100) ,
DECLARE @.Subject varchar(100),
DECLARE @.Body varchar(4000)

SELECT @.From = i.From, @.To = i.To, @.Subject = i.Subject, @.Body = i.Body FROM inserted i

EXEC sp_send_cdosysmail @.From, @.To, @.Subject, @.Body

SET NOCOUNT OFF

This workes, i used this in an insert an update trigger, now when i insert a new record it fires the insert 1 time and the update 4 times which generates 4 emails when only 1 is the good one,

The triggers are:

Insert trigger

CREATE TRIGGER KRS_email_insert ON dbo.KRS_KRFID
after INSERT
AS

SET NOCOUNT ON

DECLARE @.From varchar(100)
DECLARE @.To varchar(100)
DECLARE @.Subject varchar(100)
DECLARE @.Body varchar(4000)

SELECT @.From = 'Klachtenregistratiesysteem',
@.To = i.email,
@.Subject ='nieuwe melding onder volgnummer '+ cast(i.volgnummer as varchar),
@.Body = '<style type="text/css">
<!--
.style1 {color: #FF0000}
body {
background-color: #FFFFFF;
}
-->
</style>
<p>
<table width="*" border="0">
<tr>
<td colspan="2">Geachte '+M.NAAM+',<br>U heeft een klachtregistratieformulier ingevuld bij het JVH gaming products Klachtenregistratiesysteem, uw klacht is in het systeem opgeslagen onder volgnummer: <span class="style1">'+ cast(i.volgnummer as varchar)+'<br><br><br></span></td>
</tr>
<tr>
<td width="*" bgcolor="#CCCCCC"><div align="right">Onderwerp:</div></td>
<td width="*" bgcolor="#FFFFCC"><div align="left">'+i.onderwerp +'</div></td>
</tr>
<tr>
<td width="*" bgcolor="#CCCCCC"><div align="right">Probleemomschrijving:</div></td>
<td width="*" bgcolor="#FFFFCC"><div align="left">'+i.probleemomschrijving +'</div></td>
</tr>
<tr>
<td width="*" bgcolor="#CCCCCC"><div align="right">Melddatum:</div></td>
<td width="*" bgcolor="#FFFFCC"><div align="left">'+cast(i.melddatum as varchar) +'</div></td>
</tr>
<tr>
<td width="*" bgcolor="#CCCCCC"><div align="right">Evaluatiedatum:</div></td>
<td width="*" bgcolor="#FFFFCC"><div align="left">'+cast(i.evaluatiedatum as varchar) +'</div></td>
</tr>
<tr>
<td width="*" bgcolor="#CCCCCC"><div align="right"></div></td>
<td width="*" bgcolor="#FFFFCC"><div align="left"></div></td>
</tr>
<tr>
<td colspan="2"><div align="right"><br><br><br></div> <div align="left">LET OP: Deze e-mail is verzonden door een automatische mailbox, vragen die u naar deze mailbox stuurt worden niet beantwoord. <br>
Voor vragen of opmerkingen kunt u terecht bij het Niels Beukenex, telefoon: 0900-1793 of via email: <a href="http://links.10026.com/?link=mailto:nbeukenex@.jvh.nl?subject=Vragen en/of info over JVH gaming products BV Klachtenregistratiesysteem">nbeukenex@.jvh.nl</a>. </div></td>
</tr>
</table>
<p> </p>'
FROM inserted i, MAN_MEDEWERKERS m
--WHERE MELDDATUM < GETDATE()and m.uid = i.melder
EXEC sp_send_cdosysmail @.From, @.To, @.Subject, @.Body

SET NOCOUNT OFF

Update trigger

CREATE TRIGGER KRS_email_update ON dbo.KRS_KRFID
After update
AS

SET NOCOUNT ON

DECLARE @.From varchar(100)
DECLARE @.To varchar(100)
DECLARE @.Subject varchar(100)
DECLARE @.Body varchar(4000)

SELECT @.From = 'Klachtenregistratiesysteem',
@.To = i.email,
@.Subject ='Uw melding met volgnummer '+ cast(i.volgnummer as varchar)+' is bewerkt',
@.Body = '<style type="text/css">
<!--
.style1 {color: #FF0000}
body {
background-color: #FFFFFF;
}
-->
</style>
<p>
<table width="*" border="0">
<tr>
<td colspan="2">Geachte '+M.NAAM+',<br>U klacht met volgnummer <span class="style1">'+ cast(i.volgnummer as varchar)+' </span> is gewijzigd, klik <a href="http://links.10026.com/?link=http://pc/Support/KRS_KRFID/ShowKRS_KRFIDRecord2.aspx?KRS_KRFID='+ cast(i.volgnummer as varchar)+'">hier</a> voor meer details<br><br><br></td>
</tr>
<tr>
<td width="*" bgcolor="#CCCCCC"><div align="right">Onderwerp:</div></td>
<td width="*" bgcolor="#FFFFCC"><div align="left">'+i.onderwerp +'</div></td>
</tr>
<tr>
<td width="*" bgcolor="#CCCCCC"><div align="right">Probleemomschrijving:</div></td>
<td width="*" bgcolor="#FFFFCC"><div align="left">'+i.probleemomschrijving +'</div></td>
</tr>
<tr>
<td width="*" bgcolor="#CCCCCC"><div align="right">Melddatum:</div></td>
<td width="*" bgcolor="#FFFFCC"><div align="left">'+cast(i.melddatum as varchar) +'</div></td>
</tr>
<tr>
<td width="*" bgcolor="#CCCCCC"><div align="right">Evaluatiedatum:</div></td>
<td width="*" bgcolor="#FFFFCC"><div align="left">'+cast(i.evaluatiedatum as varchar) +'</div></td>
</tr>
<tr>
<td width="*" bgcolor="#CCCCCC"><div align="right"></div></td>
<td width="*" bgcolor="#FFFFCC"><div align="left"></div></td>
</tr>
<tr>
<td colspan="2"><div align="right"><br><br><br></div> <div align="left">LET OP: Deze e-mail is verzonden door een automatische mailbox, vragen die u naar deze mailbox stuurt worden niet beantwoord. <br>
Voor vragen of opmerkingen kunt u terecht bij het Niels Beukenex, telefoon: 0900-1793 of via email: <a href="http://links.10026.com/?link=mailto:nbeukenex@.jvh.nl?subject=Vragen en/of info over JVH gaming products BV Klachtenregistratiesysteem">nbeukenex@.jvh.nl</a>. </div></td>
</tr>
</table>
<p> </p>'
FROM inserted i, MAN_MEDEWERKERS m
where i.melder = m.uid
EXEC sp_send_cdosysmail @.From, @.To, @.Subject, @.Body

SET NOCOUNT OFF


When a new record is inserted it will fill in the email field en the afdeling field from another table trough 2 other triggers.
After that the insert email trigger should run...

Now it runs the update email trigger 4 times when inserting a new record.
Can someone help me with this

Sunday, February 12, 2012

After export to flat file, all records are in one line, help!?

I created a package that exports contents from a table to a flat file but all my records are being displayed in a single record. where do i configure it to where each record has its own line. the columns in the flat file are fixed.Did you specify a row delimiter? If you did, and specified a LF as the delimiter, you may need to view the file in Wordpad or something. Otherwise, I'd guess there is no row delimiter chosen.|||You should pick fixed width with ragged right for the flat file type if you want a row delimiter, or in line with Phil's suggestions, you can set the column delimiter on your last column to {CR}{LF}.|||THANKS PHIL AND JWELCH, BOTH YOUR INPUT WAS VERY HELPFULL...THINGS ARE WORKING NOW.

After copying a record with an SP all textfields has max lenght

Dear All,

After copying a record using an Stored procedure all textfields (nvarchar)
has max lenght !

See VBA-code and SP below

VBA-code tos execute SP

Dim objcommand As ADODB.Command
Dim intReturnParam As Long
Set objcommand = New ADODB.Command
With objcommand
.CommandType = adCmdStoredProc
.CommandText = "FB_CopyOrder"
.Parameters.Append .CreateParameter("return_value", adInteger,
adParamReturnValue)
.Parameters.Append .CreateParameter("ORD_ID", adInteger,
adParamInput, , Me.ORD_ID)
.Parameters.Append .CreateParameter("ORD_P_ID", adInteger,
adParamInput, , Me.ORD_P_ID)
.Parameters.Append .CreateParameter("ORD_PHTI_ID", adInteger,
adParamInput, , Me.ORD_PHTI_ID)
.Parameters.Append .CreateParameter("ORD_NAME", adWChar,
adParamInput, 50, Me.ORD_NAME)
.Parameters.Append .CreateParameter("ORD_CLIENT_CODE", adWChar,
adParamInput, 50, Me.ORD_CLIENT_CODE)
.Parameters.Append .CreateParameter("ORD_INTERNAL_NOTE", adWChar,
adParamInput, 1024, Me.ORD_INTERNAL_NOTE)
.Parameters.Append .CreateParameter("ORD_REQUESTED_DELIVERY_DATE",
adDate, adParamInput, , Me.ORD_REQUESTED_DELIVERY_DATE)
.Parameters.Append .CreateParameter("ORD_REQUESTED_QUANTITY",
adInteger, adParamInput, , Me.ORD_REQUESTED_QUANTITY)
.Parameters.Append .CreateParameter("ORD_AVAILABLE_QUANTITY",
adInteger, adParamInput, , Me.ORD_AVAILABLE_QUANTITY)
.ActiveConnection = CurrentProject.Connection
.Execute
intReturnParam = .Parameters(0).Value
End With

Stored procedure

Alter Procedure FB_CopyOrder

--List of parameters to be added to the parametercollection of the
ADO-commandobject before executing the command

@.SourceOrderID int,

@.ORD_P_ID int,

@.ORD_PHTI_ID int,

@.ORD_NAME nvarchar(50),

@.ORD_CLIENT_CODE nvarchar(50),

@.ORD_INTERNAL_NOTE nvarchar(1024),

@.ORD_REQUESTED_DELIVERY_DATE datetime,

@.ORD_REQUESTED_QUANTITY int,

@.ORD_AVAILABLE_QUANTITY int

as

declare @.err int

declare @.NewOrderid int

begin tran

-- add new order values = command-parameters

insert into [ORDER] (ORD_P_ID, ORD_PHTI_ID, ORD_NAME, ORD_CLIENT_CODE,
ORD_CREATION_DATE, ORD_INTERNAL_NOTE, ORD_REQUESTED_DELIVERY_DATE,
ORD_REQUESTED_QUANTITY, ORD_AVAILABLE_QUANTITY)

values (@.ORD_P_ID, @.ORD_PHTI_ID, @.ORD_NAME, @.ORD_CLIENT_CODE,
convert(varchar,getdate(),101), @.ORD_INTERNAL_NOTE,
convert(varchar,@.ORD_REQUESTED_DELIVERY_DATE,101), @.ORD_REQUESTED_QUANTITY,
@.ORD_AVAILABLE_QUANTITY)

set @.err = @.@.Error

select @.NewOrderID =SCOPE_IDENTITY()

etc................................."Filips Benoit" <benoit.filips@.pandora.be> wrote in message
news:G3bkc.90727$o73.5680193@.phobos.telenet-ops.be...
> Dear All,
> After copying a record using an Stored procedure all textfields (nvarchar)
> has max lenght !
>
> See VBA-code and SP below
> VBA-code tos execute SP
> Dim objcommand As ADODB.Command
> Dim intReturnParam As Long
> Set objcommand = New ADODB.Command
> With objcommand
> .CommandType = adCmdStoredProc
> .CommandText = "FB_CopyOrder"
> .Parameters.Append .CreateParameter("return_value", adInteger,
> adParamReturnValue)
> .Parameters.Append .CreateParameter("ORD_ID", adInteger,
> adParamInput, , Me.ORD_ID)
> .Parameters.Append .CreateParameter("ORD_P_ID", adInteger,
> adParamInput, , Me.ORD_P_ID)
> .Parameters.Append .CreateParameter("ORD_PHTI_ID", adInteger,
> adParamInput, , Me.ORD_PHTI_ID)
> .Parameters.Append .CreateParameter("ORD_NAME", adWChar,
> adParamInput, 50, Me.ORD_NAME)
> .Parameters.Append .CreateParameter("ORD_CLIENT_CODE", adWChar,
> adParamInput, 50, Me.ORD_CLIENT_CODE)
> .Parameters.Append .CreateParameter("ORD_INTERNAL_NOTE", adWChar,
> adParamInput, 1024, Me.ORD_INTERNAL_NOTE)
> .Parameters.Append
..CreateParameter("ORD_REQUESTED_DELIVERY_DATE",
> adDate, adParamInput, , Me.ORD_REQUESTED_DELIVERY_DATE)
> .Parameters.Append .CreateParameter("ORD_REQUESTED_QUANTITY",
> adInteger, adParamInput, , Me.ORD_REQUESTED_QUANTITY)
> .Parameters.Append .CreateParameter("ORD_AVAILABLE_QUANTITY",
> adInteger, adParamInput, , Me.ORD_AVAILABLE_QUANTITY)
> .ActiveConnection = CurrentProject.Connection
> .Execute
> intReturnParam = .Parameters(0).Value
> End With
> Stored procedure
> Alter Procedure FB_CopyOrder
> --List of parameters to be added to the parametercollection of the
> ADO-commandobject before executing the command
> @.SourceOrderID int,
> @.ORD_P_ID int,
> @.ORD_PHTI_ID int,
> @.ORD_NAME nvarchar(50),
> @.ORD_CLIENT_CODE nvarchar(50),
> @.ORD_INTERNAL_NOTE nvarchar(1024),
> @.ORD_REQUESTED_DELIVERY_DATE datetime,
> @.ORD_REQUESTED_QUANTITY int,
> @.ORD_AVAILABLE_QUANTITY int
> as
> declare @.err int
> declare @.NewOrderid int
> begin tran
> -- add new order values = command-parameters
> insert into [ORDER] (ORD_P_ID, ORD_PHTI_ID, ORD_NAME, ORD_CLIENT_CODE,
> ORD_CREATION_DATE, ORD_INTERNAL_NOTE, ORD_REQUESTED_DELIVERY_DATE,
> ORD_REQUESTED_QUANTITY, ORD_AVAILABLE_QUANTITY)
> values (@.ORD_P_ID, @.ORD_PHTI_ID, @.ORD_NAME, @.ORD_CLIENT_CODE,
> convert(varchar,getdate(),101), @.ORD_INTERNAL_NOTE,
> convert(varchar,@.ORD_REQUESTED_DELIVERY_DATE,101),
@.ORD_REQUESTED_QUANTITY,
> @.ORD_AVAILABLE_QUANTITY)
> set @.err = @.@.Error
> select @.NewOrderID =SCOPE_IDENTITY()
> etc.................................

It looks like you should be using adVarWChar, not adWChar - the data is
being treated as nchar, not nvarchar, so it's being 'padded out' with
spaces.

Simon