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 2004 > threads for wednesday june 2

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

Select using short-circuit condition and breaking after first match
Posted by AA at 6/2/2004 11:45:40 PM
I need to do this, please help me :) I have one table with records like this Prefix Country 595 Paraguay 591 Bolivia 593 Ecuador 594 French Guiana I need to make a query that return the first row that match the first condition, for example Select * from...more >>


triggers - INSERTED table
Posted by whitegoose NO[at]SPAM inorbit.com at 6/2/2004 10:14:12 PM
Hi all, I'm writing a bunch of triggers for an off-the-shelf product to enforce some business rules not enforced by the standard product. Not ideal I know but its what I have to do. The application does not allow more than 1 record to be inserted at a time into any table. However, someone h...more >>

data type: table
Posted by popo at 6/2/2004 8:41:19 PM
can i define a dynamic SQL that use the data type table. eg. insert into @table + a dynamic sql ths...more >>

Tricky INNER JOIN
Posted by Maik Richter at 6/2/2004 8:15:55 PM
Hi guys, I need to join 2 tables with 2 criterias i.e.: The 1st key is the document number and after the 1st key matches there should be a 2nd check, i.e. the year should be checked. I got no idea how to bring that into SQL. Example: Table1: Row 10: DocNumber: 1 / Year: 2004 Row ...more >>

eliminating redundant data
Posted by gordy at 6/2/2004 8:06:40 PM
edit: this came out longer than I thought, any comments about anything here is greatly appreciated. thank you for reading My system stores millions of records, each with fields like firstname, lastname, email address, city, state, zip, along with any number of user defined fields. The appli...more >>

Msg 8163 comes up
Posted by Gerald Hopkins at 6/2/2004 7:31:46 PM
I am getting this error message: Server: Msg 8163, Level 16, State 4, Line 7 The text, ntext, or image data type cannot be selected as DISTINCT. when I run this SQL in QA. Can anyone tell my why I am getting this error even though I do not have a DISTINCT keyword in my statement? Is there...more >>

Distinct, record set in presorted order
Posted by Steve H at 6/2/2004 6:51:02 PM
Hey group.. I hope I ask this thoroughly. We are trying to write a stored procedure that needs to return a distinct result set in a pre-determined order, yet the column determining the order is not returned. Let me clarify: For simplicity sake, there is a table that is getting populated in the f...more >>

SQL query
Posted by Enoch Chan at 6/2/2004 6:40:09 PM
I have a table TB_History with fields id, x, y, insert_date and would like to write a SQL to do the following 1. retrieve those records, all four fields required, which are not older than 5 minutes and; 2. Only 1 record for EACH id and should be the lastest (according to the insert_da...more >>



Duplicate Records in Database
Posted by Lontae Jones at 6/2/2004 6:26:05 PM
Hello I have numerous duplicates in my database I am trying to find out how many. The duplicate is identified by a contact field and address field are the same. I have a front end app that has this info stored in a table called Contact1. In contact1 Address1 and Contact are the same. How can I...more >>

Question about check contraints
Posted by Pro at 6/2/2004 6:21:16 PM
Hi, I'm viewing the setting in a table and find an expression in check contraints. ([colorId] like '\d{3}|([A-Z0-3]){3}') May I know the meaning for this expression? Thx Charles ...more >>

Transaction duration and the Log
Posted by Wells Caughey at 6/2/2004 5:36:51 PM
Hi, I know that performing "long" transaction is a bad idea and should be avoided when possible in SqlServer. I have heard something to the effect that long transactions make SqlServer do extra work when it recovers should it crash in the middle or toward the end of the transaction. My quest...more >>

output stored procedure
Posted by mike at 6/2/2004 5:17:36 PM
hi. a little new to this so thanks for any support. i have a sql db attached to an access db. i have a sql stored procedure that creates a crosstab. i thought i'd be able to just open the sp in access and view the results but i keep getting a time out error. i used to have access email the...more >>

autoincrement problem
Posted by patrick stirling at 6/2/2004 4:56:12 PM
Hi, Im logging web site hits to sqlserver 2000, using an autoincrement primary keyed field. (the first column below) This field should go up by one with every hit, but when I view the output it is jumping around a fair bit - sometimes 2 ,others 4 or 12, but most often just one. Here is so...more >>

Description of table
Posted by Tina Ma at 6/2/2004 4:41:40 PM
Hi, Does anybody know where does SQL Server store the column description of tables? Thanks, Tina ...more >>

Can I do this using one SQL statement
Posted by Simon at 6/2/2004 4:27:59 PM
I have a table defined as create mytable (mydate datetime) I need to populate this table with 30 years worth of dates (roughly, 10,000 entries - one for everyday for the last 30 years). I was wondering if there's a snazzy way of doing this via one INSERT INTO mytable SELECT.... statem...more >>

SPROC help
Posted by Timothy V at 6/2/2004 4:25:10 PM
Hi, I'm new to stored procedures and I'm trying to do something but unsure how to. I have 3 columns: custID INT custFName VARCHAR(30) custLName VARCHAR(30) I want to create a stored procedure that inserts a record with custID being an OUTPUT, not an INPUT. In other words, how...more >>

Exec statements in stored procedures
Posted by Jeremy Chapman at 6/2/2004 4:09:52 PM
In my stored procedure I have to selects, the first one in an exec, and the second one is just a standard exec. The user only has exec access to the stored proc, no select access to tables. The second select * from CourseInstance works fine but the select in the exec errors out with a selectp...more >>

Stored proc select denied error
Posted by Jeremy Chapman at 6/2/2004 3:38:42 PM
I two databases on the same server. I'm logged in with a user that has access to both databases. The user has no select/delete/update rights to any tables. On the first database the user has exec rights to a stored procedure. That stored procedure selects * from two tables with a join. 1 ta...more >>

Decimal Data Type, is rounding....ah!
Posted by mitchel at 6/2/2004 3:35:23 PM
Hi, I am submitting the following number to my SQL table to a field with a Decimal Data Type: 1.5873015873 But when I bring back the number via ASP or check it in Enterprise Manager it records: 2 These are the settings for the field: Decimal Description: blank Default Value: (0) ...more >>

transfer data
Posted by frazer at 6/2/2004 3:12:27 PM
hi I would like to transfer data from one database on a server to another server. But i want to specify the order of teh tables that are to be transfered. like table a before table b. what is the best way to do this? is there any sample for it? thnx ...more >>

stored procedure maintenance
Posted by Han at 6/2/2004 3:01:03 PM
Hi I've a sp like this create proc usp_tableX_modif @column1_key int @column2 nchar(10) @column3 nchar(10 a begi update table set column2 = @column2 column3 = @column where column1 = @column en The question is: How can I avoid maintenance problem wich arises with th...more >>

Tree Structure & Triggers.
Posted by James E at 6/2/2004 2:53:18 PM
I have a table in my database that basically represents a tree structure, Table 'CostCodes', columns as follows: ID: bigint ParentID: bigint Import (bit) InheritImportValue (bit) I have a trigger which I was hoping would enable me to check to see if any children of the updated parent,...more >>

SQL SP
Posted by MarcusBSB at 6/2/2004 2:11:13 PM
I have this stored procedure below but when I try to run it from a webpage it returns a error message of too many arguments... SELECT DISTINC eb.TopicName, eb.AuthorFirst eb.AuthorLast, oe.ecik Responses = Count(oe.id)/4, Average = AVG(CAST( oe.Answer_Num as decimal) INTO #TempAl FROM emed_E...more >>

Calculating overlapping time periods
Posted by Jonathan at 6/2/2004 2:04:51 PM
I have a challenging query that has me stumped. What I need to do is given a set of records containing time ranges, I need to calculate the number of overlaps per quarter hour for a specified time range. Example: The following would be the time ranges used to calculate overlaps time_start ti...more >>

Select Permission Denied for Exec('Select * from myTable') in stored procedure
Posted by nima at 6/2/2004 1:56:05 PM
Here is my Stored procedure. If I uncomment the first commented line it works like a charm. If I uncoment the second commented line I get SELECT permission denied on object 'MyTable', database 'myDB', owner 'dbo' Why? And is there a way around this. I have a stroed procedure that uses complic...more >>

Help with SQL snyntax, unexpected results
Posted by m miller at 6/2/2004 1:39:05 PM
Hi, There must be some trick to this or I have expectations that can't be met. Here are my syntax: SELECT territory, dist_name, SUM(CASE WHEN Date1 <= Date2 THEN 1 ELSE 0 END) AS od, COUNT(PROJECT) AS cnt, SUM(CASE WHEN Date1 <= Date2 THEN 1 ELSE 0 END) / COUNT(DIST...more >>

Application role.
Posted by David at 6/2/2004 1:26:01 PM
IM trying to write a stored procedure that takes an database and application name as input. It then looks in a sql database for the corresponding password and then sets the application role. I am having problem using a variable for the password in the following satement. Execute( 'sp_setapprole '...more >>

Problem with restore
Posted by Johnny Silvestre at 6/2/2004 1:23:26 PM
Hi friends i need help ! I apply the following statement FIRST: >>RESTORE DATABASE MYDB >>FROM DISK = 'E:\mydb.bkp' >>WITH REPLACE, >>MOVE 'MYDBD01' TO 'E:\MYDBD01.DAT', >>MOVE 'MYDBL01' TO 'E:\MYDBL01.LOG', >>NORECOVERY THEN: >>RESTORE LOG MYDB >>FROM DISK = 'E:\MYDB_T16.BKP' >>WI...more >>

File Group and Table
Posted by Prabhat at 6/2/2004 1:14:24 PM
Hi All, I need query that will determine which tables are created on primary file group or secondary file group? I know that i can exectute sp_help 'tablename' to see on which file group the only one table is. But that is very difficult to do for all tables. So any single query to find th...more >>

newbie view question
Posted by george at 6/2/2004 1:11:03 PM
I have the following view SELECT dbo.Patient.*, dbo.PatientAddress.AddressID AS CAddressID, dbo.PatientAddress.PatientID AS CPatientID, dbo.Address.AddressID AS Expr1, dbo.Address.Address1 AS Expr FROM dbo.Patient INNER JOIN dbo.PatientAddress ON dbo.Patient.P...more >>

DBCC Reindex if (Reorg < 80%)
Posted by Mike at 6/2/2004 12:57:38 PM
I have SQL script listed below that I use to reindex my database tables. Please help me modify my SQL script if the table index is less than 80% unorganized then reindex. Thanks, Mike DECLARE @TABLE_NAME sysname DECLARE @SAVE_STRING_TABLE VARCHAR(255) DECLARE columnsele...more >>

A big transfert is about to begin...
Posted by +The_Taco+ at 6/2/2004 12:55:00 PM
I really need a solution about this... We are about to launch a big database transfert that will last about 6 day. So we can't stay here for 6 day looking if there is any errors during the transfert. So is there any ways with the SQL profiler to lauch a message (by e-mail or by cell phone...more >>

1934 Error
Posted by Arbiter at 6/2/2004 12:16:36 PM
I have a tricky problem. I am getting a 1934 error when running a stored procedure. The actual error message is: INSERT failed because the following SET options have incorrect settings: 'ANSI_NULLS., QUOTED_IDENTIFIER'. However, changing these options on the stored procedure allows t...more >>

single primary constraint question
Posted by Frank Wisniewski at 6/2/2004 11:39:08 AM
Hi All, Is it possible to make a constraint on a bit field where only one bit is allowed to be true? I have a table with contact numbers and one field is called "IsPrimary", this is a bit field. I want to use this field allow only one primary contact number. I know how to do this from code ...more >>

System Stored Proc to Parse/Validate Sql statement like Query Analyzer does
Posted by William Ryan eMVP at 6/2/2004 11:30:23 AM
I know someone posted this in the ADO.NET group a few months ago but I sure can't find it. Does anyone know what this is? It's the proc that QA runs whenever hit the check button. Thanks, Bill -- W.G. Ryan, eMVP http://forums.devbuzz.com/ http://www.knowdotnet.com/williamryan.htm...more >>

error: "Could not find database ID 102. Database may not be activated yet or may be in transition"
Posted by matthew c. harad at 6/2/2004 11:16:05 AM
hello i am receiving the following error at weird times Could not find database ID 102. Database may not be activated yet or may be in transitio the latest incident was doing an update query of the type update tabl set column = x.column from table join select ...more >>

How can I detect the "state" of a trigger?
Posted by Joe Fallon at 6/2/2004 10:56:05 AM
Is there a command that I can run in T-SQL code that will tell me whether a given trigger is enabled or disabled? Thanks! -- Joe Fallon ...more >>

Q: Query - Price on specified date for each item
Posted by Pyro at 6/2/2004 10:47:20 AM
Here is my problem: create table #itemprice ( ID int IDENTITY (1, 1) NOT NULL, ItemID int NOT NULL, PriceDate smalldatetime NOT NULL, Price money NOT NULL ) SET NOCOUNT ON INSERT INTO #itemprice VALUES (1, '2004-04-29', 10.0) INSERT INTO #itemprice VALUES (1, '2004-05-01', 11.1) IN...more >>

SQL/HTML spacing question
Posted by me NO[at]SPAM privacy.net at 6/2/2004 10:36:29 AM
I found a problem in a table I'm reading and displaying on a web page. The problem is that the data, for whatever reason has 2 spaces in it. When I do the display on the web page, only 1 space renders in the combo box. If I run the sql from query analyzer, it shows 2 spaces. The result: "AB...more >>

Encrypting data
Posted by enric at 6/2/2004 10:11:04 AM
Dear all I need a stored procedure, function or something like that which take a table and then, encrypt all the fields into another one. I mean, one script to be able to encrypt and another for to deencrypt Thanks in advance and warm regards ...more >>

Query scanning entire clustered index instead of seeking in non-clustered index.
Posted by delphidev2000 NO[at]SPAM yahoo.com at 6/2/2004 10:02:28 AM
I have a situation where a query is doing a entire scan of a clustered index instead of using a seek against non-clustered index (which would be faster). Here is a hypothetical example of the structure of my data. Assume that I have the following table with three fields and the accompanying ...more >>

I deleted a table by mistake
Posted by Fariborz at 6/2/2004 9:06:04 AM
is there anything I can do to get it back?...more >>

SQL Server + ADO = empty fields
Posted by rc at 6/2/2004 8:40:48 AM
Hello, Back end - SQL Server 2000 Front end - Access 2000 I have a basic table with about 20 columns. I retrieve data via a stored procedure. If I run the stored procedure (the select statement) in Query Analyzer, the data returned is exactly what I requested. In Access...more >>

Ayuda
Posted by Martin at 6/2/2004 6:16:06 AM
tengo varias tablas que tiene fechas en formato numerico , necesito crear una etl que me cambie esas fechas automaticamente a datetime, y que quede la tabla modificada......more >>

Deferred Constraint Checking
Posted by Mal at 6/2/2004 5:06:01 AM
Hi All I was wondering if any one could tell me if deferred constraint checking (ie not checking referential integrity until a transaction is committed) is available in SQL Server 2000. If so, how it is implemented Thanks mal...more >>

t-sql job step restriction, osql
Posted by OJ at 6/2/2004 4:57:06 AM
Hi, I need to implement job consisting of many t-sql steps which have more than X characters (what is restriction?), so I have to implement osql in these steps. However, each of these steps will succeed regardless of if they had some error or not. How can I control if osql step really com...more >>

Merging the RTF files
Posted by Ramnadh at 6/2/2004 4:36:03 AM
Hi I have saved two RTF (RichTextFormat) Data into the Database in two different tables Now i need to merge those two RTFs into one RTF. How can i do this in SQL Server Can anyone help me Regards Ramnadh....more >>

ISQL and ASNI_NULLS
Posted by Ben Reese at 6/2/2004 4:21:05 AM
I am trying to run some Cross database queries defined in a stored procedure from the ISQL command ine like this EXEC master..xp_cmdshell 'isql.exe -S MySQLServer -E -d MyDB -s , -w 200 -Q "EXEC uspMyStoredProcedure" -o "C:\Output.csv" The output file contains this error message "Heterogeneous ...more >>

Dynamaic SQLs
Posted by BeBe at 6/2/2004 3:30:48 AM
I use two dynamic SQL to contruct a SQL in a stored procedure as below. 1st: SQL for inserting record into temp table 2nd: Extract record from the temp table in 1 When I execute the stored procedure in query analzer, it returns data. However, when I execute in crystal report. It prompte...more >>

Dropping Unique Indexes
Posted by Tony C at 6/2/2004 3:18:51 AM
Good Morning Newsgroup PLEASE NOTE, IF YOU HAVE ALREADY REPLIED TO MY ORIGINAL POST (Dropping Indexes) THEN PLEASE DO NOT RESPOND TO THIS NEW POSTING. 'DROP INDEX' STATEMENTS WILL NOT WORK WITH UNIQUE INDEXES!! I am very new to T-SQL Programming, so I need a little bit of help. I am w...more >>

SP Output Parameter Question
Posted by David Johnson at 6/2/2004 2:51:06 AM
I'm checking some legacy SP code and notice that an OUTPUT parameter is declared prior to other INPUT parameters, from what I can tell this OUTPUT parameter is only used as an INPUT parameter Is it just good practice to declare any OUTPUT parameters after INPUT parameters in a SP or is it illegal ...more >>

DTS Export to CSV
Posted by Adam Stewart at 6/2/2004 2:31:03 AM
Hi all i am having a very strange issue when trying to create a very simple dts package. I have a table (see sql below) and i have created a new sql dts package. In my package i have a sql connection to the db (this is fine) and a text file (source)(this is also fine). I then define a data pump ta...more >>

derived table issue
Posted by Ming at 6/2/2004 2:11:03 AM
Hi I got a timeout error in running a complex SQL, part of the SQL are as below (simplified) select * fro (select * from tableA where condA) table LEFT JOI (select * from tableB where condB) table ON someConditio There are about 600,000 records in tableA, with condA, it will return about 3...more >>

Stored Procedure parameter problem
Posted by Alex at 6/2/2004 1:52:29 AM
I use MS Project VBA code to get data from my SQL Server database. The query below works fine sQuery = "execute stored_procedure_name 'TEST V7.1', 'XX', '012'" but if I use variables instead I get an error if the parameter contains a "." or space. Proj="TEST V7.1" Proj2="XX" sQuery = ...more >>

Tricky Group By Clause
Posted by n_j_dawson NO[at]SPAM yahoo.co.uk at 6/2/2004 1:15:18 AM
Hi, If I have a table like this: UserId ValueDate Amt 1 10/06/04 10 1 12/06/04 15 1 13/06/04 -13 2 11/06/04 10 2 12/06/04 14 2 20/06/04 -2 2 30/06/04 10 I'd like to sum the amount and group on V...more >>

System function/procedure to check existence of a constraint?
Posted by Sheetal at 6/2/2004 1:06:06 AM
Hello Is there any System function/procedure to check the existence of a constraint(indexes, PK,FK,UQ,etc) in the database Thanks in advance Sheetal...more >>

Dropping Indexes
Posted by Tony C at 6/2/2004 12:43:38 AM
Good Morning Newsgroup I am very new to T-SQL Programming, so I need a little bit of help. I am writing T-SQL Programmes using SQL Server 7.0 to drop then re-create indexes in a bunch of databases. I am OK with dropping nonclustered indexes, I am also OK with creating the Indexes, howe...more >>

DRI
Posted by Evandro Braga at 6/2/2004 12:02:10 AM
Hello all, after select a user in the database (using Enterprise Manager for SQL-Server 7.0), and click Permissions, all objects are listed. All tables (only) have an option DRI to be selected. What is this column / property for ??? best regards, Evandro ...more >>


DevelopmentNow Blog