Showing posts with label step. Show all posts
Showing posts with label step. Show all posts

Thursday, March 29, 2012

Adding a step to CreateUserWizard

Hey all,

I'm working in Visual Web Developer 2005 Express. I'm a total newb so please bare with me. I'm trying to add a step to my CreateUserWizard that I put in using the automatic site administration utility. I've added a wizard step in between the "Sign up for your new account" step and the "complete" step. The purpose of the new step is to collect additional information about the user. I've added a FormView control and used an SQLDataSource to link it to a new table in the database established by the administration utility, and set up the templates to recieve the data.


The one kink in the process seems to be associating the UserID created in step one with the additional information submitted in step 2. I made a UserID column, of data type uniqueidetifier in my new table and set up a foreign key relationship with the UserID columns in the aspnet_Membership table and the aspnet_Users table. When I run it as is I get the following error after I try to insert the data entered in the second step (additional information) into my new database table:

Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query

I guess my question is:How do I take the UserID generated in step 1, and pass it into the new table and into the new row being created in step 2? If possible, I would like to do it without any code (haha probably not going to happen, but worth a shot) but any assistance anyone could offer would be greatly appreciated. Thanks everyone.

Matt Downey

You can grab the userID like this

Membership.GetUser(CreateUserWizard1.UserName).ProviderUserKey

where createuserwizard1 is the ID of the 1st step of your wizard.

Sunday, March 11, 2012

Add step to JOB that checks to see if Maintenance Plan X is running

Hi All,
How can I add a step to a job that will check to see if a maintenance
plan is running? If it is, don't run the rest of the job, but if it
isn't run the rest of the job.
Thanks!
KiranYou could look at the job state:
http://www.replicationanswers.com/Downloads/KillRunningJobs.txt
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .

Add step to JOB that checks to see if Maintenance Plan X is running

Hi All,
How can I add a step to a job that will check to see if a maintenance
plan is running? If it is, don't run the rest of the job, but if it
isn't run the rest of the job.
Thanks!
Kiran
You could look at the job state:
http://www.replicationanswers.com/Downloads/KillRunningJobs.txt
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .

Add step to JOB that checks to see if Maintenance Plan X is running

Hi All,
How can I add a step to a job that will check to see if a maintenance
plan is running? If it is, don't run the rest of the job, but if it
isn't run the rest of the job.
Thanks!
KiranYou could look at the job state:
http://www.replicationanswers.com/D...RunningJobs.txt
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .

Saturday, February 25, 2012

Add indexed view will suppress the after trigger to get fired.

Problem: Add indexed view will suppress the after trigger to get fired.
Step to Reproduce:
Create TableA, TableB, TableC and TableD with after trigger in each one.
TableA is parent table for TableB with Foreign key Cascade Delete.
TableB is parent table for TableC with Foreign key Cascade Delete.
TableC is parent table for TableD with Foreign key Cascade Delete.
Test Case 1.
Delete from TableA
TableA, TableB, TableC, and TableD's After delete trigger will get fired cor
rectly.
Test Case 2.
Add indexed view in TableC
Delete from TableA
TableA, TableB, and TableD's After delete trigger will get fired correctly
but miss TableC's After trigger.
If anyone has any suggestion, that will be appreciated.
----
--
-- Sample sql
----
--
-- Clean Out
IF OBJECT_ID (N'[dbo].[TableC_VW]') IS NOT NULL
DROP View [dbo].[TableC_VW]
GO
IF OBJECT_ID (N'TableD') IS NOT NULL
DROP TABLE TableD
GO
IF OBJECT_ID (N'TableC') IS NOT NULL
DROP TABLE TableC
GO
IF OBJECT_ID (N'TableB') IS NOT NULL
DROP TABLE TableB
GO
IF OBJECT_ID (N'TableA') IS NOT NULL
DROP TABLE TableA
GO
Create TABLE TableA
(
ID int not null,
dummy1 varchar(20) null default 'dummy1',
dummy2 varchar(20) null default 'dummy2',
dummy3 varchar(20) null default 'dummy3',
CONSTRAINT [PK-TableA_-ID] PRIMARY KEY CLUSTERED ( [ID] )
)
GO
CREATE TRIGGER [dbo].[TableA_Delete]
ON [dbo].[TableA]
AFTER DELETE
AS
begin
print 'Trigger TableA_Delete'
end
GO
Create TABLE TableB
(
ID int not null,
TableAId int null,
dummy1 varchar(20) null default 'dummy1',
dummy2 varchar(20) null default 'dummy2',
dummy3 varchar(20) null default 'dummy3',
CONSTRAINT [UK-TableB-ID] Unique ( [ID] ),
CONSTRAINT [FK-TableB-TableAId_TableA-ID]
FOREIGN KEY ( [TableAId] ) REFERENCES [TableA] ( [ID] ) ON DELETE CASCADE
)
GO
CREATE TRIGGER [dbo].[TableB_Delete]
ON [dbo].[TableB]
AFTER DELETE
AS
begin
print 'Trigger TableB_Delete'
end
GO
Create TABLE TableC
(
ID int not null,
TableBId int null,
dummy1 varchar(20) null default 'dummy1',
dummy2 varchar(20) null default 'dummy2',
dummy3 varchar(20) null default 'dummy3',
CONSTRAINT [PK-TableC-ID] PRIMARY KEY CLUSTERED ( [ID] ),
CONSTRAINT [FK-TableC-TableBId_TableB-ID]
FOREIGN KEY ( [TableBId] ) REFERENCES [TableB] ( [ID] ) ON DELETE CASCADE
)
GO
CREATE TRIGGER [dbo].[TableC_Delete]
ON [dbo].[TableC]
AFTER DELETE
AS
begin
print 'Trigger TableC_Delete'
end
GO
Create TABLE TableD
(
ID int not null,
TableCId int null,
dummy1 varchar(20) null default 'dummy1',
dummy2 varchar(20) null default 'dummy2',
dummy3 varchar(20) null default 'dummy3',
CONSTRAINT [PK-TableD-ID] PRIMARY KEY CLUSTERED ( [ID] ),
CONSTRAINT [FK-TableD-TableCId_TableC-ID]
FOREIGN KEY ( [TableCId] ) REFERENCES [TableC] ( [ID] ) ON DELETE CASCADE
)
GO
CREATE TRIGGER [dbo].[TableD_Delete]
ON [dbo].[TableD]
AFTER DELETE
AS
begin
print 'Trigger TableD_Delete'
end
GO
----
-- Test 1 Delete from TableA without indexd view schema binding which case t
he TableC After delete trigger has fired.
----
Print 'Delete from TableA without indexd view schema binding which case the
TableC After delete trigger has fired.'
Set NoCount On
Insert Into TableA (ID) values(1)
Insert Into TableB (ID, TableAId) values(1,1)
Insert Into TableC (ID, TableBId) values(1,1)
Insert Into TableD (ID, TableCId) values(1,1)
delete from TableA
----
-- Test 2 Delete from TableA with indexd view schema binding which case the
TableC After delete trigger has not fired.
----
Print 'Test 2 Delete from TableA with indexd view schema binding which case
the TableC After delete trigger has not fired.'
Insert Into TableA (ID) values(1)
Insert Into TableB (ID, TableAId) values(1,1)
Insert Into TableC (ID, TableBId) values(1,1)
Insert Into TableD (ID, TableCId) values(1,1)
IF OBJECT_ID (N'[dbo].[TableC_VW]') IS NOT NULL
DROP View [dbo].[TableC_VW]
GO
CREATE VIEW [dbo].[TableC_VW] WITH SCHEMABINDING
AS
SELECT TableBId, C.Dummy1, C.Dummy2, C.Dummy3
FROM [dbo].TableC C inner join [dbo].TableB B on B.ID = B.TableAId
WHERE TableBID Is Not Null
GO
CREATE UNIQUE CLUSTERED INDEX [IX_TableC_VW]
ON [dbo].[TableC_VW] (TableBID, Dummy1,Dummy2,Dummy3)
Go
delete from TableA
----
----Notes:
Sql 2000 sp4 get this trouble.
Sql 2005 is good without this issue.

Thursday, February 9, 2012

Actual execution plan vs Estimated execution plan

The benefit of the actual execution plan is that you can see the actual number of rows passing through each step - compared to the estimated number of rows.

But what about the "cost percentages" ?

I believe I've read somewhere that these percentages is still just an estimate and is not based on the real execution.

Does anyone know this and preferable have a link to something that documents it?

ThanksThe cost percentages is what let you know if you need to change table placement in JOINS or use index to improve performance. The information you are looking is in SQL Server Profiler in Management Studio or Enterprise Manager. You use the Profiler to find duration of SQL statements and more. Run a search for Profiler in SQL Server BOL (books online). Hope this helps.