SQLStudies
Archives: February 2013
Insert multiple values sets into a table in one command
The INSERT command has two distinct ways to load data into a table.
INSERT INTO Table (field1, field2) VALUES ('string1','string2')
And
INSERT INTO Table (field1, field2) SELECT field1, field2 FROM Table2
Both of these are very handy and have been around as far back as I can remember. Historically you… Read more
0 comments, 225 reads
Posted in SQLStudies on 28 February 2013
DROP and CREATE vs ALTER
When writing a script to change a piece of code, say a stored procedure or view, there are 3 basic options. I’ll start at the outset by saying I use all 3 and that they each have their pluses and minuses. I’m not trying to advocate one or another, just… Read more
10 comments, 2,639 reads
Posted in SQLStudies on 25 February 2013
Multiple instances, single query window
Anyone who has been reading my blog for a while should realize that several divisions in my company have been merging together. This means that there are lots of new tasks and processes to learn. It also means that I’m finding uses for several features of SQL and SSMS that… Read more
0 comments, 216 reads
Posted in SQLStudies on 18 February 2013
Something to watch out for when using sp_rename on Stored Procedures, Functions and Views
For those who don’t know, the stored procedure sp_rename allows you to change the name of a user-created object. Basically when you use sp_rename it changes the name of an object in the catalog tables. Unfortunately on a stored procedure, function or view this isn’t the only place the name… Read more
1 comments, 855 reads
Posted in SQLStudies on 11 February 2013
EXECUTE, not required, but advisable.
The other day one of the developers I work with gave me a script similar to this:
BEGIN TRAN sp_rename 'tablename.columnname', 'newcolumnname' COMMIT
He was getting the error:
Msg 102, Level 15, State 1, Line 2 Incorrect syntax near 'tablename.columnname'.
Now most of you probably realize that had he just… Read more
0 comments, 194 reads
Posted in SQLStudies on 6 February 2013
Duplicate rows in a table
I recently got the following email:
“I just keyed in two rows into a table with all identical column values. How do I get rid of just one of them?”
Now even way back when in the dark ages when I started as a database developer I ran into this… Read more
10 comments, 2,397 reads
Posted in SQLStudies on 4 February 2013



Subscribe to this blog