create a view and add a constaint that only permit update when the time is sunday 2 pm -…
Jump to turn (12)
- 1create a view and add a constaint that only permit update when the time is sunda
- 2how to fix create view must be the only statement in the batch error
- 3SELECT cOrderNo FROM OrderDetail HAVING SUM(mToyCost) > 80 GROUP BY cOrderNo inc
- 4SELECT FROM Orders WHRER cOrderNo IN ( SELECT cOrderNo FROM OrderDetail GROUP BY
- 5ALTER VIEW myview1 ADD CONSTRAINT CHECKUPDATETIME CHECK( DATEPART(week,GETDATE()
- 6ALTER VIEW myview1 ADD CONSTRAINT CHECKUPDATETIME CHECK( DATEPART(week,GETDATE()
- 7ALTER VIEW myview1 ADD CONSTRAINT CHECKUPDATETIME CHECK( DATEPART(week,GETDATE()
- 8ALTER VIEW myview1( ADD CONSTRAINT CHECKUPDATETIME CHECK( ) incorrect syntax nea
- 9it does not work still get syntax error
- 10how to insert records into a new table,that the records seleted from other table
- 11modify foreign key reference ,reset delete reference
- 12修改Toybrand表和Toys表外键列的参照方式,将‘删除‘的参照方式改为’置空’。
- User
create a view and add a constaint that only permit update when the time is sunday 2 pm - 4pm
- Assistant
Assuming you have a table named
my_tablewith a column namedmy_columnthat you want users to update only during Sundays between 2pm and 4pm, you can create a view and add a constraint using the following SQL code:codeCREATE VIEW my_view AS SELECT * FROM my_table; ALTER VIEW my_view ADD CONSTRAINT check_update_time CHECK ( DATEPART(dw, GETDATE()) = 1 AND -- Sunday DATEPART(hh, GETDATE()) BETWEEN 14 AND 16 -- 2pm - 4pm );This creates a view named
my_viewthat selects all rows from , and then adds a constraint named that checks the current day of week ( checks if it's Sunday) and current hour ( checks if it's between 2pm and 4pm) before allowing an update to happen.