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

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

Avoiding temp tables
Posted by davidol NO[at]SPAM hushmail.com at 3/7/2005 11:53:24 PM
Dear all, I'd like to rewrite this update statement without using a temp table. For each row with duplicate my_id's, the reference_no field should be set to the number of duplicates for that id. When I try rewriting this as a single statement I have problems getting 'at' the calculated dupl...more >>


How to create views with SQL-NS
Posted by at 3/7/2005 10:07:58 PM
I am doing research into how to best allow developers to visually add views to a database using our in-house system (.NET Windows apps + SQL Server back end). Since Enterprise Manager's Access-like "New View" component is easy to use, I thought that might be nice to integrate into our syste...more >>

Linked server & transaction connection
Posted by whiteegg at 3/7/2005 9:05:03 PM
Hi all, I've a local server and a linked server, which I need to update both servers' tables. But I encountered the error "Can't start more transaction in a session'. Following is the structure of the code in the program: ----------------------------------------------------- Begin Tra...more >>

Query to count physician encounters
Posted by richardb at 3/7/2005 8:37:03 PM
I need to count the total number of patient visits accumulated by each provider in a medical practice between selected dates. I am using the table of charges. Each visit may include several individual charges during the visit, but I want to count the visit only once. Therefore I used this st...more >>

modifying sql server 2000 database
Posted by Wendy Elizabeth at 3/7/2005 8:35:02 PM
add 2 columns to middle of sql server table Posted on: 03/07/2005 16:00:00 I am basically new to sql server. I need to add 2 new columns to a sql server 2000 database. I do not want to add the columns to the end of the table. I want to add the columns to the middle of the table...more >>

help for a search procedure
Posted by kamal hussain at 3/7/2005 8:20:58 PM
hello, please help me to give me solution i have a table CREATE TABLE T_STUDENT_MT (ID INT PRIMARY KEY, NAME VARCHAR2(50) NOT NULL, FATHERNAME VARCHAR2(50), COUNTRY VARCHAR2(50), STATE VARCHAR2(20), CITY VARCHAR2(30), STREET VARCHAR2(40)) MY DATA IS INSERT INTO T_STUDENT_MT VALUE...more >>

Converting delimited varchar @parameter for use in NOT IN()
Posted by Patrick Russell at 3/7/2005 8:12:57 PM
I am creating a stored procedure which is passed a comma delimited string of ids as a varchar datatype. The param is to be used in an SQL statement such as: CREATE PROCEDURE GetFromTable @IDs varchar(255) AS SELECT * FROM table WHERE iId NOT IN(@IDs) GO The problem is that the iI...more >>

sp_monitor
Posted by M. de Jong at 3/7/2005 7:49:22 PM
Hello, I would like to know how to read the monitor information after running sp_monitor of what i have to do to get more sight in the workload on my machine. What is high and what is low? For Example: after running sp_monitor i get the following information. This information changes a lot...more >>



Changing a table will break a view?
Posted by David W. Rogers at 3/7/2005 6:13:03 PM
The other day I updated a table to add a few columns using Enterprise Manager. When I closed the table, it said it would update several other database items as a result (very good, I thought). However, subsequent to this change, even the most basic view is broken, e.g., CREATE VIEW [v_ta...more >>

Query with date question
Posted by Aleks at 3/7/2005 5:47:53 PM
I need to return all records in which the date 'lastmodified' + 'responsible' which is a number (of days) is the same as today's date. I have the following condition in my sql but even though it should return some records it doesnt: WHERE (DATEADD(day,Activities.responsible , Activi...more >>

Select a remote server
Posted by Jennyfer J Barco at 3/7/2005 5:42:50 PM
Hello I have a remote SQL server. May I make a select of a table in a database from that server? I'm using select * from POMPANO-W.mydb.dbo.mytable and I get the error Incorrect syntax near "-" The server name is POMPANO-W. Thanks in advance Jennyfer ...more >>

Return only 3rd row in select
Posted by Jon J. at 3/7/2005 5:23:04 PM
How would I return only the 3rd row of a SELECT query? Let's say I start with: SELECT * FROM TABLE1 WHERE ID = 4 And let's also assume I've already counted rows with 'SELECT COUNT(*)' so I know the SELECT will return at least 3 rows. TIA, Jon -- Jon...more >>

set datatype of computed column
Posted by Shawn Clabough at 3/7/2005 5:05:57 PM
If I'm concatenating two columns in a computed column (Formula), SQL Server is automatically making the column a varchar datatype. I've tried using CAST and CONVERT around the formula to change it to datetime, but it gives me an error. Is there a way to set the datatype of a computed colum...more >>

How can I get the name of databases
Posted by Dib at 3/7/2005 4:41:52 PM
Hi, How can I get the name of the databases from SQL 2000, to a combo box. Thanks Dib ...more >>

Looking for a SQL Server Account Provider
Posted by Wayne Wengert at 3/7/2005 4:35:06 PM
I currently use an ISP to provide SQL Server service. I have one database, unlimited bandwidth and 100MB of space. My current service is going to he__. I keep getting periods when connectivity is flakey and the support people are of little help. Anyway, I am looking for a reliable, full featur...more >>

order by and UNION
Posted by js at 3/7/2005 4:31:15 PM
Hi, I got an error "ORDER BY items must appear in the select list if the statement contains a UNION operator." when trying to put an order clause at the end ot the union query. How to set order to the whole set? Thanks. ...more >>

When Do I Need a Temp Table?
Posted by jpuopolo NO[at]SPAM mvisiontechnology.com at 3/7/2005 3:42:45 PM
All: I've been building software for a long time (mostly middleware and front end, but have done some SQL as well) and am interested in the use of temporary tables in database development. Under what conditions do temp tables help? Are they sometime the most straight forward solution to an...more >>

'Contains' problem
Posted by JackRabbit at 3/7/2005 3:42:43 PM
Hello, I have a problem with a contains clause. I believe I have the full-text index set correctly. Whenever I put a '-' (dash) character in the query, it seems to return incorrect results. Here is a query that works. SELECT DISTINCT Store_Products.Family As [key] FROM Store_Products WHERE ...more >>

Determing Last Table Update?
Posted by jpuopolo NO[at]SPAM mvisiontechnology.com at 3/7/2005 3:36:32 PM
All: Is there a way to tell when the last time a row was added to a table? SQL Enterprise Manager shows the creation table for a table in the standard view... Is there a way to get the "last modified date?" I am trying to analyze what a piece of code is doing (I do not have the source - onl...more >>

Sequence number that would increment only when a value in a Column changes
Posted by rgn at 3/7/2005 3:34:49 PM
Hello All, I was wondering if there are other ways of doing this. I need a way to generate a Sequence number that would increment only when the [StartDateTime] & [EndDateTime] changes. I was able to do it after introducing some tables but I was wondering if there are other methods. ...more >>

XML query help
Posted by Q at 3/7/2005 3:17:03 PM
I got the following XML format, but I don't know how to pull data out of it. Expect results: CustomValue Value ----------------------------- ApplicantFICOScore 804 Thanks all for your help, Q. DECLARE @xml VARCHAR(8000), @idoc INT SET @xml = '<?xml version="1.0"?> <decisio...more >>

capture more detail in profiler for triggers
Posted by JRStern at 3/7/2005 3:16:53 PM
Our app generates a simple-looking "delete" statement for single rows which shows up in the profiler logs as generating 17000 reads, and we know it takes five seconds! It turns out that the table has a delete trigger, and that trigger updates another table that has update triggers, and I think ...more >>

SQL Script to Display Last Hour of Data
Posted by Joe K. at 3/7/2005 3:15:04 PM
I would like to modified the SQL statement listed below to output the previous hour of data from the present time. The problem is CounterData.CounterDateTime field is in the char(24) format which cannot be changed. If this field was in datetime format it would be much easier. The Count...more >>

A quest for a query
Posted by Hrvoje Vrbanc at 3/7/2005 3:08:10 PM
Hello all! Could somebody please help me with the following query: I have a table with 3 colums. First column are just identity numbers. Second column contains data in the following pattern: 2 rows of data, 1 null (empty) row and then again 2 rows on data, 1 null row, etc. Third column is a...more >>

remove chr(10) char with Tsql?
Posted by Ron at 3/7/2005 2:50:43 PM
Hello, I am writing data to a table using a DTS package from a VB app. One of the columns, nvarchar column, is getting carriage/return char appended to the data. Select '*' + fld1 + '*' From tbl1 fld1 contains digits. I get this * 10* If I do this: Declare @s varchar(10) Selec...more >>

Syntax problem with Alter Column
Posted by Hemil at 3/7/2005 2:43:06 PM
Hello Friends, 1) I have the following SQL which is giving me the error message as listed the SQL. I can run the alter column statement individually but when I try to run the whole block(with the statements preceding and following it), it gives me the error. --33. Table WnBck ALTER T...more >>

Timestamp -> datetime
Posted by Dirk Dulfer at 3/7/2005 2:15:47 PM
Hi, I have this database designed by someone who didn't knew a timestamp isn't just an easy way to insert a usable date. However we needs this creation date for statistics. Is it possible to convert these 7000+ timestamps to a datetime? Thanks in advance!...more >>

suspect state and triggers
Posted by IvanG at 3/7/2005 2:15:09 PM
I have a backup table that is just a mirror of another table. All changes are copied to backup table using FOR INSERT, UPDATE, DELETE trigger. The question is what happens if original table is damaged because of disk failure (suspect DB state). Is it possible that these "wrong" changes will b...more >>

Query your Stored Procs
Posted by Toco at 3/7/2005 2:05:07 PM
Is there a way you can query stored procedures for a string in all of the stored procs in a database? For example, if you were looking for "LETTERS" in all of your stored procedures in your Account DB, how would you look for the string? Please post example if you know. -Toco-...more >>

Query to check if DB name is referred to
Posted by Chris at 3/7/2005 1:46:22 PM
Is is possible to construct a query that will list all the references to the database name that are used throughout the database itself. E.g. It would tell give me a list of all the views/stored procedures/triggers that refer to the database name in them. Example: CREATE PROCEDURE [dbo].[...more >>

log the warning?
Posted by Britney at 3/7/2005 1:35:47 PM
when I execute the query, I get warning sometimes. such as aggregation warning... some null rows will be eliminates... Now, is warning part of master.dbo.sysmessages? I think it's impossible to save the warning message to a file or even to database table, right? ...more >>

Working with #temp tables
Posted by Logger at 3/7/2005 12:53:04 PM
Help, I’m trying to build a list into a temp table using an if/else statement but I keep getting the error “There is already an object named ‘wktable’ in the database.” Can you tell me why building a temp table using an if/else statement doesn’t work? See below example Decla...more >>

XML parsing error
Posted by Vijay at 3/7/2005 12:47:02 PM
Hi, In my stored procedure I am calling sp_xml_preparedocument to load the xml string from the message table. The sp will be called when a record is inserted in the message table by an insert trigger. If the xml string is not well formed, I want to move this record to another failedmessage ...more >>

Help with query NOT IN
Posted by larzeb at 3/7/2005 12:28:02 PM
I have a view containing column X and column Y and a foreign key F. I want to filter the view so that it does not contain any rows which are in the foreign table, which also contain columns X and Y. I want to do something like this: SELECT * FROM vView v LEFT OUTER JOIN Tbl t ON t.f = v.f ...more >>

Nested views and functions?
Posted by Matt at 3/7/2005 12:25:37 PM
I am working in a project where the business model is complex enough that many common retrieval functions become difficult to develop and maintain in single query statements or functions. I have found the logic is easier to implement (and later modify when the code is no longer freshly remembe...more >>

Renaming a table
Posted by Steve Caliendo at 3/7/2005 12:06:46 PM
Hi, Can someone please tell me the syntax for renaming a table in a query? Thanks, Steve ...more >>

Statistics (sp_monitor)
Posted by M. de Jong at 3/7/2005 11:21:20 AM
Hey, Over the last couple of months SQL Server is getting slower and slower. This is due some know factors, like more customers, bigger databases, not verry nice programming and a machine that is 5 years old. Yes, I know i have to upgrade it but before i'll do that., i would like to know what ...more >>

Loop through relation to set incremental number
Posted by WB at 3/7/2005 11:13:17 AM
I have a relation with two attributes acting as the primary key. Each key is a foreign key to another table. The requirements have changed and now I need to set the relation with a single auto increment primary key. The existing relation has about 45k tuples. As you might guess, if I add a ...more >>

Help with chinese character
Posted by Agnes at 3/7/2005 11:03:37 AM
sorry.. help with chinese character , cocode is nchar(10) int (1), i can see the record of that china company, but in (2) , show nothing.... (1)select cocode,invno ,netbaseamt from arinvinfo order by cocode (2)select * from arinvinfo where rtrim(cocode) = '©v§Q´ä¶ì®Æ' ...more >>

Another query problem
Posted by Aleks at 3/7/2005 10:07:19 AM
I am using Dreamweaver for the following: Hi, I have a problem with a search/results page, one of the fields is a date, I want to display all results if the date is not entered in the search page and display the records that match the date entered if any. My problem is that if in the resu...more >>

Query problem
Posted by Aleks at 3/7/2005 10:06:39 AM
I want to restrict the results of a query only where the field 'email' has something in it. I had a record with data in 'email' and deleted it and my query still returns the record even thoug part of my statements reads: Select * from Users Where email is NOT NULL OR email <> '' Even though...more >>

simiple question
Posted by Ed at 3/7/2005 10:01:04 AM
hi, what is the T-SQL Syntax to remove a login name from the server, is it sp_dropsrvrolemember but i am not sure what i need to put right after the command in order to remove the login name Thanks Ed...more >>

RE: Any idea on this!
Posted by Comfort at 3/7/2005 9:15:41 AM
How can execute sqlscript stored in a folder. i.e D:\SQLSCRIPT\cs_posting_exc.PRC What can I write in query analyzer so that I can run that procedure in that folder is a specified server and database. ...more >>

Performance Issue
Posted by Devron Blatchford at 3/7/2005 9:02:53 AM
Hi there, I have a performance issue that I am having trouble solving, I am hoping that someone can give me some pointers as to where to look next. Here is the scenario: We have a SQL2000 SP3 Database on our live server. From time to time we have issues with this database where most que...more >>

String Concatenation with Distinct
Posted by Alien2_51 at 3/7/2005 8:53:03 AM
This query returns 6 rows of data, my intent is to concatenate the values of each row into one varchar variable, if I take the distinct off it works fine, when I add the distinct keyword I only get the first row. Any ideas...? SELECT DISTINCT @WarClaimExceptions = @WarClaimExceptions + '<li...more >>

Changing a column type with replication
Posted by Phil396 at 3/7/2005 7:14:59 AM
I need to change a column that is a six character varchar called meeting_date to a datetime value. My plan is to create a table that stores a int value and a datetime value. Copy the primary key (an identity column) and converted the value to a datetime on the insert. Disable or alter all o...more >>

Select statement
Posted by Newbie at 3/7/2005 6:01:13 AM
Hello! I am working on migrating an ASP page writen in Visual Basic into C# ASP.NET. How do I convert the following 2 select statements? Thanks in advance. Set rsPPO = Server.CreateObject("ADODB.Recordset") sPPO = "SELECT a.line_no, a.loc_no, a.qty_ord, a.po_no, a.unit_price, a.tot_qt...more >>

Matrix building difficulties
Posted by Marfig at 3/7/2005 2:57:42 AM
Hello all, I have the following temporary table structure which I already populated with a regular query to the main database: CREATE TABLE #MESVENPAR2 ( CONTAID BIGINT, -- ID of Partner CONNAME VARCHAR(100), -- Name of Partner CONZONE VARCHAR(50), -- Geaographical Zone of ...more >>

Turn off Error messages
Posted by Steve Norman at 3/7/2005 2:51:02 AM
Hi, Is there a way to stop SQL Server reporting errors in a Stored Procedure? The one I am trying to ignore is a divide-by-zero error? Infact, the ideal solution would be to have SQL Server raise the error so I can detect it in @@ERROR, but to not report it to Query Analyser or any other ...more >>

create login for db access on the fly
Posted by Ezekiël at 3/7/2005 2:05:02 AM
Hi, How can i create logins on the fly to access a database. I have a login which can access a database through my webapp. The enduser will access also through my webapp, but they have a different login to the database. My question how can this be done? I've tried to execute the followi...more >>

Trigger Need Heeeellppppp
Posted by EllandRD at 3/7/2005 12:45:03 AM
TblA HbdID JID GradeID Hours TblB SalesID PersID HbdID <-----FK TblC HR...more >>


DevelopmentNow Blog