Groups | Blog | Home


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
August 2008
all groups > sql server programming > january 2005 > threads for wednesday january 12

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 31

Bug in SQL Server 2000
Posted by filtermyspam NO[at]SPAM yahoo.com at 1/12/2005 9:42:46 PM
Hi all, I'm having an issue with the following code in SQL Server 2000, SP3a (@@VERSION reports 8.00.818). I was hoping somebody else can confirm this (esp somebody from Microsoft). -------------------------------------------- create proc sptest as insert into #tbltest exec('select 1') ...more >>


What is the best way to query for used foreign key
Posted by Tedy Pranolo at 1/12/2005 9:30:51 PM
Let's say I have table Customers and Orders. I want to let the users to be able to change the Customer record (name, address), as long as the customer has never made an order. In other word as long as that particular CustomerID doesnt exists in the Orders table as a foreign key. So I need a q...more >>

Questions regarding Table variables vs temp tables
Posted by Kevin NO[at]SPAM test.com at 1/12/2005 6:58:11 PM
2 questions: 1) Until very recently, I thought that table variables were always stored in memory, whereas temp tables were stored in tempdb - so the method for the former resulted in better performance. However, some information on MSDN made me wonder...the link is... http://support.micro...more >>

MIN() + MAX() Deadlock ?
Posted by eval at 1/12/2005 6:37:38 PM
Hi guys The only difference between the following 2 queries... Select min(GpsDate) minTime, max(GpsDate) maxTime From TblAvlTrans Where UnitID = '1720200022285010001407' Select min(GpsDate) minTime, max(GpsDate) maxTime From TblAvlTrans with (nolock) Where UnitID = '172020002228...more >>

Cross Database Trigger
Posted by Ashkan Daie at 1/12/2005 6:26:24 PM
Hi All, I have a trigger that does a cross database insert. Is there a way to optimize cross database transaction performance? It takes about 16 times longer to write to a table on another database (on the same SQL Server instance) than it does to write to the same table structure on the lo...more >>

UDF problems
Posted by Carl Howarth at 1/12/2005 6:04:55 PM
Hello there, I am using the same UDF in a select query, with differing parameters, for example: SELECT A.Something, dbo.fnFunction(A.Field1, A.field2, 'ChangingParameter1') AS Answer1, dbo.fnFunction(A.Field1, A.field2, 'ChangingParameter2') ...more >>

JOINING ON ENTIRE ROWS?
Posted by Carl Howarth at 1/12/2005 5:59:42 PM
Hello there, I am trying to write trigger that basically inserts a record into an activity history table with relevant user details, record IDs etc. I have this working which is fine, but I want to put a check in to determine if any details have changed during the update so that I am not a...more >>

Search a String with in Stored Procedure List
Posted by DMP at 1/12/2005 5:49:22 PM
Hi, How can i Search a string ("ABC") with in All Stored procedures in a Database ? Thanks, ...more >>



Procedure or function XXX has too many arguments specified???
Posted by Lacka at 1/12/2005 5:12:40 PM
Hi, I have an sp, that worked till now good. Then I gave two more parameters, and now I get the error message in my application: Procedure or function XXX has too many arguments specified. The sp has now 46 parameters. Is it too much? How many parameters can an sp have? Another sp of the sa...more >>

2005 speciality? - Wrong result from DatePart( Week,xxx )
Posted by Einar Næss at 1/12/2005 5:04:04 PM
When I execute this in QueryAnalyzer I expect to get the current WeekNumber according to Norwegian (ISO) rules: set language norwegian set datefirst 1 select GetDate() as TodayDate, DatePart( Week, GetDate() ) as TodayWeekNumber Result: 2005-01-12 16:24:52.450 3 Since last yea...more >>

Normalization insanity
Posted by John Spiegel at 1/12/2005 4:36:54 PM
Hi all, I'm wrestling with a new system design and am looking for opinions on where to draw the line with normalizing the database. I'm in early design and proof-of concept so have started with a very broken out set of data. I have identified a number of cases where a many-to-many situation ...more >>

how to ouput dbcc checkdb into a file or table
Posted by SQL Apprentice at 1/12/2005 4:32:54 PM
Hello, Is there a way to output the result of dbcc checkdb into a file or table? I am trying to send an email to users when there is an error found in dbcc checkdb. Any ideas? Thanks again ...more >>

Assigning dbo to objects without typing the "dbo."
Posted by galenboyerdev NO[at]SPAM hotpop.com at 1/12/2005 3:34:21 PM
Is there anyway to login with SQLServer authentication and issue the following ddl statement: create table some_table (id integer) go and have it owned by dbo, (that is without having typed "dbo.") Thanks. -- Galen Boyer...more >>

SQL-DMO SystemObject
Posted by Hardcoded SQL hater at 1/12/2005 3:31:06 PM
Does anyone know how SQL-DMO determines when a Database object has a true SystemObject property? Or can anyone point me to a script that programmatically determines if a database is a system database? I have had no success looking in system tables and system stored procedures short of sp_d...more >>

SQL Parent/Child Select
Posted by John Baird at 1/12/2005 3:15:05 PM
I have a table that contains a number of items. Each record has a primary Key and a Foreign Key to itself representing a parent/child relationship. For example: pkey fkey title 1 null Line 1 2 1 Line 2 3 1 Line 3 4 2 line 4 5 2 line 5 6 4 line 6 etc... What I have spent a long tim...more >>

Collation problem
Posted by Rob Meade at 1/12/2005 2:46:09 PM
Hi all, Ahh, the on going saga of moving databases... Ok - having installed SQL Server 2000 on the new server and copied across approximately 10 database I've since learnt that we did NOT use the default collation on the original server, instead we have case sensitive, accent insensitive...more >>

Log stored proc. errors to SQL log or Event Log
Posted by vickie hoffmann via SQLMonster.com at 1/12/2005 2:39:53 PM
I have 2 stored procedures that are launched through ADO calls in a LabView application. When an error occurs in one of the procedures, I have no way of knowing this, since I can't see the errors through the ADO. Is there a way to force any errors that occur in a stored procedure to be logged? I've ...more >>

Conditional Insert
Posted by Munch at 1/12/2005 1:39:11 PM
I am provided a txt file every month. I need to append records from this txt file to a table, but I only want to insert those records that are non existing already in the table. For example: TABLEA Extract_Date Emp_id Name Status_CD Status_Start_Date Status_end_Date 20040...more >>

truncate log file
Posted by Ed at 1/12/2005 1:35:10 PM
Hi, After I backup the log file, the log file size is down from 1GB to 100MB, I would like to know what is the syntax to truncate the physical file as well. I mean to release about 900 MB back to the operating system. Thanks Ed ...more >>

Randomly Slow Stored Procedure
Posted by fbwhite NO[at]SPAM online.nospam at 1/12/2005 1:35:06 PM
I have a sproc that has a complex select statement consisting of many joins and some joins over Linked Servers. The sproc takes about 45 seconds to run the first time in query analyzer and then 1 second subsequent calls. This would be fine if it only happened when the sproc got changed, but ...more >>

check constraints and null values
Posted by Benjamin Strautin at 1/12/2005 1:29:07 PM
Regarding check constraints, Books Online has this to say: "A CHECK constraint specifies a Boolean (evaluates to TRUE or FALSE) search condition that is applied to all values entered for the column; all values that do not evaluate to TRUE are rejected." However, in SQL Server 2000, at least...more >>

CAST char to date on Japanes server
Posted by Meir at 1/12/2005 1:13:37 PM
Hello, I'm using the following statement to add 1 day to the current date and get the result with time 00:00:00 SELECT CAST(CONVERT(char(12), DATEADD(d,1,GetDate()),1) as smalldatetime) When running this statement on a Japanese server I get an error telling that it can't convert a char to s...more >>

Select from a table passed as variable ?
Posted by Chris V. at 1/12/2005 1:10:09 PM
Hi, I'm tryning to exceute some select on some table which I want to pass a variable (a follow) DECLARE @MyVar sysname SET @MyVar = 'Test' SELECT * FROM @MyVar. Each time I get '@MyVar' is nt declared'. If I do the following : DECLARE @MyVar sysname DECLARE @Statement varchar(25...more >>

Update statement performance decreases in stored proc
Posted by Hugo Kornelis at 1/12/2005 1:04:59 PM
Hi all, I'm having some trouble finding out why an update statement that runs in less than 2 seconds from Query Analyzer takes no less than 24 minutes when in a stored procedure. Here are the important parts of the stored proc: CREATE PROC MyProc AS -- Create temp table, fill it with start...more >>

sp and DNS
Posted by a at 1/12/2005 12:49:55 PM
Hi, Anyone know if it is possible (anything's possible??) to perform reverse dns lookup in a stored proc (or scheduled job if easier??) ie convert a passed IP address to hostname?? Thanks for thinking about this if you did... Arth ...more >>

xml data output in text format
Posted by John at 1/12/2005 12:27:02 PM
i have one column in the table have xml data. i want output in plain text format. which procedure or function is the best. Thanks, John...more >>

T-SQL Question
Posted by dfate at 1/12/2005 12:02:21 PM
Got a question for y'all. In the code below @status is being passed into a proc. If it's 6 I don't want the condition in bold (event.status) to evaluate at all (select all Status'). Other than putting an if around the whole thing and splitting out two different statements is there any other ...more >>

Require real value in calculation
Posted by Umar at 1/12/2005 11:47:07 AM
SELECT 22/7 results 3. I need a real value like 3.1428571..... I tried following too: SELECT CAST(22/7 AS DECIMAL(10,7)) and DECLARE @TEMP_NR DECIMAL(10,7) SET @TEMP_NR = 22/7 SELECT CAST(@TEMP_NR AS DECIMAL(10,7)), @TEMP_NR No luck so far. ...more >>

Select to get date of previous Friday
Posted by shop NO[at]SPAM pacifictabla.com at 1/12/2005 11:23:36 AM
Hi: In code I am using this: DECLARE @WeekEndingVar datetime SELECT @WeekEndingVar = '12/7/2005' SELECT DISTINCT @WeekEndingVar AS WeekEnding, ....... ______________________________ To assign a week ending date. Basically, the 2nd line needs to be replaced with something that fig...more >>

wildcard search and empty strings
Posted by Ned Radenovic at 1/12/2005 11:09:25 AM
Hi, I'm trying to test whether one value is in another by using the like clause and concatenating the wildcard character to a variable. My code looks like this: declare @name varchar(20), @name2 varchar(20) select @name = 'test', @name2 = 'testing' if @name2 like '%' + @name + '%' ...more >>

Distinct character in a field
Posted by Munch at 1/12/2005 11:01:04 AM
Is there a way to query a field to determine the unique charcters in that given field. For example: COLUMN1 apple bat car The query should return a p l e b t c r Thanks...more >>

Problem using 'NOT IN' with varchar
Posted by DCraig at 1/12/2005 10:38:00 AM
I'm setting up DTS jobs to move data from a legacy system to SQL Server 2000 and getting what I think are incorrect results from the insert. The insert checks to see if one field (hp_number) exists in the current table, and if not it should insert the record, but the 'NOT IN' doesn't seem to b...more >>

memory leak/sp_xml_removedocument
Posted by Michael Zdarsky at 1/12/2005 10:35:03 AM
Hello, we know that one of our sp runs into an error due to an corrupt xml doc. The problem is, in that case we can not call sp_xml_removedocument to release the xmldoc handle. Is there a way to release this handles without closing the connection? E.G. save the hande in a table than re...more >>

Stored Procedure with Multiple conditions
Posted by Drew at 1/12/2005 10:33:37 AM
I am using Access to report out of my SQL Server database. I am building stored procedures and then using them for the reports. Everything is working fine, but I have hit a snag. I need to build a report to show employee information. I have the following SP, CREATE PROCEDURE spEmpInfo ...more >>

stored proc to access multiple databases
Posted by Andy at 1/12/2005 10:27:01 AM
I will try and explain my situation the best I can. Here it goes. Due to the size of our data we have it partitioned into separate databases for each year. Every so often we update the view structure and want to keep the structure the same across all databases. I have a procedure created t...more >>

Appending Data from Table to Another on one row
Posted by Edward F at 1/12/2005 9:47:09 AM
Hello All, I have so far come up with a partial solution . but it's far from complete. Using the Cursor Object In SQL Server . It allows me to loop through the records in the Table and insert them into another Table.The only problem is that I want all my records to be on one row in the dest...more >>

Transactions.
Posted by Sam Davis at 1/12/2005 9:25:03 AM
Does anyone remember if their is a limit to the number of nested transactions SQL 2000 can reach? I was thinking it was 32 but that may be just stored procedures....more >>

xp_sendmail question
Posted by Mark Siffer at 1/12/2005 9:06:37 AM
I have stored files in an image field of a table. Can I use xp_sendmail to email them? MS ...more >>

Text Manipulation in DTS Package
Posted by Space Junk at 1/12/2005 9:03:04 AM
I have a tbale that is getting copied via a DTS package from one server to another, straight copy. I need to modify it about so it can do this. Source table contains a column with a URL, that will somtimes contain a URL in this format "http://ourserver/course/ECON101-12345. Not all URLS are ...more >>

SQL Server to Access
Posted by Anthony Nystrom at 1/12/2005 8:37:01 AM
this may seem to be a strange question.... Since its the inverse which is the popular implementation.... Our app runs against SQLSERVER, yet we are creating a demo of the app for which we will be using Access. Does anyone know of a way to recreate as much as possible our sqlserver db as an acc...more >>

Extracting index's as script
Posted by Anthony Nystrom at 1/12/2005 8:23:02 AM
Is there anyway rather than manually extracting all index's as a script so that they can be created elsewhere? Thanks, Anthony Nystrom...more >>

Fixing up if-statement block
Posted by Spencer23 at 1/12/2005 8:17:04 AM
Hey, Could someone fix up this if-statement block for me, or tell me what is wrong with it, I am sure it is simple, but can't seem to get it working correctly? IF @Requestor='All' then select @s=@s+','+requestor from requests set @Requestor = substring(@s,2,len(@s)) ELSE IF @Client='...more >>

using SQLserver, ADO, Delphi: performance issue
Posted by Joe Hatem at 1/12/2005 7:57:45 AM
We have been considering using SQLserver as the backend for a large business application developed in Delphi. We intelinked an ADOconnection, an ADOtable and a DBgrid. The table is about 200,000 records. No matter what options we enabled or disabled on the ADOconnection or the ADOtable, the M...more >>

how to convert 'if...else...' to CASE
Posted by Hank at 1/12/2005 7:53:08 AM
My current system was designed under Perl, there're formulas for fee calculation just like: IF(ANA<500000000) (ANA*(125/10000)/DIY*DIM) ELSE (0 ) + IF(ANA>500000000 AND(ANA<1000000000)) ((500000000*(125/10000))/DIY*DIM + ((ANA-500000000)*(120/10000))/DIY*DIM) ELSE (0 ) means : 1st $500mm Av...more >>

Enumerations in databases
Posted by Aayush Puri at 1/12/2005 7:49:05 AM
I have a table in the database in which the fields in one of the columns (say status) needs to have a value which present in a pre-defined set of possible values. (suppose I have defined that status can only be "running", "walking" ,"sleeping"). What is the best method to store the set of pos...more >>

Tree order
Posted by Stijn Verrept at 1/12/2005 7:36:39 AM
I have the following table: Create table #Tree (TR_ID int, TR_Parent int) insert into #tree (TR_ID, TR_Parent) VALUES (1, NULL) insert into #tree (TR_ID, TR_Parent) VALUES (2, NULL) insert into #tree (TR_ID, TR_Parent) VALUES (3, NULL) insert into #tree (TR_ID, TR_Parent) VALUES (4, 1) ins...more >>

update statement in a trigger
Posted by Rodger at 1/12/2005 6:57:05 AM
I have this update statement in a trigger for insert / update , I fire the update statement following the trigger code and it gives me a error, i am not sure if the update statement is right update AtsAnnuityCurrentValues set mnyPersonalReserveRemaining = inserted.mnyPersonalPreTaxRese...more >>

User-defined variables in a where clause - bug??
Posted by ilo at 1/12/2005 6:27:05 AM
I have some strange effects occuring within a sub-query that I have created. I have a table of information that I wish to collapse subject to a datetime cuttoff, so I have used the code: select type1, type2, sum(amount) from table where [date] <= @date having defined @date...more >>

How to get Date portion of DateTime field?
Posted by GaryZ at 1/12/2005 6:13:02 AM
I'm trying to import an SQLServer table into Visual FoxPro (I'll also post this in the VFP forum). I need to test the Date portion of a SQL Server DateTime field against a user-entered Date. I tried the following: m_getagsc = SQLPREPARE(gnConnHandle, "SELECT * FROM AgentStateChange "+; ...more >>

Query performance MS-Access vs. SQL-server 2000
Posted by Marco Lorenz at 1/12/2005 5:05:03 AM
I am evaluating SQL server and therefore I made a benchmark comparing the search speed between Access (which we are using up to now) and SQL-Server. I created 2 identical tables on the same Server, once as Access database file, once in SQL-Server with one Counter as Primary Key and Index and...more >>

T-SQL Debugger
Posted by Rafa® at 1/12/2005 5:03:02 AM
I'm in a problem with T-SQL Debugger.. I'm DBA on a development environment... Most users use Query Analyzer to Debug procs, and some machines work, and anothers not... The problem is the following... The permissions are ok (EXECUTE on sp_sdidebug, dbo of the current Database)... The Debug...more >>

Putting commas between select statement values
Posted by Spencer23 at 1/12/2005 4:19:04 AM
Hello, This may be a strange request, but I am going to ask about it anyways. Say for example if I have a table named TEST and in the table there is a column named NUMBERS, such that it is like this: NUMBERS 1 2 3 4 How could I use a select statement in a way that a comma would sep...more >>

Insert Fails into a table on linked server database
Posted by Gokhan Akcam at 1/12/2005 1:51:04 AM
select, update and delete Ok. But when I want to insert a value into a table Msgs 7343 returns and operation fails. Source and linked servers are SQL Server and are linked by OLE DB Provider For SQL Server. Thanks in advance...more >>

which statement fire the trigger ?
Posted by TLV at 1/12/2005 12:27:38 AM
Hi , Is there any way to get the sql statement that fire a trigger ? Thank you in advance , TLV ...more >>

MAX function
Posted by gg.20.brunft NO[at]SPAM spamgourmet.com at 1/12/2005 12:22:43 AM
Hi, i've a simple question (guess it's simple) regarding the MAX function in MS SQL Server 2000. I'll use the example of the according help topic (http://msdn.microsoft.com/library/en-us/tsqlref/ts_ma-mz_3h6g.asp?frame=true) cause it's very similar to my problem ... USE pubs GO SELECT MAX...more >>


DevelopmentNow Blog