Anyone hit this one before?
SELECT *
INTO #tempTable
FROM dbo.ProdTable
WHERE 1 = 0
INSERT #tempTable
SELECT --list of values from other tables; column count matches
TRUNCATE TABLE dbo.ProdTable
INSERT...
Hi, all.
I'm making the switch to 2005 (yea!) and am looking for one or two good reference books (budget).
Any suggestions? Any I should rule out?
< M!ke >
I can say nothing, which is cowardly, I can lie, which is immoral, or I can tell the truth, which will upset people. - Tiki Barber
I have several legacy DTS packages which I am managing through the Package Designer add-in with SQL Server Management Studio. I am able to edit Properties in these packages EXCEPT for the Properties of the main workflow step. Attempting to do so causes the Package Designer to lock up, with my...
Search is broken, so I don't know if we've gone here before.
Lately, I've taken notice of some unusual and, I'm sure often, unintended phrases in signage. Here are a few. What are some of your favorites?
Sign...
...outside a chiropractor's office: "Trying to get pregnant? We can help!"...
>.
Some Words of Wisdom my baby sister has finally recognized:
1. Do not walk behind me, for I may not lead. Do not walk ahead of me, for I may not follow. Do not walk beside me either. Just pretty much, leave me alone.
2. The journey of a thousand miles begins with a broken fan belt and...
I'd like to lead off with one (of thousands) of my favorite(s):
To which I always want to add something like:
Okay, Word Police! Let's hear 'em!
< M!ke >
I am not a hamster and life is not a wheel.
I know how to do this the hard way; looking for something a bit less labor-intensive (SQL Server 2000).
I can get a list of all stored procedures on the current database like this:
SELECT Routine_Name
FROM Information_Schema.Routines
WHERE (Routine_Type = 'Procedure'...
I'll be replacing the following with a DateAdd(DateDiff()) method...
DECLARE @datetime DATETIME
SET @datetime = '7/5/2007 11:59:59 PM'
-- so what day is it?
SELECT CAST(CAST(@DateTime AS INTEGER) AS DATETIME)
-- and what time of day? on what day?
SELECT CAST(@DateTime - CAST(@DateTime AS...
If the CFO rules, as appears to be the driving force in most organizations, then the cost of business software development (BSD) has to be offset by a Return On Investment (ROI) generated by the end product.
I have seen BSD projects fail for the following reasons (not inclusive or in any...
I have a table that looks like this:
ID ReferenceNo IDtype
123456789 555-1111 EIN
234567890 555-1111 ITN
345678901 555-1111 SSN
456789012 555-2222 EIN
567890123 555-3333 SSN
The same reference number can have one or more IDtypes. What I want to do is to...
I've got a database (2000) with 12 tables - one for each month (rolling 12).
I've got an ugly gob of dynamic SQL to get the job done of totalling for the last 12 (loop through temp table with tablenames + processed flag), but would LOVE to replace it with non-dynamic SQL.
Any ideas? I mean...
Sometimes, ya just gotta deal with bad design.
Case in point: I needed to get data which is stored in "monthly" tables. To make it even worse, some of the "monthly" tables have "monthly" columns. Take a look at the result set at the bottom to see examples.
Anyway, here's a block of code I...
Before I attempt an update or delete, I always check to see if the primary key exists and, if not, return a message to that effect. For example:
IF EXISTS (SELECT PrimaryKey FROM dbo.TableName WHERE PrimaryKey = @InputParam)
--transaction wrapper removed for brevity...
BEGIN...
We have a bunch of tables with an 'S_' prefix and I wanted to get the identity columns for them so I ran this:
SELECT o.name AS [Table Name]
, c.name AS [Column Name]
FROM sysobjects o
JOIN syscolumns c
ON o.id = c.id
WHERE o.type = 'U'
AND COLUMNPROPERTY(o.id, c.name...
Hi, all.
I'm setting up a table in our database to store pertinent data concerning stored procedures to aid with code reuse during development and to assist in future maintenance.
Here's the table structure:
CREATE TABLE dbo.SPlog
(
pkID int IDENTITY
...
Seems like these things always come up on Fridays!
I've been tasked with implementing transactional processing for a particularly nasty set of nested stored procedures. There's one entry-point procedure that calls 12 others, each of which does a bunch of calculations and then inserts or...
Hi, all.
Our dev team had a bit of a heated discussion about when to use output values, return parameters and rasierror messages in stored procs for a new project. Naturally, I figured I'd just ask the pros!
So, at the risk of opening a huge can of worms, what do you all think? Is there...
Why oh why do I try to write code after 4pm on Fridays?
I've got a 3-column UserCustomerContact table:
userID customerID contactID
------ ---------- ---------
me 1 1
me 1 2
me 1 3
When I run this:
DECLARE...
One of the requirements for my current assignment is that all development be set up in a version control software package (ClearCase, not that it really matters). I've been told this is to include stored procedures (???).
This is a first for me. I've always relied on nightly backups, but that...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.