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 > june 2005 > threads for thursday june 9

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

Backup from server 1 and restore to server2.
Posted by Tri at 6/9/2005 10:28:02 PM
Hello . I use sql enterprise manager to do backup for the database from the server 1. the file is under .dat. can i use this file and restore it to another database server ( server2)? If it yes, can you show me how to do it? can i use sql enterprise manager to retore sql da...more >>


Filter remaining rows
Posted by sharman at 6/9/2005 9:34:02 PM
I am learning to write SQL Queries. I have two exactly similar tables - first has 1000 rows and the second has 100 rows. Out of these both the tables have 90 rows in common (Which I ca find using the INNER JOIN). How can I filter out the remaining 910 rows in the first table and 10 rows in the...more >>

Nullable Unique Constraint
Posted by WJ at 6/9/2005 7:55:36 PM
I have a table and want to put a unique constraint on a nullable column. I don't think I can do this and I think I will have to check for uniqueness on an Insert / Update trigger (selecting from the inserted buffer where column is not null). Is there a way to do this with a constraint instead ...more >>

Hierarchical Result Set!
Posted by AJ at 6/9/2005 6:07:02 PM
I have the following table structures. question - question - text question_opts - question_opt_id - opt_text One question can have many options. When i want to retrieve a result set containing a question with all its options i get a copy of the question with each option retrieved....more >>

stored procedure and views
Posted by Calvin X at 6/9/2005 5:00:56 PM
Hi All, Is it possible to use a stored procedure (one with parameters) result as the value for a column in a view. I know you can do this for UDF's but I cant make my stored procedure into a udf because I am building a dyanamic SQL statement and using sp_executesql. Which of course you a...more >>

trigger doesn't seem to work w/cursor
Posted by Keith at 6/9/2005 4:15:01 PM
Hi The purpose of this trigger is this; When "UNITNBR" gets updated, I want to change the ID field to a concatenation of the new UNITNBR and some other fields. So, this is what I've got: =============================== CREATE TRIGGER TRG_UPDATE_ID ON dbo.tblRESULTS FOR UPDATE AS ...more >>

SELECT for consecutive runs ofvalues
Posted by Joel Reinford at 6/9/2005 3:57:07 PM
I am looking for a way to extract starting and ending points for a run of values for a given foreign key. Given this scenario: CREATE TABLE Intervals ( PkValue int identity, FkValue CHAR(10) NOT NULL, StartYear INT NOT NULL, EndYear INT NOT NULL, CHECK (StartYear <= EndYear) ) ...more >>

multi excel files to sql server
Posted by christy at 6/9/2005 3:17:03 PM
I am following the instruction in http://www.sqldts.com/default.aspx?6,103,246,0,1 to loop thru a directory and get multi excel files to sql. excel files: same layout, in the same folder and going to the same sql table I am using the transform data task for excel -> sql step. the problem i...more >>



Grouping by defined number of days.
Posted by Jack at 6/9/2005 3:05:12 PM
This is a question about custom grouping by a defined number of days. I would like to have a start date, then group the data in 3 day blocks. Is this possible ?? Ideally, I would like to have a start date, end date, and all the little intervals in-between, even if no data is in those interv...more >>

Too much to join
Posted by Zeng at 6/9/2005 2:56:31 PM
Hi, I'm very sure this is a classic performance/design problem that every experienced db designer knows about. Basically in an application with a feature that requires to frenquently join 3-4 tables together to return a list of something useful, it will run into performance problem including ...more >>

How to optimize this query
Posted by gsinthoju at 6/9/2005 2:47:46 PM
In following code online_test_responses contains 16 million records and i have bundled it into stored proc and try to execute it it never runs. It runs 40-50 hrs but nothing happens. I have indexed the tables properly too. INSERT INTO objective_difficulty(code, correct, incorrect, skipped, ope...more >>

Duplicate Column Names - A Good Trick to Avoid Temp Tables?
Posted by steveeisen NO[at]SPAM yahoo.com at 6/9/2005 2:42:50 PM
A data base administrator objects to a select query I wrote, on performance grounds, because it uses a temporary table. So I simplified it, cutting elapsed time by 85%. However, before going into production, I wanted to run this by someone -- say, someone here -- because the fast query uses th...more >>

update statement
Posted by J-T at 6/9/2005 2:22:56 PM
I'd liekt o compare one record from one table with another exactly identical record (Schema wise,not data) from another table and if they are different in 3 fields (feild1,feidl2,feild3) then I update the second one.The problem is that is one of these fields in either tables is null ,then the...more >>

create table with dynamic constraint
Posted by Dave at 6/9/2005 2:09:05 PM
I am trying to create a table with the type of constraint I don't see in any of the help resources. Say the basic table structure for table t1 is (colType int, colDesc varchar(10), colMiscellaneous varchar(100)) I want to limit the combination colType-colDesc thusly: If the combination is...more >>

Need advice for publishing SQL DTS Packages / Automating changes for prod
Posted by Sean Aitken at 6/9/2005 1:59:54 PM
Hi, We are trying to simplify our lives a bit and be able to develop a DTS package in dev and have it pushed to test and stage, with the minimal amount of modification to the packages. It seems that the client 'alias' option works well for SQL connections, however, when we have a file ex...more >>

importing delimited files...
Posted by M.Smith at 6/9/2005 1:27:33 PM
Hi, I am importing a batch of comma delimited files. The process reads several files and then moves them to an archive folder. The process reads each line of each file into a temp db, but it does not parse the line out onto fields. It just dumps the whole line into the table. What I nee...more >>

Select statement
Posted by Aleks at 6/9/2005 1:18:41 PM
Hi, I have a table with fields "userid1" and "userid2" Those are int fields and have numbers, most of the times different like userid1 = 34 userid2 = 35 But sometimes they have the same values in a record, like: userid 1= 34 userid2 = 34 If I do: Select userid1, userid2 from ...more >>

subquery help
Posted by Jen at 6/9/2005 1:01:11 PM
Hello, I need help building a query: I have Multiple single items with different statuses (one item can have several diff. statuses). The items and statuses are in different tables. I just want to have a recordset with each unique item and latest status. Here's what I have now. 1st Que...more >>

Database adapter?
Posted by Bob Castleman at 6/9/2005 1:00:17 PM
So what exactly is a database adapter? There is a company that wants to provide reporting services to our customers using a proprietary technology, but all they will tell us is they use an adapter and a listener through ODBC. Seems to me that an adapter is just a fancy way of saying a wrapper ...more >>

Case setup for multiple fields
Posted by tshad at 6/9/2005 12:54:43 PM
I am trying to return some text to describe some bit fields. For example, I have the following table: CREATE TABLE [dbo].[TestStatus] ( [id] [int] IDENTITY (1, 1) NOT NULL , [FullTime] [bit] NULL , [PartTime] [bit] NULL , [Temporary] [bit] NULL , [Seasonal] [bit] NULL , [Contract] ...more >>

Why is Insert causing duplicate records?
Posted by Earl at 6/9/2005 12:52:10 PM
Hopefully this is obvious because I cannot see why I am creating duplicate records with this Insert. The Staging table has 25,000 records, but after I do the Insert, I have 30,000+ records in the Prospects table. INSERT INTO dbo.Prospects (StreetID, HouseNumber, FirstName, LastName, AgeRa...more >>

returning multiple values in a subquery
Posted by Blasting Cap at 6/9/2005 12:49:42 PM
I have a report that I've looked at with regards to a crosstab query - which doesn't really give me what I need. I have to produce a report where I provide some customer information, and the channels in which they purchase items from us. A customer can purchase items under several differen...more >>

Primary Key, bigint or char?
Posted by Tim Baur at 6/9/2005 12:45:59 PM
Hey guys, just a quick question for you. I think I know the answer, but I would like to get the expert's opinions... I have a primary key called RequestID that is to be constructed of the year, month, day, and a four-digit sequence number with leading zeros. An example of the ninth Reques...more >>

Just a concept
Posted by Enric at 6/9/2005 12:05:06 PM
Dear all, What does 'federated databases' mean? I haven't idea if I'm currently using them in our Microsoft' international environment I've got SQL remote servers but.. Thanks a lot for your support,...more >>

update query
Posted by FRR at 6/9/2005 12:05:02 PM
Hello - Is it possible to update a char field to include only the first 5 characters? Can I use the left function to accomplish this? The problem is zip codes for a customer db were incorrectly loaded with four trailing zeros. For example, instead of 53511, the field would contain 53511...more >>

dynamic sql w/sp_executesql - servername parameter issue
Posted by andrew007 at 6/9/2005 11:31:10 AM
I know that we can't pass serername/tablename as a parameter to sp_executesql as follow... But I have to work around sql injection vulnerability too.... I want to use some type of paratertize way but...can't find a solution yet. Please help!! create proc SaferDynamicSQL(@serverName nvarchar(...more >>

Case Syntax
Posted by vvenk at 6/9/2005 11:27:54 AM
I want to update teh columns of a database if the value is either 0 or ''. I tried using the statement below: UPDATE [medDRA].[dbo].[HLT_PREF_TERM] SET [HLT_CD_N] = CASE [HLT_CD_N] WHEN 0 THEN NULL ELSE [HLT_CD_N], [HLT_CD_C] = CASE [HLT_CD_N] WHEN '' THEN NULL ELSE [HLT_CD_N] ...more >>

ER Diagram
Posted by Vince at 6/9/2005 11:24:57 AM
I was wondering if anybody knows of a freeware utility that could help in drawing ER diagrams of a database from the SQL Server. Is using Visio the easiest approach? TIA, Vince ...more >>

assigning process priority to transactions?
Posted by Bae,Hyun-jik at 6/9/2005 11:21:30 AM
I am using ADO 2.8 and SQL server 2000. Is there any way to assign process priorities to multiple DB connections? For example, consider that there is a long-time taking transaction and many short-time transactions running on a server machine. I want to assign low priority to the long-time t...more >>

Scandinavian collation
Posted by Gunnar at 6/9/2005 11:07:19 AM
Hi! Using SQLServer 2000 I am making a database which shall be used in the hole Scandinavia (Norway, Sweeden, Denmark, Finland) The collation should be ending with "..._CI_AS", but I am not sure if I should use Finnish_Swedish_CI_AS, or Danish_Norwegian_CI_AS, or is there any other su...more >>

Primary key at the beggning of each record
Posted by J-T at 6/9/2005 10:32:03 AM
Are primary keys always the first columns in each record? What's the disadvantage of having them for example in the middle of the records? what happens? Thanks ...more >>

Weird resuld from SP
Posted by Chris Lieb at 6/9/2005 10:30:18 AM
I have a SP that sets a flag on some records in a table. Whenever I run it in QA, it says: (... row(s) affected) (3 row(s) affected) Since I have only one UPDATE statement that is fired only once, why am I getting the extra '3 row(s) affected' message? When I execute the UPDATE with...more >>

Proper Case Syntax on Name Column
Posted by Lontae Jones at 6/9/2005 10:17:04 AM
Hello, I have a Column called Name varchar(50). Data was imported from an excel spreadsheet in all caps. How can proper case all fields in this column that is in CAPS?...more >>

Time Math
Posted by Steve Murphy at 6/9/2005 9:54:40 AM
I'm trying to do a calculation of the time between a start time and an end time and represent the result as a real. What is the best way to approach this in a query? Thanks, Steve Murphy ...more >>

Chunked Delete?
Posted by xenophon at 6/9/2005 9:45:17 AM
I can't truncate a table because I'd lose the Identity columns that are referenced in other tables, but I do need to delete all 2 million rows in there. Is there a way to recusrively delete rows in say 1,000-row chunks to keep the transactions small and DB load lighter? Thanks. ...more >>

Suppress raiserror in transact-sql job?
Posted by nick at 6/9/2005 9:07:18 AM
I have a step in job which call sp_help_jobschedule @job_name='...' @schedule_name='...' to check if any schedule already exists in the job. However, it raiserror if the schedule doesn't exists and it cause the step failed. How to omit the exception in Transact SQL? Like catch the except...more >>

How to do this in a report?
Posted by Blasting Cap at 6/9/2005 8:53:26 AM
I have to write a report in SQL that takes the following data structure: CREATE TABLE [dbo].[Sales_Customer_List] ( [cust_no] [char] (10) NOT NULL , [cust_name] [char] (35) NULL , [distr_channel] [char] (2) NOT NULL , [sold_to_sales_grp] [char] (3) NULL , [ship_to_sa...more >>

Select into
Posted by TS at 6/9/2005 8:05:04 AM
Thanks to the experts of this discussion group, I used the following code to select two columns from the following table: Room# Capacity Description 201 2 Small 202 1 Large Into a new table that looks like this:...more >>

Select Question
Posted by akej via SQLMonster.com at 6/9/2005 8:02:21 AM
Hi, suppose i have table with values: col1 | col2 | col3 | col4 | -----|------|-------|---------| zzz | 12 | 34 |1/2/2004 | zzz | 155 | 22 |3/2/2004 | zzz | 12 | 1 |9/3/2004 | ddd | 2 | 33 |3/2/2004 | ddd | 23 | 12 |4/2/2004 | ..........................more >>

Amazing logical error in sql query
Posted by huseyin_akturk at 6/9/2005 7:56:54 AM
Additionally, if I write this query; SELECT * T1, T2 WHERE T1.NAME = T2.NAME AND T1.VALUE = T2.VALUE There is no result - huseyin_aktur ----------------------------------------------------------------------- Posted via http://www.codecomments.co -----------------------------------------...more >>

Amazing logical error in sql query
Posted by huseyin_akturk at 6/9/2005 7:42:19 AM
Hi, I have got two tables as T1 and T2. Their attributes are same; NAME (nvarchar(255)) VALUE (float) and their entries are; T1 A 7100 B 7200 C 7300 T2 A 7100 B 7900 I am running this query. SELECT * T1, T2 WHERE T1.NAME = T2.NAME AND T1.VALUE < T2.VALUE But result is; A 71...more >>

Profiler Specific Stored Procedure
Posted by Kalvin at 6/9/2005 6:55:50 AM
I would like to run profiler to watch a specific stored procedure. I have Events of RPC:Starting and RPC:Completed. I have a filter on the ObjectID, DataBaseID, ObjectType(16), and I have also tried a filter on the name of the SP. When I run profiler I get rows for execution of all stored pro...more >>

different records result if a use N (unicode data)
Posted by Filippo at 6/9/2005 6:50:04 AM
A same query with a NOT LIKE statement and a wild character % returns different records result if a use N (that means that the string follow is unicode data) or not. Par example: select * from company where company_name not like N'%' select * from company where company_name not like '%'...more >>

release the Database Locks...
Posted by hngo01 at 6/9/2005 6:17:02 AM
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE GO BEGIN TRANSACTION SELECT * FROM table1 WITH (ROWLOCK)where autoID=2 GO IF I execute this sql statement then that will prevent others users to update this record. How can I prevent others users from SELECT this record? How can I unlock /...more >>

Disregard null parameter in WHERE clause
Posted by decland NO[at]SPAM petml.com at 6/9/2005 3:41:21 AM
I have a problem optionally using a parameter to query a second key column in an outer joined table: DROP TABLE Sub; DROP TABLE Main; CREATE TABLE Main ( main_key_col INTEGER NOT NULL PRIMARY KEY, main_data_col VARCHAR(15) NOT NULL )' CREATE TABLE Sub ( main_key_col INTEGER NOT NULL REFE...more >>

YTD problem - adding extra field to table
Posted by ChrisB at 6/9/2005 2:28:04 AM
Currrent table (TABLEA) A B Month Value YTD(?) 1601 60000 1 557.2938 557.29 1601 60000 2 557.2938 1114.58 1601 60000 3 557.2938 1671.87 1601 60000 4 557.2938 2229.16 1601 60000 5 557.2938 etc 16...more >>

Calculating the adjustment of employee hours
Posted by ngorbunov NO[at]SPAM onetouchdirect-dot-com.no-spam.invalid at 6/9/2005 1:01:37 AM
I work for a telemarketing company. I have a table that looks lik this Project Emp Task Hour A 1 sales 1 A 2 sales 1 A 3 sales A 4 sales 2 A 5 QA 1 A 6 Audit For project A, I need the total hours for tasks QA and Audit. In thi case it would be 15 hours. Then I need to take that 15 ...more >>

query on recursive table
Posted by dot at 6/9/2005 12:00:00 AM
Hi, Suppose I'm working on a database containing 2 tables: tStudent (student information) ======== |----------------------------------| | studentID | studentName | deptID | |----------------------------------| | 504001 | John Doe | 10001 | | 504005 | JI Jane | 200 | |--...more >>

Any facility to hold string data of length more than 8000 characters?
Posted by Su Man at 6/9/2005 12:00:00 AM
Hi, I have a typical scenario in one of our application. In a Stored Procedure, I need to get values from different fields and form a select statement. The problem here is each field may be upto a length of 8000. So after forming the final query it will exceed length of 8000. How to concate...more >>

Address Selection Query
Posted by Chuck Reif at 6/9/2005 12:00:00 AM
I've been wondering if there was a better way to accomplish the following task, and any help or suggestions would be welcomed. I work on an application in which customers can have multiple address rows, which each customer having at least one row, marked as their default address. Address rows...more >>

Release date of SQL Server 2005
Posted by John Baima at 6/9/2005 12:00:00 AM
I don't know if this is interesting or not, but if you are interested in SS 2005, you may want to check out: http://blogs.technet.com/mat_stephen/archive/2005/06/07/406023.aspx -John ...more >>

Making a view
Posted by John Baima at 6/9/2005 12:00:00 AM
My brain is locking up again. I would like to make a view with the Tech_ID and the most recent, non-null value of TechWOProduct_WorksheetNumber. Thanks for any help -John CREATE TABLE [tblTech] ( [Tech_ID] [int] IDENTITY (1, 1) NOT NULL , [Tech_EID] [varchar] (50) COLLATE SQL_Latin1_General...more >>


DevelopmentNow Blog