.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

check or before trigger to dis allow entry of instype = 2 when no instype 1 exists

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

I have a table that holds insurance types 1 -5, these are layered, the person must have type 1 before any other type.  We dont have a front end yet so users enter directly in the table, i would like to create a check constriant so that if a user trys to enter a type 2 and there is no type 1 for the client the record will be kicked out.


Any help appreciated.

View Complete Post

More Related Resource Links

How can I check (true/false) if every single entry in table exists in other table?



I have 2 tables:

- Salesmen with Pk.SalesmenID
- Appointments with Fk.SalesmenID and busy(bit)

How can I check if every salesmen has at least one appointment

Am I on the right way with statement below, though I got syntax problems

(SELECT COUNT(distinct SalesmanID)FROM Appointments)
(SELECT COUNT(SalesmanID) FROM Salesmen)

Is there a way to check if workflow instance already exists for a particular productID in Workflow o

I am using Visual Studio 2008 and .NET 3.5. I am trying to build a WF that is exposed as WCF hosted on IIS. This service is consumed by ASP.NET client. It is a very simple WF- receive info for new product "A"- send email to person 'Xyz' that new prodcut "A" is received- do some business process for product "A"- send out more notifications for product "A"Consider this scenario - - Client hits submit on asp.net page for prodcut "A"- new WF instance is created for product "A"- client can go back to the same page, edit some more info and hit save again. However, this time or for any subsequent "Saves",  I do not want to create a new WF instance for product "A".I can check to see if a WF instance exists for product "A" on the client side before calling the service operation. However, I want to see if there is a way to do this in WF or WorkflowServiceHost, as I don't want to add this logic to client. First acitvity in WF has to be receive activity with CanCreateInstance = true, so not sure how I can do this check in WF itself.Also, I have another stupid question, when using WF exposed as WCF service, do we have to implement all service operations using WF? What if I have some service operations that just involves checking some business logic? Do I implement this in a

LinQ to check if xml node exists in the XML??

Using LinQ or any C# syntax, I just want to know whether "Item" Child exists or not if the parent Node (ChildMenuSelected>>MenuSelected) are true from the below xml format.Xml Format:<MenuDataResult> <Items> <Item> <ItemType>Submenu</ItemType> <ItemTitle>Level22</ItemTitle> <Menu> <MenuSelected>false</MenuSelected> <ChildMenuSelected>false</ChildMenuSelected> </Menu> </Item> <Item> <ItemType>Submenu</ItemType> <ItemTitle>Level21</ItemTitle> <Menu> <MenuSelected>false</MenuSelected> <!--if ChildMenuSelected = true --> <ChildMenuSelected>true</ChildMenuSelected> <Item> <ItemType>Submenu</ItemType> <ItemSubType>0</ItemSubType> <Menu> <!--if MenuSelected = true --> <MenuSelected>true</MenuSelected> <ChildMenuSelected>false</ChildMenuSelected> <!-- whether this below item exists or not --> <Item> <ItemType>Submenu</ItemType> <Menu> <MenuSelected>false</MenuSelected> <ChildMenuSelected

How to check if SPFiled already exists?

hi   I donot know the internal name and cannot use title for retreiving the filed because user can add 2 fields with the same title. Is there anyother option to check if filed already exists?

check user exists in which group

After entering user name, i want check user belonging to which group, group is some thing like role based if group is something group1 , then i want redirect hime to page 1, if groupis 2  then page 2 like that

How check if file exists?

Hello I want to delete file, i can do this but firstly i want to check if it exist. What must i add to  my code for this? DECLARE @del varchar(50) SET @del = REPLACE(' del C:\ADFS\Data_'+CONVERT(char(10),dateadd(year,+1,DATEADD(dd, -1, GETDATE())),103)+'.csv','/','.') EXEC master..xp_cmdshell @del

check if a table exists in SQL 2005

I'm trying to check if a certain table exists in a given database on a SQL 2005 Server. I've tried numerous times without any result.   can anyone point me in the right direction?

Check if custom culture exists

Hello, I created a custom culture using the 'Register' method on the CultureAndRegionInfoBuilder class. But if you execute this method when the culture has already been registered, then an exception will be thrown. So, is it possible to check if the culture is already registered on the machine? Regards, Stefan

check if a url exists

is there a way to check if a url or a website exists?

XMLdocument check if path exists (selectnodes throws "Object reference not set to an instance of an


Normally the code below works, EXCEPT if the xpath doesnt exist, then I get the error "Object reference not set to an instance of an object." on the 2nd line

Dim sessionXML As XmlDocument = Session("XML")
If sessionXML.SelectNodes("//root/data/compare/locations/location") IsNot Nothing Then

How can I check if the xpath exists (without a try catch preferably)?

How to check for file exists on remote server in ssrs 2008?

I have a report that needs to display images that are stored on a remote web server. The problem is that I also need to check if the file exists first otherwise I get those annoying image not found red X's.

I tried entering the code at the bottom in the custom code section of the report which works if I run it on my local machine however it doesn't work in SSRS 2008. After doing a little trial and error I found it seems to be failing on the first line in the function,

Dim request = System.Net.WebRequest.Create(New Uri (fileURL))

Is there some specific permissions or configuration change needed on the SSRS2008 server for this code to work? Or is there a better way to do this?


Public Function CheckRemoteURL(ByVal fileURL As String) As String
Dim request = System.Net.WebRequest.Create(New Uri (fileURL))
request.Method = "HEAD"

Dim returnURL = ""

Dim response = request.GetResponse()
returnURL = fileURL
Catch ex As Exception
returnURL =""
End Try

Return returnURL
End Function

C# How to check prammatically if null value exists in database table (using stored procedure)?


How to programattically check if null value exists in database table (using stored procedure)?

I know it's possble in the Query Analyzer (see last SQL query batch statements)?

But how can I pass null value as parameter to the database stored procedure programattically using C#?

Although I can check for empty column (the following code passes string.Empty as parameter but how to pass null value?), I cannot check for null value in the following code snippet:

SQL Queries:

USE [master]

IF EXISTS (SELECT name FROM sys.databases WHERE name = 'ExampleDatabase')
DROP DATABASE [ExampleDatabase];

CREATE DATABASE [ExampleDatabase];

USE [ExampleDatabase];

DROP TABLE dbo.ExampleTable;

IsActive BIT,


CHeck to see if file exists on Server before backup



  I want to check first to see ifthe xyz.bak file exsits before I perform a backup.



Check to see if record exists befor SQL Insert


I would like to check and see if a record exists before doing an insert. Here is the code I have tried:


Imports System.Data
Imports System.Data.SqlClient
Imports Telerik.Web.UI
Imports System.CodeDom
Imports System.Web
Imports System.Web.Security
Imports System.Web.Security.Roles
Imports System.Web.Security.Membership
Imports System.Security
Imports System.Security.Principal.WindowsIdentity

Partial Class template
    Inherits System.Web.UI.Page
    Private Shared prevPage As String = String.Empty

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If (Not IsPostBack) Then
            prevPage = Request.UrlReferrer.ToString()
        End If
    End Sub

    Protected Sub btn_Volunteer_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim IDProfileVolunteer As String = Session("IDProfileVolunteer")
        Dim IDProfileOrganization As String = CType(FormView1.FindControl("hf_IDProfileOrganization"), HiddenField).Value

        Dim conn As SqlConnection
        Dim cmd As SqlCommand
        Dim strconnection, strsqlinsert As String

        Dim currentUser As MembershipUser = Membership.GetUser()
        Dim currentUserId As Gu

Correct way to check if a SPField exists


Hey all,

I want to create a module I can reuse that will let me pass in a list object and field name to check to see if the column exists. What would be the best way to do this in terms of performance? I've read some things about looping through every field in a list is unnecessary but I'm not sure how else to go about it.

Check if item exists in array



I have a javascript function, in which i have declared an array variable.

var strUsers = new Array("John","Mac","George"); 

The above declaration is for sample and the number of items vary.

How to check, if the particular loggedin user for example: Mac is available in the arraylist.

Thank you


most efficient way to check if a table exists



heys all i was wondering if we do if not exists(select*from information_schema.tables where table_type='base table' and table_name='tbl') is it slower than if not exists(select 1 from information_schema.tables where table_type='base table' and table_name='tbl') because we select less things in the inner query?

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