I have this CREATE TABLE statement: - CREATE TABLE howto (
-
id INT IDENTITY(1,1) PRIMARY KEY,
-
title VARCHAR(100) UNIQUE NOT NULL,
-
url VARCHAR(20) UNIQUE NOT NULL,
-
order_on_homepage SMALLINT UNIQUE, --just put an order on this and if it's not null, then its on the homepage
-
CONSTRAINT CK_HOWTO_URL CHECK(url != ''),
-
CONSTRAINT CK_HOWTO_TITLE CHECK(title != '')
-
);
-
GO
I want order_on_homepa ge col to either have a SMALLINT value or a NULL value. However, if there is a SMALLINT value entered, I want those to be unique. In other words, I want to be able to add multiple NULL values in this col, but NOT multiple SMALLINT values. Any suggestions? A check? Thanks!
3 2057 ck9663 2,878
Recognized Expert Specialist
I have this CREATE TABLE statement: - CREATE TABLE howto (
-
id INT IDENTITY(1,1) PRIMARY KEY,
-
title VARCHAR(100) UNIQUE NOT NULL,
-
url VARCHAR(20) UNIQUE NOT NULL,
-
order_on_homepage SMALLINT UNIQUE, --just put an order on this and if it's not null, then its on the homepage
-
CONSTRAINT CK_HOWTO_URL CHECK(url != ''),
-
CONSTRAINT CK_HOWTO_TITLE CHECK(title != '')
-
);
-
GO
I want order_on_homepa ge col to either have a SMALLINT value or a NULL value. However, if there is a SMALLINT value entered, I want those to be unique. In other words, I want to be able to add multiple NULL values in this col, but NOT multiple SMALLINT values. Any suggestions? A check? Thanks!
I think a trigger would be better for this one.
-- CK
Any hints on how to do this? I created a test trigger, but not sure how to go forward, - CREATE TRIGGER test_howto
-
ON howto
-
FOR INSERT
-
AS Print('foo');
-
GO
ck9663 2,878
Recognized Expert Specialist
I did not compile this: - CREATE TRIGGER TRG_HowtO
-
ON HowTo
-
FOR INSERT, UPDATE
-
as
-
begin tran
-
if exists (select 1 from HowTo inner join inserted on HowTo.Order_on = inserted.Order_On)
-
rollback tran
-
else
-
commit tran
-
go
If the value of Order_On you inserted is NULL the exists function will still return false since you can not compare 2 NULLs.
-- CK
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dawnunder |
last post by:
eg.
Someone fills out 3 fields. (There will be more but this is just to
give you an idea)
1. Country?
2. State?
3. City
I want this script to generate a web page and list the people by
|
by: Terry |
last post by:
I have cerated a Form, ExamsFrm, which is used to input details of
exams taken at several Centres. It dosplays details from StudentTbl
and has a SubForm which displays details from ExamsTble.
I have incorporated some VB6 code as well as some Conditional
Formatting. The code automatically updates CheckBoxes in the SubForm,
depending on exam results, and the Conditional Formatting changes
background colours, depending on CheckBox datum.
...
|
by: Richard Hollenbeck |
last post by:
I use a temporary table to assemble unrelated data for specific forms and
reports. After each use of this table, I have a delete query which empties
the table out for its next use.
I have one field I want to populate with the record number as it appears in
the form. That way I can use a comparison with Me.CurrentRecord to change
the background color of the text boxes for the OnCurrent property. I'm
doing this because I want the record...
|
by: Steven |
last post by:
Hi,
I want to create an image that looks exactly the same as the things I see in
my application.
I have an application in which you can create some controls, drag them
anywhere you like.
Now I want to export these controls to an image. The image should reflect
the position of the controls and the controls should look the same in the
picture as they do on the screen.
|
by: Paul Watt |
last post by:
Hi,
i've placed a table within a <div> to dispay some data.
All is well in FF, but in MSIE the table starts inline with the bottom of
the <div> to the left. I've set the css div to vertical align: top, but this
hasn't made a differance.
http://www.paulwatt.info/test/calendar.htm
Thanks guys
| |
by: BrutalByte |
last post by:
I have a report that I would like to apply conditonal formatting to by referencing another table's data. The "NSN" data table is a single column of NSNs. What string do I enter into the Conditional Formatting dialog box to reference the table's entire first column. All I want this to do is turn the referenced NSNs on the report red.
Thanks in advance!
Bryan
|
by: mukesh |
last post by:
Can we use expression in default value for a table field for example –
IIf(Table-1.field-1=table-2 . field-1, table-1.field-2, 0)
Interpretation – If field-1 of table -1 is like/equal to field-2 of table-2 then value of field-1 of table-1 will be the default value other wise 0 will be the default value
Can I use this type of conditional default value if yes please tell me how. I tried to set this expression in default property of a...
|
by: enywu |
last post by:
Hi all,
I have created a report in my access database through a query.
The report has no problem, however now there is new request that they want this report to use the conditional formatting. Whereby the criteria is to be taken from a table.
Is this possible to be done?
For your info, I'm using Access 97.
Any help will be much appreciated.
Thank you.
|
by: dstorms |
last post by:
Hi folks,
I am trying to set up my database to create a new record in one table when a new record is created in another. Since it is a one-to-one realtionship it certainly would be easier to put the data into one table. Originally it was one table, but I split the table to create conditional field-level security (read-only unless one box was unchecked). However I'm trying to fix one flaw in the whole scheme: When a user adds a new record in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |