Quick SQL Server Tip – Creating your Insert Stored Procedure

When I start to create the insert stored procedure for an existing database table I used to always start by copying an existing stored procedure (for the template only purpose) and then empty the contents of the stored procedure, then I would right-click on the table and then select, script table as ‘Insert’ from the menu options as shown below:-

Insert into a table

This template always kind of annoyed me as I felt it never laid it out very well, only last week did someone point out that the best thing to do is to actually just type inside your stored procedure:-

INSERT INTO and then press Enter

This will generate the insert and also tell you the column types and sizes for variables such as varchar(s) as shown below, including putting in default dates.

Insert syntax

That’s it for now.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s