| Author |
Topic  |
|
|
samyer
Starting Member
15 Posts |
Posted - 03/04/2013 : 10:35:27
|
| Apologies if this is not the right area to ask this question. Is the script code associated with a table executed when the table is first created or everytime the table is accessed at runtime? |
|
|
James K
Flowing Fount of Yak Knowledge
1500 Posts |
Posted - 03/04/2013 : 13:48:07
|
Not sure what you meant by "script code associated with a table". You would use a script (or the SSMS GUI, which behind the scenes uses a script) to create a table. For example:CREATE TABLE dbo.MyTestTable (id INT, val VARCHAR(32)); You run that script only once - which creates the table object. Once that table object is created, it is there for you to use - you can insert, update, delete, and select data into/from it.
Think of a table as a container that you create. Then you may insert rows into that container, take them out, or look into it or modify them.
If that does not answer your question, can you explain what you meant? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47069 Posts |
Posted - 03/05/2013 : 00:01:08
|
or are you referring to trigger code you created on the table?
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
samyer
Starting Member
15 Posts |
Posted - 03/05/2013 : 10:13:30
|
If I right-click on a table and choose 'Script Table as..', then 'CREATE to', then 'New Query Editor Window' I will see code associated with the table. It appears that the code was used to create the table, and what gets executed when you select EXECUTE. I guess my question is, is this code executed whenever a program accesses the table or updates a table?
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47069 Posts |
Posted - 03/05/2013 : 10:17:25
|
nope..this code was executed when table was first created. When a program accesses a table it executes SELECT,INSERT,UPDATE and DELETE statements (DML operations) and not CREATE (DDL operation)
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
MIK_2008
Aged Yak Warrior
Pakistan
823 Posts |
Posted - 03/05/2013 : 10:18:01
|
No
Cheers MIK |
 |
|
|
samyer
Starting Member
15 Posts |
Posted - 03/05/2013 : 10:37:43
|
| Thanks guys!!! |
 |
|
| |
Topic  |
|