.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Creating Trigger error

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :Sql Server

I declared for both @begin_time and @end_time as you see, but why do I get an error saying, 

Msg 137, Level 15, State 2, Line 2
Must declare the scalar variable "@begin_time".
Msg 137, Level 15, State 2, Line 6
Must declare the scalar variable "@end_time".


DECLARE @begin_time datetime
DECLARE @end_time datetime
DECLARE @from_lsn binary(10)
DECLARE @to_lsn binary(10)

-- Set the start time for the CDC query to 2 minutes ago
SET @begin_time = DATEADD(MI, -2, GETDATE())

-- Make a change to the Production.Product table
UPDATE Production.Product
SET Name = 'AWC Logo Cap (XL)'
WHERE ProductID = 712

-- Get the end time for the CDC query
SET @end_time = GETDATE()

-- Wait for 10 seconds to allow the CDC process to record the change
WAITFOR DELAY '00:00:10'

-- Map the time intervals to log sequence numbers for CDC
SELECT @from_lsn = sys.fn_cdc_map_time_to_lsn_(
    'smallest greater than or equal', @begin_time

SELECT @to_lsn = sys.fn_cdc_map_time_to_lsn(
    'largest less than or equal', @end_time

View Complete Post

More Related Resource Links

SQL Server 2008 Error creating trigger


I am working in sqlserver 2008 with SP1.  DB mail is setup and works with no issues.  When creating a trigger am getting the following error:

 Msg 14607, Level 16, State 1, Procedure sysmail_verify_profile_sp, Line 42 profile name is not valid

Not sure where this error is comming from.  Thanks in advance for any help.  The code is below: 

CREATE Trigger TR_BLCargo ON BLCargo


CLR Trigger with stored procedures - transaction error

Hi, I've developed sample CLR trigger which call stored procedure but if execution of stored procedure fail I got following exception The context transaction which was active before entering user defined routine, trigger or aggregate "CskTest" has been ended inside of it, which is not allowed. Change application logic to enforce strict transaction nesting. The statement has been terminated.  My trigger [SqlTrigger(Event = "FOR INSERT", Name = "CskTest", Target = "Requirement")] public static void HandleRequirement() { using ( SqlConnection conn = new SqlConnection("Context Connection=true") ) { SqlCommand cmd = conn.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Test"; conn.Open(); try { cmd.ExecuteNonQuery(); } catch ( Exception ex ) { SqlContext.Pipe.Send(ex.Message); } } } I wanna handle this exception in my catch block. How can I do this?

Error when creating a net.tcp endpoint in wcf

I am trying to create a simple wcf service that has a net.tcp endpoint.  My OS is Vista and I am hosting the service in IIS 7.  I have set my default website binding for net.tcp to "9200:*" and added net.Tcp to my Enabled Protocols in my website hosting the service and the default website.  Here is my Config Values:   <system.serviceModel>     <services>       <service name="FirstWcfService.Service" behaviorConfiguration="ServiceBehavior">         <!-- Service Endpoints -->         <endpoint address="" binding="netTcpBinding" contract="FirstWcfService.IService"             bindingConfiguration="tcpbinding"/>         <endpoint address="mextcp" binding="mexTcpBinding" contract="IMetadataExchange"/>         <endpoint address="" binding="wsHttpBinding" contract="FirstWcfService.IService"             />         <endpoint address="mexhttp" binding="mexHttpBinding" contract="IMetadataExchange"/>       </service>     </services>     <behaviors>       <serviceBehaviors>         <behavior name="ServiceBehavior">           <!-- To receive exception details in faults for debugging purposes,                set the value below to true.  Set to false befor

Error creating Web Apps

I am getting the following error when I try and create a Web APP. Error An error occurred while getting information about the user FarmAdmin at server ServeName.com: The network path was not found  Troubleshoot issues with Microsoft SharePoint Foundation. Correlation ID: 6ea31cf3-22bd-4e02-b87b-c1b8a1990ab1 Date and Time: 8/30/2010 2:24:55 PM I have set the logging to verbose The Event logs show nothing. The Sharepoint logs show Provisioning of the web application, null, has encountered the following error: System.InvalidOperationException: An error occurred while getting information about the user FarmAdmin at server ServeName.com: The network path was not found at Microsoft.SharePoint.Win32.SPNetApi32.NetUserGetInfo1(String server, String name)     at Microsoft.SharePoint.Administration.SPManagedAccount.GetUserAccountControl(String username)     at Microsoft.SharePoint.Administration.SPManagedAccount.Update()     at Microsoft.SharePoint.Administration.SPProcessIdentity.Update()     at Microsoft.SharePoint.Administration.SPApplicationPool.Update()     at Microsoft.SharePoint.Administration.SPWebApplication.CreateDefaultInstance(SPWebService service, Guid id, String applicationPoolId, SPProcessAccount processA... 6ea31cf3-22bd-4e02-b87b-c1b8a1990ab1 ...ccount, Str

Error when creating PK to a column which has dupliacte columns..

The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'table name' and the index name 'PK__column__118068EB'. The duplicate key value is (D1).

Error creating Read Item or Read List operation in Sharepoint Designer 2010

In terms of high-level requirements, I need to pull in lists from a couple of different web apps.  To do this, I’m using SPD 2010 to create an External Content Type for the list of interest.  I’m able to create a SOAP Service or WCF Service connection just fine.  However, when I try to create the external content type and create a Read Item Operation on one of the GetList or any other Get* (or other Update methods for that matter) methods, I get the following error:"The method that your operation is based on has parameters with complex types that do not have default parameterless constructor.  This kind of data source methods cannot be used in Business Data Catalog."I tried defining an operation on the “AddAttachment” method, and that worked just fine.  I also tried providing default values to the listName and viewName parameters when creating the SOAP Service connection, but still get the error.  Same issue with a WCF Service connection as well. Does anyone know if this is a 2010 issue, or am I approaching this requirement incorrectly?  What are other approaches for connecting to lists that reside in a different web app than yours? 

Error Creating Site Collection

Hello, I have created a basic claims-based web app in SharePoint 2010. When I try to create a Site Collection, after filling out all the details, I get the following error:   Error  Cannot complete this action. Please try again.  Troubleshoot issues with Microsoft SharePoint Foundation.  Correlation ID: 349b9ae9-7bda-41eb-921a-87974afb289c    I have tried ever which way to try and get it to work, but am still stuck. Any ideas as to why I can't create a Site Collection? Thanks!

Error when creating site collection through programmatically?

hi all, When i am creating SharePoint Site collection through programmatically i am getting an error message. i am using below code...   using (SPSite site = new SPSite("http://servername:7853/")) {   using (SPWeb web = site.OpenWeb()) {   SPWebApplication oweb = web.Site.WebApplication; site.AllowUnsafeUpdates = true;   SPSiteCollection sitecol = oweb.Sites;   SPSite site1 = oweb.Sites.Add("sites/DemoSiteCol", "DemoSiteCol", "Welcome to the Client SiteCol",1033, "STS#0", "Domian\\user", "display name", "user@domian.com");//here i am getting the error message as "Object refernce not set to an instance of an Object". oweb.Update(); } Please tell me why i am getting the error message.... thanks in advance.....

Error in attaching database file and creating a new connection

I am having problem when i was trying to attach .mdf file while create a new connection of SQL server, create a new connection of SQL database file and open the database in Server Explorer. I am using VS 2010 Ultimate and SQL Express 2008 R2.Can anyone please tell me what is the problem I am facing?Here are the error message.1. Attach .mdf in SQL database file and open the database in Server Explorer2. Create a new SQL server and attach .mdf

Error Creating Control - 'asp:UpdatePanelAnimationExtender' could not be set on property 'Animati

It doesn't seem to matter what I try to make the animation do, I keep getting this shown in the designer. No one else on google seems to be getting that problem either. Note: it doesn't cause debugging or runtime issues... in fact, the only negative thing it does is make it extremely annoying when I look at the designer... I'm going to have about 12 of these updatepanelanimations firing everytime the timer ticks too :(. MasterPage file has the toolkitscriptmanager on it. Here is my designer code for the page I'm having the issue on:<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/MasterPage.Master" CodeBehind="TimeLine.aspx.vb" Inherits="TimeLine.WebForm1" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:Timer ID="Timer1" runat="server" Interval="7000"> </asp:Timer> <asp:Panel ID="Panel1" runat="server" Height="285px" HorizontalAlign="Center" Width="970px" BackImageUrl="~/Images/Img.jpg"> <br />

Ajax Control Toolkit Error Creating Control

Error Creating Control - ToolkitScriptManager1Unknown server tag 'asp:ToolkitScriptManager'.Error Creating Control - ComboBox1Unknown server tag 'asp:ComboBox'.I encountered this error, very annoying becasue it would shut off design view rendering of ComboBoxes as well as entire parent containers like ListViews.  It took me a lot of efforts to hunt down the cause, which would seem very illogical if not weird.  So I am suspecting that it is just happening to me, but would appreciate if somebody could care to reproduce and see if it is actually a bug.Cause: HtmlHead title tag has textFix: Delete text in HtmlHead title tagSteps to reproduce and verify error:1. Have AjaxControlToolkit.Binary.NET4 Instructions: http://www.asp.net/ajaxlibrary/act.ashx Download: http://ajaxcontroltoolkit.codeplex.com/releases/view/43475#DownloadId=1165342. Start Visual Studio 2010 Ultimate Open new project ASP.NET Web Application Default name WebApplication13. Keep Default.aspx open Add Ajax Control Toolkit in Toolbox Close Default.aspx4. Add new folder in WebApplication1 Default name NewFolder15. Add new nested master page in NewFolder1 Default name NestedMasterPage1.master Select Site.Master as master page6. Open NestedMasterPage1.master Add ContentPlaceHolder in Content2 Default ID ContentPlaceHolde

MS.IT.SiteDeleteCapture Error When Creating Webs

When I try to create a web in any of my site collections I get the error below.  I have tried deactivating the Feature but it still shows this error.  I tried uninstalling after first seeing this error and it still gave this error. Does anyone know how to fix? and get rid of this tool completely?   Feature '78b94e15-23ce-43f9-8036-babd847497d1' could not be installed because the loading of event receiver assembly "MS.IT.SiteDeleteCapture, Version=, Culture=neutral, PublicKeyToken=98e95e81f8e48206" failed: System.IO.FileNotFoundException: Could not load file or assembly 'MS.IT.SiteDeleteCapture, Version=, Culture=neutral, PublicKeyToken=98e95e81f8e48206' or one of its dependencies. The system cannot find the file specified. File name: 'MS.IT.SiteDeleteCapture, Version=, Culture=neutral, PublicKeyToken=98e95e81f8e48206' at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assembly

Creating assembly throwing an error as system.directoryservices assembly is not in the SQL Server

Hi, I am trying to create an assembly (DLL file that created by C# ) which uses System.DirectoryServices assembly. When I try with following script Create ASSEMBLY Addresstype From 'C:\ActiDirectoryFunctions\ActiveDirectoryFunctions.dll' I am getting following Error Assembly 'ActiveDirectoryFunctions' references assembly 'system.directoryservices, version=, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request. From above error message, I learnt that System.DirectoryServices assembly is not in the SQL Server. I am using SQL SERVER 2005 SP2 and .Net Framework 3 is there in the machine How to manually add this assembly into this SQL Server Machine? Please let me know if you know Thank you, Raj Dreaming a world without any war in anywhere

Creating Database gives error : "Directory lookup for the file "xxxxx.mdf" failed with the operating

Hello FriendsI am creating Database using SQLDMOcode is as follows... Code Snippet SQLServer2Class server = new SQLServer2Class();server.EnableBcp = true;server.Connect(WebConfigurationManager.AppSettings["ServerName"] ,WebConfigurationManager.AppSettings["UserName"],WebConfigurationManager.AppSettings["Password"]);DBFileClass dbFile = new DBFileClass();           dbFile.Name = dbName;          dbFile.PhysicalName = "C:\\" + dbName + ".mdf";          dbFile.Size = 300;          dbFile.FileGrowthType = SQLDMO_GROWTH_TYPE.SQLDMOGrowth_MB;          dbFile.FileGrowth = 25;          dbFile.PrimaryFile = true;          LogFile2Class dbLogFile = new LogFile2Class();          dbLogFile.Name = dbName + "_log";          dbLogFile.PhysicalName = "C:\\" + dbName + "_log.ldf";          dbLogFile.FileGrowthType = SQLDMO_GROWTH_TYPE.SQLDMOGrowth_Percent;          dbLogFile.FileGrowth = 10;          Database2Class newDb = new Database2Class();          newDb.Name = dbName;          newDb.FileGroups.Item("PRIMARY").DBFiles.Add((DBFile)dbFile);          newDb.TransactionLog.LogFiles.Add((_LogFile)dbLogFile);          server.Databases.Add((_Database)newDb); This Code Generates Following Error !!]Microsoft][ODBC SQL Server Driver][SQL Server]Directory lookup for the file "D:\Projects\my_system\mySys

Creating a div by 0 exception error

I have a grid that displays all the years sales cost and billing margin (1-(cost/sales)) but it seems on some years there is a cost but no sale and it is giving me a cannot divide by 0 error on running.    how can i make it where if it cannot give the BM then it will say N/A or something instead of erroring out?   Thanks!

DDL Trigger Question - ADD_ROLE_MEMBER - Error regarding synchronous trigger registration

I am getting the following error when trying to create the DDL trigger below.  Why? Msg 1082, Level 15, State 1, Procedure DDL_tr_wb_Add_DB_Role_Member, Line 7 "ADD_ROLE_MEMBER" does not support synchronous trigger registration. Create Trigger DDL_tr_wb_Add_DB_Role_Member ON DATABASE FOR ADD_ROLE_MEMBER AS DECLARE @data XML SET @data = EVENTDATA() Insert Into Security_Audit ( PostTime, LoginName, UserName, [HostName], [Application], [Event], [Command] ) VALUES ( GETDATE(), -- The time of the event CONVERT(nvarchar(100), SYSTEM_USER), -- Current Login CONVERT(nvarchar(100), CURRENT_USER), -- The database user against whose session the event occurred CONVERT(nvarchar(20), HOST_NAME()), -- The workstation name CONVERT(nvarchar(100), APP_NAME()), -- Application name of the current session @data.value('(/EVENT_INSTANCE/EventType)[1]', 'nvarchar(100)'), -- The type of event @data.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'nvarchar(2000)') -- The Transact-SQL command that comprised the event ) Thanks,   Dave

Error while creating Termstore using Object Model

Hi, I'm creating term store Group using object model using the below mentioned code:- string TermStore = drManagedMetadataGroups["Term Store"].ToString(); string GroupName = drManagedMetadataGroups["Group Name"].ToString(); string Description = drManagedMetadataGroups["Description"].ToString(); string GroupManagers = drManagedMetadataGroups["Group Managers"].ToString(); string Contributors = drManagedMetadataGroups["Contributors"].ToString(); try { //Type importManagerType = typeof(ImportManager); //Type[] parameterTypes = new Type[1] { typeof(TermStore) }; //ConstructorInfo constInfo = importManagerType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, CallingConventions.ExplicitThis, parameterTypes, null); //if (constInfo != null) //{ TaxonomySession session = new TaxonomySession(web.Site); TermStore ts = session.TermStores[TermStore]; //ts.AddTermStoreAdministrator(@"test-account-01\d39373g"); //logger.LogToOperations(string.Format("Added managed metadata group administrator '{0}' to '{1}'", GroupName, TermStore), EventLogEntryType.Information); if (!M
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend