Archived Months
January 2003
March 2003
April 2003
May 2003
June 2003
July 2003
August 2003
September 2003
October 2003
November 2003
December 2003
January 2004
February 2004
March 2004
April 2004
May 2004
June 2004
July 2004
August 2004
September 2004
October 2004
November 2004
December 2004
January 2005
February 2005
March 2005
April 2005
May 2005
June 2005
July 2005
August 2005
September 2005
October 2005
November 2005
December 2005
January 2006
February 2006
March 2006
April 2006
May 2006
June 2006
July 2006
August 2006
September 2006
October 2006
November 2006
December 2006
January 2007
February 2007
March 2007
April 2007
May 2007
June 2007
July 2007
August 2007
September 2007
October 2007
November 2007
April 2008
all groups > sql server programming > april 2007 > threads for tuesday april 24

Filter by Day: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Make Trigger update a specific row and not all of them?
Posted by apax999 NO[at]SPAM gmail.com at 4/24/2007 10:14:27 PM
This is SQL Server 2005... I have the following Trigger. I need it to update the field specified in the code (Total_Credits) by the amount of School_Credits inserted. Trigger works, but when I insert a new row it is updating EVERY row for every Client, it should only be updating one Client/...more >>


Creating an Audit Database
Posted by R C at 4/24/2007 8:02:05 PM
hi, I have a database and i want to enable auditing. I've read (not always about MS SQL) that a second database can be created easily that audits the original database using triggers. For instance, if there is a table named "Tree" and i need to delete a record in tree, a record would be ins...more >>

Need help in a query
Posted by SqlBeginner at 4/24/2007 5:18:02 PM
Hi All, This is my existing query and i have given below the output sample as well. btw I am using SQL Server 2005. Select field1, field2, Sum(A) as A, Sum(B) As B, '1 : ' + convert(varchar(20),convert(decimal(8,2),NULLIF(sum(B),0)) / convert(decimal(8,2),NULLIF(sum(A),0))) as C From (...more >>

how to select every "n"th row from an ordered dataset?
Posted by Rich at 4/24/2007 3:58:03 PM
My table contains 100 rows of data that was collected every 10 seconds. The datetime is recorded along with other information. I want to retrieve every 6th row from this table - that would be the row at each minute interval. How to accomplish this? pseudo code here select * from mytbl...more >>

Getting the maximum value of a datatype
Posted by Caitlin at 4/24/2007 2:55:05 PM
Is there any system function in SQL Server 2005 that would return the maximum possible value of an int? (I know that it's 2147483647; I'm looking for a way to avoid pasting in that number.) (What I'm trying to do, by the way, is run a comparison between two positive integer values that might...more >>

Log Ship
Posted by CLM at 4/24/2007 2:54:04 PM
I have four 2000 SP4 databases that I need to move tonight to a different drive on the same server. Can I leave the log shipping intact when I do this? If so, how? Or do I need to delete out the log shipping and then add it back in?...more >>

Backup Question
Posted by John Wright at 4/24/2007 2:52:57 PM
I am running SQL Server 2000 on Server 2003. I have a good backup regiment in place. I do a full backup at midnight every day, then every hour I do a transaction log backup. My network backup then picks up the backups and we store them in an archive. Also, I pick up the files in a nightly ...more >>

Any drawbacks to creating linked servers?
Posted by Jiho Han at 4/24/2007 2:13:29 PM
Once upon a time, I asked a DBA if he would create a linked server so I can easily access a remote server from SQL. He recommended against doing so asking me to find an alternate approach. His reasoning was something to the effect of a failure cascading into the local server. Something like...more >>



Searching for columns in views
Posted by wnfisba at 4/24/2007 1:34:01 PM
We have a situation where we have to expand a primary key field. We want to do full analysis and understand any foreign keys that might be affected by this as well. That would entail searching views as well. Does anyone have a script where I can search a column name against all the defin...more >>

function (like sp_helpText) to view table script?
Posted by VMI at 4/24/2007 1:20:09 PM
Does SQL Server have a function (similar to sp_helpText) where I can view the CREATE TABLE script for a particular table? Thanks. ...more >>

Attaching database
Posted by jim at 4/24/2007 1:14:02 PM
Hello, I'm attempting to upgrade from MSDE 1.0 to MSDE 2000. However, before removing MSDE 1.0, a database apparently was not properly detached before attempting to attach (using sp_attach_db not attach w/ single file) this very database to MSDE 2000. The following error is rec'd: "C...more >>

EXEC SP inside a SELECT?
Posted by Thunder at 4/24/2007 1:10:56 PM
Hi all, Is it possible to execute a stored proc with an OUTPUT param inside a select statemement? I have a need to do this becuase functions will not work here. You will notice the " EXEC uspf_MEDIAN_CLOSE_DAYS" towards the bottom of the example. Thanks. /*Example:*/ CREATE PROCEDUR...more >>

Restore with File Group
Posted by Ed at 4/24/2007 1:06:00 PM
Hi, I have a database that I created two file groups. One is called Primary (d drive) and another is called Secondary (e drive). I think it can increase the performance with better I/O. I put 10 tables into the Secondary File Group. I am wondering what would happen when I restore a ...more >>

if statement
Posted by gv at 4/24/2007 1:01:41 PM
Hi all, Is there a more effient way to write this? IF @status = 'ALL' BEGIN SELECT A.COL1 A.COL2 ETC.... from @salesTemp end IF @status = 'Active' BEGIN SELECT A.COL1 A.COL2 ETC.... FROM @salesTemp WHERE A.status = 'Active' END IF @status...more >>

substring and replace
Posted by brian at 4/24/2007 12:34:02 PM
I cannot get the syntax to work for me. I have a string like this: 2828^Edmonton 9889^Danvers etc. I need to extract everything to the right of the carat (^). I've tried this: RIGHT(description,CHARINDEX('^',REVERSE(description))-1) and a variant using the substring but cannot get ...more >>

Restore database sql2000
Posted by Franck at 4/24/2007 10:48:32 AM
ok i manage to make a Vbscript that do in order : - Backup DeeBee (database name) from production server it make a full of it - Copy over network to development server - Restore the database there (Database already exist just replace) here's the vbs (name of servers and path where remove inte...more >>

Create complete datetime
Posted by Mark Goldin at 4/24/2007 10:21:26 AM
I have a time value. How can I build a complete datetime value from it? Thanks ...more >>

Suggestion: Tables used for reporting
Posted by SqlBeginner at 4/24/2007 9:38:01 AM
Hi All, I would like to know what are the things one should consider for getting optimum performance in this scenario. 1. If we have tables which are going to be used only for "Report" generation purpose and it doesn't involve in any front end transactions. 2. Once in a week or so these...more >>

Q: Data model change -> recompile all SP?
Posted by Art at 4/24/2007 9:20:02 AM
I have just inherited a DB in which data model needs to change. Lot's of SPs are already written, applications use them. What's the best way to go about this change? There is over a 100 SPs and Functions written. I'd hate to have to thru all of them open/look[edit]/compile ... room for er...more >>

Alter Table from SQL Management Studio
Posted by Leonard at 4/24/2007 8:30:12 AM
I am trying to use the script table feature on Management Studio and the ALTER TABLE is disabled, is there anyone who has an idea how to enable it or why it is disabled? Thanks...more >>

sp_helpdb slow response time
Posted by nd98powell NO[at]SPAM gmail.com at 4/24/2007 7:03:14 AM
Hello. I'm running the command sp_helpdb on a SQLServer 2005 database and it is taking 15 seconds to respond. What is making this SP take so long? Is there a way to make it perform better? The reason I'm running the command is to determine the names of all databases on the server. Is t...more >>

Integrated Security
Posted by Arne Garvander at 4/24/2007 6:52:01 AM
integrated Security= true or Integrated Security=SSPI Does the above mean the same thing in a connection string? -- Arne Garvander (I program VB.Net for fun and C# to get paid.)...more >>

find a duplicated name and sum de result
Posted by Pedro at 4/24/2007 6:38:02 AM
Hi all, I have this query. Select VO.idOperation,G.Description AS Group,VO.Active, count(VO.idOperation) as tot from TB_ViaturOperation VO INNER JOIN TB_Groups AS G ON VO.Group = G.CODGroup Where VO.idOperation = 10000014 GROUP BY VO.idOperation,G.Description,VO.Active Result :...more >>

SQL Server Data compare across data types
Posted by bbcrock NO[at]SPAM gmail.com at 4/24/2007 6:31:31 AM
I imported 60 tables with 50k rows from DBASE III to MS SQL Server. In doing so we converted many data types from int, numeric and others to real, float, smallint, etc. We experienced some rounding issues. We also experienced problems with positional notation (ie, columns switched). I download...more >>

Any suggestions on how to do this
Posted by Maurice at 4/24/2007 5:54:01 AM
Hi there, I hope someone has any ideas how to handle the next situation. I've got a table and need to insert data in a field which will consist of the following: Department (let's say 900) than I need to add the current year. So far no problem. But I need to add a sequenatial number start...more >>

inner join difference between on condition and where condition
Posted by gsganesh at 4/24/2007 3:49:33 AM
Hi There, Is there any difference between the two sql, in terms of result, performance .. SELECT MEMBER_BROKER.BR_CODE AS Expr1, * FROM MEMBER inner JOIN MEMBER_BROKER ON MEMBER.[PLAN] = MEMBER_BROKER.PLAN_ID where MEMBER_BROKER.BR_CODE = 'SBKR' SEL...more >>

SQL Select statement to retrieve last 12 or so values matching a criteria
Posted by RB0135 at 4/24/2007 2:15:56 AM
Hi, Is there a way of retrieving the last 12 (or 15 or 20, or any number) of values from a column/s that match a certain criteria from a record easily (or built into SQL 2000 or SQL 2005)??? Something like select last 12 games where Played = true and week < 16 Is this simple, or am I g...more >>

SQL needed
Posted by Ahmed Hashish at 4/24/2007 12:00:00 AM
Dear All I have a table with fields SensorCode (nvarchar), TDate (datetime), = and Value (float) If the value exceeds 300 the sensor considered violates the rules. I need sql statment to get the SensorCodes that have Values over 300 and = violation duration The result should be l...more >>

user logon action (SqlS2k)
Posted by yapann at 4/24/2007 12:00:00 AM
best / simplest way to detect user logon event (to perform some db action )in SqlS2000? thx ...more >>

Flattening Tables
Posted by bob at 4/24/2007 12:00:00 AM
Hi, I had a need to extract a customer’s phone number(s) from a child table and attach them as a string onto the end of an existing ( SQLServer7 ) SPROC’s output. i.e. Alter the sproc so that it also produced the phone numbers for each customer (parent) row. I got the impression fro...more >>

Sql 2005 err 233 ?
Posted by perspolis at 4/24/2007 12:00:00 AM
Hi all I have this problem when connecting to sql 2005 : A connection was successfully established with the server, but then an error occurred during the pre-login handshake. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Serv...more >>

SP - insert statement error
Posted by Agnes at 4/24/2007 12:00:00 AM
create table #CursorRVPV (docid nvarchar(10) not null,docno char(20) not null,cocode nchar(10) not null,paidinvamt decimal(9,2) not null,paidbaseamt decimal(9,2) not null,reportid nvarchar(50) not null) INSERT INTO #CursorRVPV (docid,docno,cocode,paidinvamt,paidbaseamt,reportid) SELECT doc...more >>

How to debug a SP per remote SQL 2005?
Posted by Andreas Klemt at 4/24/2007 12:00:00 AM
Hello, is there an easy documentation how to debug a stored procedure with remote on SQL 2005? I tried everything and I get always the error message "DCOM error. Check firewall". I opened all ports but I still get this message. Please help me. Thanks in advance! Andreas ...more >>


DevelopmentNow Blog