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 2004 > threads for monday april 5

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

Query optimizer question
Posted by Florian Ion at 4/5/2004 9:46:46 PM
Hi, we have a very strange behavior of SQL Server that we try to understand. We have the following Select statement: SELECT DISTINCT TOP 100000 Customer.id FROM Customer LEFT JOIN CustomerAddress CA ON Customer.idDefaultAddress=CA.id WHERE 1=1 and Customer.id IN ( select idCustom...more >>


CASE Question
Posted by mozHD at 4/5/2004 8:46:03 PM
Is it possible to do something like the example below? Is the syntax correct CASE OrderMetho WHEN 0 THEN 'Fax', 'Email WHEN 1 THEN 'Telephone EN Because 0 is actually equal to both 'Fax' and 'Email'. Thanks in advance, moz...more >>

Fast export/import
Posted by Yannis Makarounis at 4/5/2004 8:27:12 PM
I am looking for a way to export a few million records from a MS SQL Server DB and subsequently import them into a similar table in another DB. This should all be done in code. Is there a specific strategy for this in order to happen as fast as possible? I can use either ADO or SQLDMO. Thanks...more >>

Random records (with logic)
Posted by Luke at 4/5/2004 8:26:57 PM
Hi, I need to extract randomly 5 records from the table "Questions". Now I use SELECT TOP 5 FROM Questions ORDERBY NEWID() And it works. The problem is that I need an additional thing: if SQL extracts record with ID=4, then it should not extract record with ID=9, because they are similar....more >>

CHECK CONSTRAINTS
Posted by LEA at 4/5/2004 8:16:07 PM
NEED TO CREATE A CONSTRAINT THAT SPECIFIES THAT VALUES TO BE ENTERED IN A COLUMN ARE A, B, C, D, F OR NULL. tHE NAME OF THE COLUMN IS GRADE....more >>

SELECT inside an INSERT
Posted by John Smith at 4/5/2004 5:14:29 PM
i wanna something like this: INSERT INTO Employes (id) VALUES ( (SELECT TOP id from Employes) + 1 ) any help wi welcome TIA ...more >>

date comparioson in a Case statement
Posted by ajmister at 4/5/2004 4:03:17 PM
Hi I have a case statement where I am comparing two dates rpt_dt= case when ex.e_dt < a1.d_dt then "NA" else e_dt end, give me an error Syntax error during implicit conversion of VARCHAR value 'NA' to a DATETIME field. rpt_dt= case when ex.e_dt < a1.d_dt then "" else ...more >>

Suppressing error messages
Posted by Plamen Doykov at 4/5/2004 3:47:15 PM
Hi I have a stored procedure where I want to handle all errors and return something. Although when, say, an insert violates the integrity, the standard error message is displayed. Is there any way of suppressing it? This is the piece of code; there is a 'nocount on' in the beginning INSERT...more >>



Very Tricky SELECT statement
Posted by Stewart Saathoff at 4/5/2004 3:00:31 PM
Hey Everyone, I have a very tricky select statement that I need help with. I have a table that contains orders and order details. I want to retrieve the last detail record from every unique order that was placed. The last record is known by the exact date and time that it was ordered. ...more >>

SQL 6.5 Installation
Posted by Jeff W at 4/5/2004 2:56:03 PM
SQL 6.5 Server Installation on Win NT 4.0 Server with Service Pak 6.0. SQL 6.5 installs & sticks at the end on "Indexing Files". The MSSQL Sub Directory is created & Master.Dat is there, but no SQL 6.5. Is this a problem with istallation on a newer computer with old 6.5 software ? Is there a pr...more >>

Limiting the number of duplicate rows returned to three
Posted by Hasan Kachal at 4/5/2004 2:47:39 PM
Hello everyone: We have a sweepstake database. One of the rules is that they can only enter three times. But some people have entered a dozen times or so. I want to do a query that will return a maximum of three rows per name, address and zip collumns. Is there a way to do this? Thank...more >>

Stored Procedure use Like statement;
Posted by Lin Ma at 4/5/2004 2:41:47 PM
I am a newbie in SP. Does anyone know what is the command for SQL statement Like? Instead of user =, I would like to use the Like in SQL statement. Such as: ..... where Location like '%Location%' I just do not know how. Thanks. Here is my SP: CREATE PROCEDURE [dbo].[getCustomerList] (...more >>

Statement Execution Order
Posted by Jeff S at 4/5/2004 2:21:18 PM
When a stored procedure that contains multiple DML statements (e.g, 3 UPDATE statements) is executed, are they DML always executed in the order in which they appear in the stored procedure? ...more >>

Updating recordset
Posted by P Bull at 4/5/2004 2:14:46 PM
Hi I am trying to get data from a SQL2000 table plus a variable field into a recordset which is held in a stored procedure. My code in VB runs the SP and hold the data in a disconnected recordset. I then want to, depending on logic, update the variable field with data and then output. Th...more >>

Find out what is using a function ?
Posted by Phil396 at 4/5/2004 1:57:46 PM
Is there a way to find out how many sp and udf are using a certain udf in a database. If the function I am changing is only being used in one place there will not be a problem. However, if the function is being used in other places there might be a problem. ...more >>

'And' not filtering in Join clause
Posted by Steve at 4/5/2004 1:52:13 PM
I guess I really don't know how to use the "And" operator in a Join clause. I have 3 tables - tblTotal, tbl1, and tbl2. tblTotal has an ID field and a Region field of interest. Two Regions - 'N' and 'S' in tblTotal. tbl1 cointains records from tblTotal for region 'N', and tbl2 contains...more >>

The difference between MS and IBM (corrected)
Posted by Kevin Davidson at 4/5/2004 1:37:36 PM
Consider the following query: select soundex('MS'), soundex('IBM'), difference ('MS', 'IBM'), difference ('IBM', 'MS') Results from Microsoft SQL Server 2000: ----- ----- ----------- ----------- M200 I150 2 1 Results from IBM DB2 version 8.1 ----- ----- ----------- ----...more >>

xp_sendmail and @user param
Posted by Kasper Birch Olsen at 4/5/2004 1:26:49 PM
Hi Im trying to use the stored procedure xp_sendmail, but I have run into a problem. If I try: dbo.xp_sendmail @recipients = 'mymail@mydomain.com', @message = 'test' I get the following error: "xp_sendmail: Procedure expects parameter @user, which was not supplied." but if I add the @user ...more >>

Save, Script, Export SQL Database Diagrams
Posted by clay NO[at]SPAM beattyhome.com at 4/5/2004 1:22:23 PM
When you create database diagrams in Enterprise Manager, the details for constructing those diagrams is saved into the dtproperties table. This table includes an image field which contains most of the relevant infomation, in a binary format. SQL Enterprise manager offers no way to script out ...more >>

Subselect question
Posted by Vlad at 4/5/2004 1:19:36 PM
I need to write a stored procedure which will return 1 record from table Job which is 20 records away (bigger for instance) from the current record defined by input @JobID parameter. For instance I pass @JobID = 1000 and would like to get a record with JobID = 1020 if there are all records betw...more >>

Union VS temp tables
Posted by pcherlop NO[at]SPAM hotmail.com at 4/5/2004 1:15:53 PM
Hello, With reference to performance, which is better - using union in a query or creating a temp table Thanks Prasanna....more >>

SELECT & number of line
Posted by myname at 4/5/2004 12:21:37 PM
Hello, I'm using SQL Server 2000. I would like each line of my SELECT to contain a column giving the number of the current line. It seems the only way to do that is something like: INSERT identity(int,1,1) as lineNumber,* INTO newTable FROM oldTable But oldTable as an identity column...more >>

outer join 3 tables
Posted by Bob at 4/5/2004 12:11:34 PM
Hi, I have three datable tables. The table schema is as below. They all have the same foreign key field tblID, and each has individual primary key field as tbl1ID, tbl2ID, tbl3ID. The table is sorted by its primary key field. What I want is to get a result like: tblID tbl1ID tbl1Fld tbl2...more >>

Anti-Virus Software for Windows 2000 and 2003 Server
Posted by anon at 4/5/2004 11:25:16 AM
Hello, Can anyone recommend some good Anti-Virus Software for Windows 2000 and 2003 Server version? Seems like Symantec, Norton AV is asking IT professionals to buy minimum 5 licenses just to get a server version. Totally B.S. I want to be able to also exclude files, such that for SQL S...more >>

Shrink database...
Posted by Brett at 4/5/2004 11:23:55 AM
Is there a way to shrink a database in production without blocking user connections? I have a 75 GB file and want to shrink it down 30 GB. The file had become empty after archiving data. I run the following syntax: USE CustomerService GO DBCC SHRINKFILE (customerservice_dat...more >>

Troubles with SELECT char expression
Posted by Scott at 4/5/2004 11:22:27 AM
Is there a limit on the size of a character expression, that I can change? In the following (GUI is text): SELECT '(''' + REPLACE(CONVERT(char(5000), GUI), '''', '''''') + ''')' FROM MyTable WHERE GUI IS NOT NULL I get: ('my-stuff But I would expect (and want) to get: ('my-stuf...more >>

Finding and inserting consecutive pairs
Posted by myname at 4/5/2004 11:12:42 AM
Hello, I'm trying to insert into a table consecutive pairs from another table. Right now, I'm using a cursor but I wonder if there's a faster way. Example: My table1 contains a column of integers: 1, 20, 3, 45, 12 I want to obtain this in a two columns table Table2 : (1;3) (3;12) (12...more >>

WHERE clause question
Posted by Carl Imthurn at 4/5/2004 11:04:40 AM
I am having a bit of difficulty understanding the performance issue I'm facing, as follows: Here's the WHERE clause of my SQL statement: WHERE (DN.OFFICE_NUM = 3) AND (DN.ProcedureID < 9000 OR DN.ProcedureID > 9999) AND (DN.ProcedureID <> 5985) AND (DN.PostingDate BETWEEN...more >>

suser_name() in SQL Server 2000
Posted by SqlJunkies User at 4/5/2004 10:57:28 AM
It's my understanding that [suser_name()] has been changed to [suser_sname()] in SQL Server 2000... my question is: are there any other gochas? thx d --- Posted using Wimdows.net NntpNews Component - Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post ...more >>

Table scan and index seek
Posted by ajayz90 NO[at]SPAM hotmail.com at 4/5/2004 10:25:44 AM
When running this query i find that in the select staement if age and sex is not selected the query does an index seek otherwise it does a Tbale scan....The other colums have a non clustered index on them while age and sex do not. What causes teh table scan to take place....is it necessary t...more >>

How to Query Question
Posted by Woody Splawn at 4/5/2004 10:13:51 AM
Lets say I have a table called BudgetDetail with 3 fields in it. DeptID (which is the Key and is an Int), and two float fields called BudgetAmt01 and BudgetAmt02. Further, I run the following query: SELECT DeptID, SUM(BudgetAmt01) AS Jan, SUM(BudgetAmt02) AS Feb FROM BudgetDetai...more >>

Time Problem
Posted by scorpion53061 at 4/5/2004 10:05:03 AM
My access database I have "medium time" But the time being displayed is 11:00:00 PM How do I make it say 11:00PM (Not sure if it shold have a space before PM) Below is the statement I am using..... SELECT DateOfEvent, EventName, Location, StartTime FROM Events where DateOfEvent >=...more >>

Retrieve data when date value is nothing
Posted by Stewart Saathoff at 4/5/2004 9:55:40 AM
Hello, I am trying to retrieve data from a table where a date column is blank. I have the SQL statement as WHERE DateField = "" and I receive a data type mismatch error. Does anyone know how to fix this? ...more >>

Communication between SqlServer and external application
Posted by Boaz Ben-Porat at 4/5/2004 9:23:18 AM
Hi all How can SqlServer communicate with an external application ? Te task: Each time a given value is inserted/updated in a specified field in one of my tables, I want the trigger on this table to send some kind of message to a running application (which I have to write). How can the t...more >>

dts fails on datetime import
Posted by Steve at 4/5/2004 8:56:02 AM
I have a delimited text file with a column that has date in 'yyyymmdd' format but fails to import into a datetime field. I get a conversion error. I can do an INSERT no problem but the DTS process fails. Any ideas? Thanks....more >>

SQL/OLEDB/JET
Posted by Jm Plant at 4/5/2004 8:39:30 AM
Certain of our SQL 2000 installations produce error 7399 when attempting to read/write to Excel from within SQL Server (e.g. using the OpenRowset command, using Linked Servers etc). The error produced is: Server: Msg 7399, Level 16, State 1, Line 1 OLE DB provider 'Microsoft.Jet.OLEDB.4.0'...more >>

Unexpected int value when WHERE clause returns no records
Posted by William Morris at 4/5/2004 8:39:15 AM
I can't work out how to get what I want in one statement. With this query: select coalesce(contactid, 0) from tblPeople where email = 'this_value_fails@email.com' I get no value back: not zero (which is what I want), not null, nothing. FWIW, entering a good email address gets me the con...more >>

Duplicate Indexes
Posted by Konstantinos Michas at 4/5/2004 8:14:39 AM
Hello Experts, In earlier Versions of SQL Server (perhaps even before applying Service Packs of SQL Server 2000), when I attempted to create an Index with same name to two different Tables, I get an error msg, that thereabout said "IX_ExampleName already exists." Is this handle ever exis...more >>

Discovering the Baseline
Posted by Jonathan Derbyshire at 4/5/2004 4:56:05 AM
Hi I'm trying to optimize my SQL Server 2000 Database. I'm looking at ways to improve 3 SPROCS in particular Initially I intend to discover the baseline, by running each SPROC 10 times and working out the average I intend to use the commands DBCC DropCleanBuffers and DBCC FlushProcInDB(@DB) t...more >>

Assigning a result to a varchar
Posted by Gerry at 4/5/2004 4:46:05 AM
Using the following piece of code - I would like to assign the result of a query (see Select top 1 b.bookingvalue) to @Valu I do I achieve this Thank --My Cod DECLARE @value varchar(50 DECLARE @Count int SELECT @Count = COUNT(*) Activit WHERE Customerid = IF @Count > 0 BEGI select to...more >>

Create dinamic table
Posted by RManuel at 4/5/2004 3:41:04 AM
Help urgent please, I've a piece of code that needs to alter or create a table dinamic, at the end I need to "run" the @stfield Thanks in advanc R Create procedure P a declar @cont int @stfield varchar(255 begi create table t (c1 int null select @cont = while @cont < begi ...more >>

Date format
Posted by MR.T at 4/5/2004 2:40:48 AM
Hello I have a table that one of its column is in dateTime format. My date format in the pc is dd/mm/yyyy (in the Regional Options) In the Query Analyzer I run "SET DATEFORMAT DMY" but when I try to enter data as "21/3/2004 12:00:00" I get error. when I try to enter data as "3/21/2004 1...more >>

T- Sql
Posted by Nagesh at 4/5/2004 1:58:51 AM
Hi guys how to get the number of vowels in a column? Out put should Like this, without using UDF's Column1 Count ----------- --------- abc 1 Curious 4 ...more >>

INSTEAD OF trigger
Posted by paul1664 NO[at]SPAM hotmail.com at 4/5/2004 1:45:11 AM
Hi I m trying to create a simple INSTEAD OF trigger for a view containing a couple of linked tables. One table contains a foreign key (FK) to the other which must hold a related record. However, when I try to insert a new record in Enterprise Manager I get the "Cannot insert the value NULL in...more >>

Db name
Posted by Pippo at 4/5/2004 12:55:56 AM
hi, How i can retun my current Database name in TSQL??? Thank Pippo...more >>

Backup files Problem.
Posted by sharad at 4/5/2004 12:19:56 AM
Dear Friends I am facing problem with the backup of SQL i think the backup is corrupt and i need to restore the same as there is one critical issue for the payment which is missing. Please suggest how i can do the same is there any tool which can recover the currupted backup file and a...more >>


DevelopmentNow Blog