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 > october 2005 > threads for tuesday october 18

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

insert/update NULL instead of ''
Posted by Rainer Ebert at 10/18/2005 10:27:20 PM
Hi, due to special reasons I have to ensure, that in insert and update statements for varchar-columns (which allow NULL-values) the value '' automatically becomes replaced by NULL before the records have been inserted/updated. (This because I have to convert a large application from anoth...more >>


When does @@DBTS value change?
Posted by Dean Slindee at 10/18/2005 9:50:31 PM
I have read that the value of @@DBTS changes on every insert and update. However I am finding that that is not true. I can do multiple inserts of rows into a table, and all of the rows will have the same value in the varbinary(8) column that is populated with the value of @@DBTS at the time of ...more >>

select rows to match parameter, plus default rows for non-matches
Posted by John A Grandy at 10/18/2005 6:36:04 PM
I have a table : CategoryID int SettingName nchar(50) SettingValue nchar(500) CategoryID can be 1,2,3,4,5, .... for CategoryID = 1 : rows exist for every possible SettingName for CategoryID = 2,3,4,5 : a row might exist for any given SettingName ... or it might not I need a sproc ...more >>

Joining two results
Posted by Stijn Verrept at 10/18/2005 6:28:20 PM
I have these results: ID Worked 1 25 2 30 5 20 8 32 9 27 10 26 ID Spent 1 35 2 24 3 22 4 50 5 30 6 28 Required result: ID Worked Spent 1 25 35 2 30 24 3 0 22 4 0 50 5 20 30 6 0 28 8 32 0 9 27 0 10 26 0 I think I can make it but it will be complicated, a...more >>

View Index vs Outer Join
Posted by Brad White at 10/18/2005 5:49:25 PM
I have a view that includes a left outer join. I want it to be indexed because it could easily have over a million rows in it. At any one time we are bringing back less than 1000. Adding an index complains because there is no clustered index. Adding the "clustered" keyword fails with "Cannot...more >>

Revisiting the Brands / Makes question
Posted by Earl at 10/18/2005 5:00:33 PM
On a somewhat theoretical note, I'm curious what properties others might think a Brand might have (or, as noted by Alex P. in response to my earlier "Simple primary key question", most folks refer to car Brands as "Makes"). It would seem to me that all aspects of the Brand are related to the M...more >>

DELETE all records within 2 tables for each user based on unique identifier with one DELETE statement
Posted by Nino_1 at 10/18/2005 4:50:38 PM
Hi, I'm building a SQL query that will delete all records within two different tables, the records in both tables belong to the same user with a userID as the unique identifier. Can this be done with one DELETE statement? Thanks, Nino ...more >>

Deleting rows within two tables that store ifo for the same person within one DELETE statement
Posted by Nino_1 at 10/18/2005 4:43:23 PM
Hi, I need to delete information within two different tables that has the same unique identifier relative to a single user (USERID). Basically I have to remove any records for this user from both tables with one DELETE statement. Any suggestions would be great. Thanks, Nino ...more >>



trunc. log option
Posted by Kevin at 10/18/2005 4:36:54 PM
If my database is in simple mode, I think default is clean transaction log after commit successful correct? I don't think I need to run following statement to clearn transaction log correct? If I guess correctly, the following option is only useful in FULL mode. sp_dbopti...more >>

SQL Server 2000: Converting XML document to a string type
Posted by vadim.bermanATATgmail.com at 10/18/2005 3:47:25 PM
Hi all, Is there a way to convert an XML document returned by a "FOR XML" SELECT query back to CHAR or VARCHAR or TEXT? I am trying to create a reusable stored procedure returning an XML fragment. I know it is possible to insert a string as it is into another XML document using !XMLTEXT dir...more >>

Common Table Expressions
Posted by Mark at 10/18/2005 3:27:07 PM
CTE's appear to have 2 advantages: 1. Compliance with ANSI 2. Recursive queries. Aside from these reasons, and perhaps a syntax preference by some, I do not see a good reason to go out of my way to use them. The remaining situations don't seem to give any benefit: 1. If I wanted to use...more >>

NEWBIE: Error importing NULL data to datetime field
Posted by SACedric at 10/18/2005 2:55:28 PM
I have created a table with a field which is defined as a datetime field. I set the value for default to be (0). When I try import data, I get an error message: "Destination does not allow NULL on column pair 37........." Now perhaps it should be stated that then enitire column in the source ...more >>

SCOPE_IDENTITY()???
Posted by ReTF at 10/18/2005 1:22:06 PM
Hi All, I have one doubt, if any one can help-me: I have one SQL(db) that receive a lot of inserts, and I need get IDENTITY value of current insert, but the machine have 4 processors. If I use SCOPE_IDENTITY() I will get the corret value? Thanks. ...more >>

How do I "using bcp_columns with a variable number of bcp_colfmt"
Posted by robdob2003 NO[at]SPAM yahoo.com at 10/18/2005 12:57:31 PM
hello, I have MFC VC++7.1 program which has the following code segment: // Specify the colums and format to copy retcode = bcp_columns(hdbc1, 6 ); if ( (retcode != SUCCEED) ) { return; } retcode = bcp_colfmt(hdbc1, 1, SQLCHARACTER, 0, SQL_VARLEN_DATA, (unsigned char*)"|", 1, 1); retco...more >>

query for stored procedures?
Posted by apandapion NO[at]SPAM gmail.com at 10/18/2005 12:52:43 PM
I'm working with SQL Server and I'd like to run a query to find out a list of the user stored procedures in a given database, and what the parameters for each stored procedure are. ...more >>

EXEC as part of a SELECT
Posted by KlausSarbeach at 10/18/2005 12:50:04 PM
I wrote a stored proc that results in a dynamic rowset of different columns. (not predefined except ID). To Make it available for a join with i.e. a view, I want to use an inline-tablereturn function, because this kind of function doesnt need a predefined Tabledefinition, too. But: I have jus...more >>

Unable to update in a view
Posted by fig000 at 10/18/2005 12:16:26 PM
Hi, I have an application that's running fine on development servers (web and database-sql server 2000). I'm updating a record through a third party component but I don't think the component is the problem. What's happening is that I'm updating fields that are part of view. I'm only updatin...more >>

T-SQL Procedure
Posted by itsmedotcom2001 NO[at]SPAM yahoo.co.in at 10/18/2005 11:54:11 AM
Hello! I need your help in developing a procedure which is being called by the asp .net web page when the user insert into 5 text boxes phonenumber in the format xxx-xxx-xxxx. The table in the database has id for the phonenumber, and a field called Phone-number which takes just one phone numb...more >>

Question on exporting reports
Posted by CD at 10/18/2005 11:50:02 AM
I have 2 reports in my Access program(SQL DB) that I need to export into 1 text file. The OutputTo function works great for 1 file, but I can't figure out an easy way to add the second report to the end of this text file....more >>

what is the best practice...
Posted by rodchar at 10/18/2005 11:50:01 AM
hey all, i was wondering about an invoice system that contains many customers, how are the invoice numbers normally assigned: does each customer get its own sequence of invoice numbers? thanks, rodchar...more >>

ntext or text datatype for CLR C# stored procedure pararmeter? SQL
Posted by duohong at 10/18/2005 11:42:04 AM
Is it possible to use ntext or text datatype for CLR C# stored procedure input or output pararmeter? in SQL 2005 Thanks...more >>

Joining and Union Issue
Posted by jake at 10/18/2005 11:12:14 AM
Hi, I have a problem which is hard to describe but I will try. I have table that has a relationship one to many with another table and it has a relationship many to many inside it self. Each record had a field that is called fparent and fparent can relate to the primary field fcomponet. ...more >>

How to group multiple records into 1 record
Posted by culam at 10/18/2005 11:12:02 AM
Thanks in Advance, Culam id phone_alternate phone_home phone_work phone_cell ----- ---------------- --------------- ------------------ -------------- 47 NULL 619 222-2552 NULL NULL 47 NULL NULL 61...more >>

adding a new key; planning for millions of records
Posted by John Mott at 10/18/2005 11:09:41 AM
Hello all, i'm going to be adding a new column (1 byte) that will become a non-unique indexed value into a table that i'm adding records into. i know for a fact that this table will grow from the current thousands to millions of records over the span of a few weeks and have allocated the datab...more >>

Case statement in a where clause
Posted by jaylou at 10/18/2005 11:02:02 AM
Hi All, I have a bit of a delema here, that I know someone knows how to do it properly. If the value of DSP_IN_HOUSE = 1, I need the where clause to say: where DSP_IN_HOUSE_IN = F.CollectorDesc the code I am using is: left outer join tlkCollector F on case when DSP_IN_HOUSE = 1 then DSP_...more >>

How do I copy 2 columns of data to 2 other columns of the same tab
Posted by Alpha at 10/18/2005 10:13:03 AM
I tried creating the following procedure but it's giving me error. Can someone tell me how can I get this done? Thanks, Alpha USE VMS GO CREATE PROCEDURE SavePrevOdo AS Update VehDetail set PrevOdometerDate = v2.LastOdometerDate, PrevOdometerReading = v2.LastOdometerReading fr...more >>

sql_variant for generic storage of different number formats
Posted by JohnSw at 10/18/2005 9:59:06 AM
I have a test database that needs to store different types of test data: boolean, integer, and double. Any opinions on use of three columns per row (char(1) (nullable), int, float) versus a single sql_variant column? The table will rapidly have a billion rows, so space is a concern. Thanks, ...more >>

Complex join issue
Posted by Mathieu Dumais-Savard at 10/18/2005 9:53:58 AM
Hi There, I'm having problem creating the following output: Fact Table 1 (Sales) ----- Date_Key smallint, Emp_Key smallint, SalesNbr smallint, SalesAmnt money Fact Table 2 (Attendance) ----- Date_Key smallint, Emp_Key smallint, ScheduledTime int, Attendance int Dim Table #1 (Da...more >>

uneven start finish dates converted to evenly spaced time series
Posted by DapperDanH NO[at]SPAM nospam.nospam at 10/18/2005 9:47:07 AM
Hello, I work for a discrete event simulation company. Much of data created by our simulation tools can be represented like the following: EventID, StartDate, FinishDate, Replication So, If i was simulating a hospital, the table might look like the following: (Hopefully shows up decently ...more >>

Sorting Help
Posted by John . at 10/18/2005 9:22:49 AM
I have two tables that are related - Region and Office CREATE TABLE [dbo].[Region] ( [RegionCd] [varchar] (3) , [RegionDesc] [varchar] (50)) GO CREATE TABLE [dbo].[Office] ( [OfficeId] [int] NOT NULL , [OfficeName] [varchar] (100), [RegionCd] [varchar] (3)) GO The SQL statement ...more >>

is it possible to do this without cursors?
Posted by Ben at 10/18/2005 8:59:06 AM
i have the following vb code that i want to turn into a stored procedure. Can it be done without using cursors? thanks for any help! what this code does is it says for each item, which other items reference it in the column called source. Set rst = CurrentDb.OpenRecordset("SELECT [...more >>

MAX returns 0 rows when column value is duplicated.
Posted by john NO[at]SPAM red-guitar.com at 10/18/2005 8:52:41 AM
Hi-- Aggregate function MAX is confounding my efforts? I really need to know why the subquery won't return 1 of the rows contain percentagetotal 88.00. SELECT STUDENTID, GRADEDTS, CETESTID, PERCENTAGETOTAL FROM ZZZ_DUMMYTESTS T WHERE PERCENTAGETOTAL = (SELECT MAX(PERCENTAGETOTAL) FROM Z...more >>

date convert format question
Posted by WebBuilder451 at 10/18/2005 8:23:04 AM
ni need to convert a date given as declare @thsDate as datetime set @thsDate = getdate() to an integer of YYYYMMDD thanks kes -- thanks (as always) some day i''m gona pay this forum back for all the help i''m getting kes...more >>

New index removes rows from result set. Bug?
Posted by jerryfoster7 NO[at]SPAM yahoo.com at 10/18/2005 7:50:35 AM
Ok, if you run the following simple piece of code: -------------------------- CREATE TABLE #Temp (Record_Date DATETIME ) INSERT #Temp VALUES('2005-06-29 12:17:48.140') --CREATE INDEX [IX_Record_Date] ON #Temp (Record_Date) DECLARE @Begin_Time AS SMALLDATETIME DECLARE @End_Time AS SMAL...more >>

Syntax help
Posted by rodchar at 10/18/2005 7:16:04 AM
hey all, I'm trying to convert my Access query so it will run on SQL Server but I'm having problem with syntax differences: UPDATE Transactions, InvoiceHeader SET Transactions.InvoiceID = [InvoiceHeader].[InvoiceID] WHERE (([Transactions].[CustomerID]=[InvoiceHeader].[CustomerID])); ...more >>

Help.. SQL Server system slows severely with time
Posted by John Kotuby at 10/18/2005 6:49:07 AM
We have a SQL Server 2000 transactional business production system that is installed at 20 different locations and has been running very well in all but 1 location that was installed over the weekend. The hardware setup "seems" to be rock solid according to the MS SQL Server performance guidelin...more >>

Tricky SQL Problem
Posted by Rob at 10/18/2005 6:26:55 AM
Hi all, I've got a difficult problem I'm trying to work out in SQL. I've got a set of data (see below) and I'm trying to choose records that match up to a target value. The issue is the sum of the records selected to match the target value must also match a target date, using a weighted date ...more >>

Suggestions for database document?
Posted by OKLover at 10/18/2005 6:17:08 AM
I want to retrieve the SQL Server’s database schema (ex: pubs) to WORD application to create a system design document, is any good suggestion for this? ...more >>

SELECT statement cross two machines ?
Posted by OKLover at 10/18/2005 6:11:01 AM
I have two machines, both have SQL Server 2000 installed. A's IP is 192.168.0.1, B's IP is 192.168.0.2. How do i use SELECT statement to SELECT a table's content from B machine to A machine's database?...more >>

Parse SQL statement for list of tables
Posted by Ben at 10/18/2005 5:35:09 AM
Hello, I would like to make a procedure of sorts that accepts as input a full sql statment and then is able to return a list (or print) of only the tables referenced in the sql statement. Is this kind of code available? Thanks. Ben...more >>

sp_processmail
Posted by Sammy at 10/18/2005 4:19:03 AM
Hi I am looking at getting users sending there static Sql Queries to a sql mail box to retrieve there queries.Sql mail is working fine but I have done something wrong on the query. I have set this up below. sp_processmail @subject = 'sqlquery', @dbuse ='pubs', @separator =' ' , @filetype...more >>

Insert/Update into a SQL table
Posted by karenmiddleol NO[at]SPAM yahoo.com at 10/18/2005 4:07:34 AM
I have the following keys in Consumption: - Plant - Material - Month - Year The above are the primary keys in the table and the following are non-key fields: - Quantity - Amount I have data stored in this table currently but many times I get feeds which are stored in the table: ...more >>

Spored Procedure
Posted by Peter Newman at 10/18/2005 4:01:03 AM
I have a baffiling problem trying to run a DTS from a VB6 application. The application is called from an event on an FTP server, but always hangs at the execute command for the DTS. If i reun that application as a stand alone exe its fine..... Im now wondering if i can get around this problem...more >>

A severe error occurred on the current command
Posted by Cheffe at 10/18/2005 3:22:04 AM
Dear fellow sufferers... I get the error noticed in the subjectline, while trying to put a 150MB ZipFile into a SQL-2000-SP4-DB. This is the way I do it: '************************************************************************************************** Public Function CYCLE__GisData_ZI...more >>

Index.rebuild and log files....
Posted by Joe at 10/18/2005 3:07:04 AM
Can somebody help me, I need to know what Index.rebuild does. Also the different types of log files in Sql Server. Please help, Joe....more >>

foreign key
Posted by vanitha at 10/18/2005 1:31:02 AM
hi friends, I want to check the relationship between tables before migration. so i wrote a procedure which will push the unrelated data from the source db(@i_oldDB) to the error database(@i_errorDb). alter procedure TransactionValidation ( @i_oldDb varchar(100), @i_errorDb varchar(100)...more >>

How to compact & repair a database in SQL Server?
Posted by Harshad Phadnis at 10/18/2005 12:31:04 AM
Hi, I am facing a problem. I have a table with indexes (integers). These occur out of sequence i.e. not in serial order. Due to this the performance has decreased. I have tried the following commands but of no help : 1) dbcc checkdb 2) dbcc dbreindex 3) dbcc indexdefrag I...more >>

text fields
Posted by Enric at 10/18/2005 12:26:02 AM
Dear folks, I am facing up hindrances when I move a table from one server to another one which contains 'text' fields. Sometimes I obtain errors such as: "field too large" or something like that. How do I work out this? Putting on the destination table 'varchar(5000)' instead of text 16...more >>

About DTS Import Wizard
Posted by Bob at 10/18/2005 12:02:12 AM
I use the DTS Import Wizard to copy one database to another. I notice that it does the importing of tables and data alphabetically. This causes some problems for me because I need some tables to be copied in certain order due to the relationships and constraints. Is there a way for me to us...more >>

SCOPE_IDENTITY() and "instead of" Triggers.
Posted by Rebecca York at 10/18/2005 12:00:00 AM
Here's a fun question :) If I have an instead of trigger on a table, which replaces the insert, how can I get the identity insert from the data inserted? --- example --- IF OBJECT_ID('dbo.tblTest') IS NOT NULL DROP TABLE dbo.tblTest CREATE TABLE dbo.tblTest ( ID INT IDENTITY(1,1) NOT NU...more >>

Create table Stored Procedure
Posted by DNKMCA at 10/18/2005 12:00:00 AM
Hi, Im tring to create a stored procedure with objective as 1) add new project details 2) create table with name as <projectcode>_MONTHSETTINGS pls correct my below code thanks in advance -DNK ------------------------------------------------------ CREATE PROCEDURE [dbo].[AddNewPr...more >>

Migration from DB2
Posted by Prashant Bharti at 10/18/2005 12:00:00 AM
Hi, We are migrating from DB2 to SQL Server 2000. We have used DB2 OLAP functions (rank, sum, etc.) quit liberally. How should be translate them in SQL Server. Thanks Prashant ...more >>

how to interrogate INSTEAD OF UPDATE trigger failure?
Posted by PWalker at 10/18/2005 12:00:00 AM
Hi, I was hoping someone could help me... I have a INSTEAD OF UPDATE trigger set up against a view: CREATE TRIGGER mytrigger ON mytableview INSTEAD OF UPDATE AS UPDATE mytable SET field1 = myfunction(inserted.field1), field2 = myfunction(inserted.field2), field3...more >>

Updating a Text Field -
Posted by Ben at 10/18/2005 12:00:00 AM
Hi I have declared a text field in a function and cannot seem to update it: DECLARE @tblImports TABLE(dm_ImportDesc VARCHAR(355), [Description] VARCHAR(355), RowId INT IDENTITY(1, 1)) ........ UPDATE @tblOutput SET Imports = CAST(Imports AS TEXT) + CHAR(11) I get the error - Error 403: I...more >>


DevelopmentNow Blog