SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Query code associated with a table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

samyer
Starting Member

15 Posts

Posted - 03/04/2013 :  10:35:27  Show Profile  Reply with Quote
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

3761 Posts

Posted - 03/04/2013 :  13:48:07  Show Profile  Reply with Quote
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?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 03/05/2013 :  00:01:08  Show Profile  Reply with Quote
or are you referring to trigger code you created on the table?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

samyer
Starting Member

15 Posts

Posted - 03/05/2013 :  10:13:30  Show Profile  Reply with Quote
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?

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 03/05/2013 :  10:17:25  Show Profile  Reply with Quote
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/

Go to Top of Page

MIK_2008
Flowing Fount of Yak Knowledge

Pakistan
1054 Posts

Posted - 03/05/2013 :  10:18:01  Show Profile  Reply with Quote
No

Cheers
MIK
Go to Top of Page

samyer
Starting Member

15 Posts

Posted - 03/05/2013 :  10:37:43  Show Profile  Reply with Quote
Thanks guys!!!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000