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 > march 2004 > threads for monday march 8

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

DSN
Posted by anonymous NO[at]SPAM coolgroups.com at 3/8/2004 9:43:34 PM
How do I set up a DSN in Windows...more >>


Help with query (sorting and grouping fields)
Posted by Star at 3/8/2004 9:26:04 PM
Hi, I have table like this CODE Name DateFrom 1 d american 2004/03/06 15:41:28 1 c american 2004/03/06 15:39:23 1 b american 2004/03/06 15:39:23 2 burt walker 2004/03/01 12:46:20...more >>

Aggregating by time period
Posted by David F at 3/8/2004 9:00:58 PM
I have a list of daily stock prices extending over a period of a year. I want to return the average for each week. IOW, I want 52 rows showing the average price for each 5 day trading week for the entire 1 year period. How do I write the GROUP BY to get the average for a week? ...more >>

Multiple Queries in a single line
Posted by qAnand at 3/8/2004 8:01:34 PM
Hi All, Sorry for the earlier incomplete post. Is there any setting in the server wherein I can disable the execution of multiple queries in a single line. For example: SELECT Name FROM Employee WHERE ID =5;SELECT Name FROM Employee WHERE ID=6; Returns two result sets. C...more >>

incrementing a unique value and returning it
Posted by J at 3/8/2004 7:58:10 PM
Hi, I am trying to return a unique ID number from a sp. I have a table (called IDNumber) that contains 1 row and 1 field, called 'lastNumber' Can anyone tell me if the following will work ok? I have about 400 users and I need to guarantee each call will return a unique number. I don'...more >>

sleep a few seconds
Posted by toylet at 3/8/2004 7:22:52 PM
I want to simulate a slow connection at localhost. Does SQL server has a function to sleep for a period of time? I check the book and believe I need to use a while loop with datepart(getdate()) to do so. -- .~. Might, Courage, Vision. In Linux We Trust. / v \ http://www.linux-s...more >>

Row number in a query
Posted by Miguel Ramirez at 3/8/2004 6:42:44 PM
Is it possible to get a row number in a select transact query, something that shows the incremental row number plus the table data like this. 1 Jonh Smith 2 Mark Lopez 3 George Jones I need to get the column (1,2,3, ...n) Thanks. ...more >>

sql mail
Posted by kriste at 3/8/2004 6:26:26 PM
Can someone give me some advice on how can I go about in configure SQL = to be email enabled? I've setup MS Outlooks and tried setting up mail profile in SQL but when = tested it out at the operator, error 22022: SQLServerAgent Error. There's no Exchange or mail server, I can only use POP3 email...more >>



Output and return from stored procedure
Posted by Ian at 3/8/2004 6:16:42 PM
I'm having some trouble getting the right output from a stored procedure (simple version below). Can someone please tell me why I don't get a value in the @Return parameter? CREATE PROCEDURE TableUpdate @ID int, @Name @Varchar(30) @Return @INT OUTPUT AS UPDATE TableName SET Name = @Na...more >>

Error trying to use computed column
Posted by Alex at 3/8/2004 6:10:23 PM
query: select field1, field2, case when () then 0.0 else 1.1 end AS 'Actual $', case when () then 0.0 else field2-[Actual $] AS 'Final $' from table the Query analyzer does not recognize [Actual $] in the second computed column ...more >>

Best strategy on storing files on server
Posted by NWx at 3/8/2004 5:56:51 PM
Hi, I have an application who require to let users to upload files on server, and "link" them to some other database records (projects, which allow user to attach files to them) How is the best strategy to store them on web server? Should I store them in SQL server database, or as files o...more >>

the "having" clause
Posted by toylet at 3/8/2004 5:54:57 PM
Why did SQL Server complain about "invalid column recno" in the following query? It worked in another database tool I am using. select xx.pk, xx.amount, count(*) as recno from tx xx, tx yy where xx.pk>=yy.pk group by xx.pk, xx.amount having recno = 1 -- .~. Might, Courage, Vision...more >>

parsing the store procedure comma delimited parameter
Posted by Jen at 3/8/2004 5:41:08 PM
Hi I would like to do serveral updates in the procedure, so I passed in the ids as comma delimited string, but the ids are numeric field, I know if I use dynamic sql, I can directly use it, but how about just a update statement? Thanks...more >>

Auto alert on database changes
Posted by Ed at 3/8/2004 5:39:14 PM
Is it possible to set up an alert via e-mail such that if any of the developers modifies a stored procedure in a particular database, an e-mail will be sent to me (describing which stored proc got modified)? ...more >>

simple question re DELETEing in linked DB
Posted by gerry at 3/8/2004 5:36:58 PM
I am trying to delete data in a table in a linked database. I tried to use openquery but this gives me an error without 'any information' - i assume because a DELETE does not return a result set. Using DELETE from [lnkdb]...[tab] ... is giving me grief because 'provider could not support a row ...more >>

Using UDF in a default constraint
Posted by Michael MacGregor at 3/8/2004 5:04:09 PM
Sorry about this, I'm a bit rushed and I don't have time right now to put together any DDL for it, but hope that the description will suffice ("Foul" I hear you cry!) I would like to use a UDF in a default constraint on a column, but the UDF will reference another table based on the value of a...more >>

locking a record explicitly
Posted by toylet at 3/8/2004 4:23:35 PM
Is there a T-SQL command that could lock a record in a table explicitely and unlock it within a stored procedures? -- .~. Might, Courage, Vision. In Linux We Trust. / v \ http://www.linux-sxs.org /( _ )\ Linux 2.4.22-xfs ^ ^ 4:22pm up 2 days 32 min load average: 1.00 1.0...more >>

Trim For Select
Posted by Scott at 3/8/2004 4:21:39 PM
I have a join I need to use a "trim" function to strip the left 2 char off a field - can you help? here is the join left join safeway..xsfwy_Policies sp on sp.policy = trim("AG",aip.policynumber) Thanks in advance for your help ...more >>

CASE with aggregate
Posted by Alex at 3/8/2004 3:47:58 PM
f.e., I need to have select ...., calc_value when (condition) then (result of SUM) from table is it possible to do result of SUM when ever row I'm choosing from the table is a result of a JOIN. ...more >>

Does CharIndex have 8k problem?
Posted by Bill at 3/8/2004 3:31:05 PM
Hi I tried to use Charindex function toward a TEXT field to get a keyword ocurrance, if the keywords position is greater than 8k, it returns 0, I tried PatIndex, it works fine Is this because of the 8K problem? or is there a setting for this Thank Bill...more >>

slow odbc between servers
Posted by Guy Brom at 3/8/2004 3:30:20 PM
Hi there, I created an odbc connection on machine1 that connects to mssql2k on machine2. For some reason I get very slow results between the two. Is there any way I can speed odbc connection? I'm using windows on both machines and created a system DSN using the sql connecter. Thanks! ...more >>

counting and grouping
Posted by Bryan Harrington at 3/8/2004 3:24:32 PM
SQL 2000 I have a table that has ~5,000 records in it that I need to create some reports on. Each records belongs to one of 12 categories, and has a batch_date. I need a count of records for each category by month (for a given range) i.e., JUL | AUG | SEP | OCT | CMD 88...more >>

Append Query to Another Database
Posted by rbrown NO[at]SPAM edium.com at 3/8/2004 2:44:51 PM
Hi All. I have two databases. One is called FTO, which is the main input database, and FTOArchive which, after every 3 months I need to "remove" records 3 months and prior to the ARCHIVE Database. Each database has 3 tables, tbl_OrderInfo, tbl_OrderItems, tbl_OrderLog which I need to get th...more >>

Getting external data ODBC connect errors when connecting with Access
Posted by bc at 3/8/2004 2:42:28 PM
Connecting to a Sybase 11.9 system via W2K to export some data to pipe delimited for use in another location. Sybase bcp only allows me to export an entire table. isql -s\| doesn't seem to delimit fields in the right places. Don't have a problem with ODBC with Excel works fine but I run into som...more >>

Insert Trigger error
Posted by Ron Hinds at 3/8/2004 2:33:27 PM
I'm hoping someone here can tell me what is wrong with this INSERT Trigger I'm trying to create. The error I get is: [Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'UPDATE tblPhoneLog INNER JOIN TblPhone ON tblPhoneLog.PhoneNumber = TblPhone.phNumber ...more >>

Many-to-many question.
Posted by imani_technology_spam NO[at]SPAM yahoo.com at 3/8/2004 2:20:43 PM
Is it possible to have a many-to-many relationship without an associative or "linking" table? Also, is it possible to implement a many-to-many relationship with a self-join?...more >>

SQL statement
Posted by Nikolami at 3/8/2004 2:07:17 PM
I have table with holidays date. I need to calculating the number of calendar days between two dates minus weekends and holidays (SQL 2000). How can I calculate in vbScript or SELECT statement? Could you please help me to resolve this problem??? ...more >>

linked dBase tables
Posted by Vilmos at 3/8/2004 1:48:42 PM
For our current application we have to link dBase IV tables to our SQL 2000 server. I have created a linked server pointing to the dBase tables using 'Microsoft Jet 4.0 OLE DB Provider'. I can see the dBase tables in EM and I 'm able to work with them using the Query Analyzer. I can SELECT, INS...more >>

INSERT TRIGER
Posted by simon at 3/8/2004 1:27:59 PM
I have 2 tables with ID,type and name fields. I would like to create insert trigger on table T1, to insert the values in table T2 only when ID=2 and type=0. Something like this: CREATE TRIGGER testTrigger ON [dbo].[T1] FOR INSERT AS IF INSERTED(type)<>0 AND inserted(ID)<>2 RETURN else ...more >>

SQLSERVERAGENT
Posted by js at 3/8/2004 1:23:03 PM
Hi, For security reason, I changed the "BUILTIN\Administrators" Server Access from "Permit" to "Deny". Run this one: EXEC sp_denylogin 'BUILTIN\Administrators'. But this will cause the SQLSERVERAGENT was failed to start . got the following error. I already changed the service login account t...more >>

General Network Error after database restore
Posted by Boris Wehrle at 3/8/2004 1:14:41 PM
Hello, most times the first connection after restoring a database results in the following Error: "Sytem.Data.SqlClient.SqlException: General network error." Even the workaround from http://support.microsoft.com/default.aspx?scid=kb;en-us;827452 didn´t help. Any ideas? Thanks Boris S...more >>

build resultset in stored proc
Posted by Steve at 3/8/2004 12:56:08 PM
How can I build a resultset by using multiple selects? For each succeeding select I want to link to the prior select....more >>

Error 7405
Posted by Merwin12 at 3/8/2004 12:42:48 PM
I'm getting this error :Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query. and I'm currently using SQL 2000. sqlcode: begin truncate testtable ...more >>

Identity Setting for an Existing Column
Posted by Kayode Yusuf at 3/8/2004 12:26:05 PM
Greetings ALL I have a table wih a single column - x - I need to alter the column to make it an Identity column and I seem to have run into a brick wall What is the syntax for this - I tried Alter table tblName alter column X identity(1,1) and it doe not work. Do I need to drop and recreate t...more >>

how to use charindex and substring
Posted by SQL Apprentice at 3/8/2004 12:20:46 PM
Hi, I am trying to write a select to breakdown an ip address. for example: the ip is 132.213.212.47 the result should be: 1st 2nd 3rd 4th 132 213 212 47 the select needs to be able to change when ip address changes. new ip is now 133.11.21....more >>

Multirow Operations & Triggers
Posted by JLS at 3/8/2004 12:07:50 PM
Does anyone have an example of code for multirow operations with = triggers? I don't want to use a cursor. I know the trigger I wrote will work for = single row insert or update operations, but I don't want it to break in = the off chance a multirow update occurs. I want to write the best ...more >>

Query Question for the Gurus
Posted by Dan at 3/8/2004 11:01:10 AM
Hello everyone I am trying to look at trends with some raw data that I have. My data has a two values, a volume and timestamp dOctets as in First as datetim I want to find a way that I can run one query and group the data into "time buckets" so that I can graph. For example I want to SUM(d...more >>

using "case" in where clause
Posted by TJS at 3/8/2004 10:40:13 AM
what's wrong with doing this, I get an error on compilation for case portion of code @S_Selected integer .... Select ... from ... where ... CASE When @S_Selected <> -1 then AND tblA.Number = @S_Selected END AND .... ...more >>

ISA log table in nice format
Posted by Stijn Verrept at 3/8/2004 10:35:47 AM
I have an ISA server logging to the following table: CREATE TABLE [dbo].[Results] ( [ClientIP] [varchar] (32) COLLATE Latin1_General_CI_AS NULL , [ClientUserName] [nvarchar] (32) COLLATE Latin1_General_CI_AS NULL , [ClientAgent] [varchar] (128) COLLATE Latin1_General_CI_AS NULL , [ClientA...more >>

How to force ANSI_NULLS ON for a user-defined function
Posted by Boaz Ben-Porat at 3/8/2004 10:22:37 AM
When generating SQL script for a UDF in SqlServer 2000 the script includes these lines at the top: SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS OFF GO < drop function statement> <create function> .... When a function is created with ANSI_NULLS OFF it can not be used in an index (on...more >>

Remove Alpha Characters From Varchar Column
Posted by Steve Beach at 3/8/2004 10:01:41 AM
In a SELECT statement, I want to remove all non-numeric characters from a column. (i.e. only return characters "0-9"). I know I can do this in the client and then store the resulting value in a column, but is there a way to acheive this without doing a REPLACE() 245 times? Source: 388 So...more >>

Don't understand why select distinct so slow
Posted by holysmokes99 NO[at]SPAM hotmail.com at 3/8/2004 9:09:17 AM
Hello, I am working with a table with about 27 million records. When I run: SELECT count(*) MyTable It takes several MINUTES for it to return. The disk activity goes up to 100%. Is this normal behaviour? If so, why? I would think that SQL Server would be able to easily calculcate that ...more >>

.tab or .csv
Posted by johnduran at 3/8/2004 8:01:10 AM
Need some help to have the results of the following code come out as either a .tab delimited, with " " text separators; or .csv delimited with " " separators. What code can I add to make this happen automatically CREATE PROC dbo.xbke_my_car_page_us @begin_dt datetime @end_dt datetim A ...more >>

J# and Yukon
Posted by anonymous NO[at]SPAM discussions.microsoft.com at 3/8/2004 8:00:41 AM
I've read some articles that J# will be supported in Yukon and others that say not. Does anyone know? Where can I find these answers?...more >>

How to check for duplicates
Posted by Lasse at 3/8/2004 7:52:08 AM
Hi, I have a table with 4 columns where I must check if there are duplicates, it is a duplicate if all 4 columns match another record. How should I construct the query to achieve that? Thanks Lasse Using MS SQL 2000 ...more >>

Convert from Float to Varchar
Posted by PaulaC at 3/8/2004 6:53:59 AM
Hi, I am working on an extract from our SQL Database. I need to obtain various sales values and put them into a text file. The problem is when I try to convert very large figures. When I try and convert from float to varchar the figure is always converted into exponential notation. Th...more >>

iif statement in a having(where) clause
Posted by smatthews NO[at]SPAM burbidge.co.uk at 3/8/2004 6:40:42 AM
SQL2000 sp3 Advise please i am trying to write a query with a having clause, basically i want to find out what weekday it is, if its a monday then give me todays date - 3 days, otherwise give me todays date - 1 day in access the clause looks like this "Updateddate <(IIf(Weekday(Date(),...more >>

One or many lookup tables
Posted by Blake at 3/8/2004 6:26:12 AM
When designing a database, is it better to have one lookup and types table or many. For example, in a real estate database you could have one phone_type table (mobile, home, work,...) for clients and one property_type table (appartment, house, land, cabin....) or contain all these values in one tabl...more >>

Help with Query
Posted by Mike at 3/8/2004 6:06:06 AM
I need help with a query. A subset of the data table is listed below ParentID ChildID FriendlyNum SubID DEL_IN 3 3 1000393 -998999607 3 3 1000395 -998999605 3 4 1000395 -998999205 3 3 1000776 -998999224 3 4 1000776 -998999204 I need a query that will do thes...more >>

Stored procedure help needed please (Group by and Sum)
Posted by Stephen Cairns at 3/8/2004 2:51:05 AM
I have a SQL stored procedure that is returning results in a table as follows (Below): I would like to have the results grouped by price so as it only appears the once. I would like to have it so as the copies and Rev totals for each price are summed up. To show exactly what I mean please look a...more >>

Help with Query please - Pivot
Posted by Matt at 3/8/2004 2:31:05 AM
Hi, I have the following query that kinda does what i wan SELECT ABTANumber, TourOperator, ReportStatus, COUNT(*) AS Counter FROM (SELECT ABTANumber, TourOperator, r.ReportStatus FROM bookingdetails bd LEFT JOIN report r ON bd.Id = r.BookingDetailsId) a GROUP BY ABTANumber, TourOperator, Report...more >>

minimize database records
Posted by Leon at 3/8/2004 2:01:29 AM
How do I write a store procedure that limit the amount of record a member can upload. Example: I have a student database that allows students to post-up there school books, but they can only have five books posted at one time. So how can I create a stored procedure that will do the above? ...more >>

BULK INSERT (X)
Posted by \ at 3/8/2004 1:08:36 AM
Hi, I have to import a file, using BULK INSERT, into a #TEMP_TABLE - the file has the following contents/format (5 cols): "B09Z003 ","0058-003-01 ", 57, 0," " "B09Z005 ","0053-003-R1 ", 19, 0," " "B09Z008 ","0054-2 "...more >>

Nested Cursors...
Posted by Russ at 3/8/2004 12:46:06 AM
Hi All I believe that you cannot nest a cursor and use the @@cursor_status because the @@Cursor_Status is a global variable. My problem is that I have several functions and sp's use Cursors and one sp will call another with the cursor. and this seams to work fi...more >>

DatePart
Posted by Kjell Brandes at 3/8/2004 12:26:06 AM
Hi all Please help me on this one Trying to render a swedish kalender in SQL-server is no problem, but trying to get WeekNumbers connected to the date is a problem, at least, if you trying to get the week number for 2003-12-29 (29/12/2003) SQL-server will return week 53. In many countries this mig...more >>


DevelopmentNow Blog