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 > june 2004 > threads for thursday june 10

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

How to get process info in a query result set
Posted by checcouno NO[at]SPAM tiscali.it at 6/10/2004 11:52:02 PM
I need to get process info like process id, user, database, host, application etc from a query analizer result set. Someone knows how? Thanks...more >>


undocumented feature?
Posted by Beeeeeves at 6/10/2004 11:36:44 PM
HI Is it an undocumented feature of SQL server, or just something that 'just works' that you can use a goto statement, to goto a label that's WITHIN a while loop!?? ...more >>

trapping connection-level errors
Posted by toylet at 6/10/2004 11:26:27 PM
I have a table with a contraint to avoid duplicated keys. alter procedure AddKey @key char(10) as declare @errmsg varchar(20) insert into TheTable values ( @key ) if @@error=0 set @errmsg="" else set @errmsg="duplicated key" select @errmsg as result return @errmsg Is it possibl...more >>

Select all odd/even records.
Posted by Benny at 6/10/2004 9:49:28 PM
Hello Experts, Assume i have a table with 100 records. How can i select all odd records (i.e. record 1, 3, 5...) or even records (i.e. 2, 4, 6)? i am using MS SQL 2000. Thanks, Benny *** Sent via Devdex http://www.devdex.com *** Don't just participate in USENET...get rewarded fo...more >>

Rename Files
Posted by HartmanA at 6/10/2004 9:05:43 PM
I have a process(SP) where I use xp_cmdshell to read a directory and get a list of files. These files are named like this: 601342.pdf 601355.pdf The first 6 characters are an Invoice number. I then pull this data into a Sql table where I need to match the first 6 characters(InvNbr) to an...more >>

can I Skip HTML Tags
Posted by anand at 6/10/2004 9:02:23 PM
Hello Group, i m bit new to sql server ,programming.The issue is , i am storing html contents in a field of table , now this filed carries all html tags ( e.g. <td>,<tr>,<a> etc) as well , now i want to filter the content , is it possible through procedure that the contents of this field come out...more >>

Search string without HTML tag
Posted by Ashish Kanoongo at 6/10/2004 8:54:11 PM
Currently we use text field in table to store HTML and in search like to = eliminate HTML tag for example, given text - "<P><STRONG>Access High = Resorst<BR>" or <TD colspan=3D"3">Ashish</td>. I just want to search = 'Access High Resorst' or 'Ashish'.=20 How do I eliminate HTML tag using query...more >>

After insert a record into the table, I want to update some columns in that table by using trigger.
Posted by Suresh Ponraj at 6/10/2004 8:44:49 PM
Hi All After insert a record in to the table, I want to update some columns in that table by using trigger. My trigger is "CREATE TRIGGER t_InsertMyDetailsUpdateCost ON MyDetails FOR INSERT AS Update Sql" Can any one help me to write the trigger? ...more >>



running script on one server - using data from another
Posted by vicky davis at 6/10/2004 8:16:05 PM
I would like to run a script in QA that modifies a table in one database using data from another database. How do I reference a table in this second database? What if the second database was on a different server? Thank you in advance....more >>

Database backup/restore strangeness
Posted by John at 6/10/2004 7:47:07 PM
Not really a programming problem, but related to it: I sometimes need to move a database from my dev server to the live one. So I backup and restore it (just to a file, not tape). However, sometimes this seems to restore an *older* copy of the database that the one I backed up!!!!! Why?? I t...more >>

RSI function in SQL?
Posted by Robin Hammond at 6/10/2004 6:21:04 PM
Has anyone seen anything or found an elegant solution to the Wheeler's RSI technical indicator for stock price movements. If so, any ideas on creating a view, SP or function would be very much appreciated. It's defined as 100 * (Mean of Price change on up days / (Mean of Price change on up day...more >>

gurus! can someone please translate this article?
Posted by Amadelle at 6/10/2004 6:08:33 PM
Hi all and thanks in advance, please bear with me as I will try to explain my problem: I have a .NET dll which I have created (written in C#). which I would like to access through T-SQL's extended procs. I have successfully managed to do this on my local machine which is running SQL 2K + XP ...more >>

Is There a Better Way? (Incrementing PK Column)
Posted by Alex Papadimoulis at 6/10/2004 4:47:07 PM
Hi Group, I have a master and detail table like so, Master ( ID int PK, [...] ) Detail (MasterID int PK, DetailNum int PK, [...]) The idea is that DetialNum will start at 1 and count up for each MasterID. Example: {1,1,[...]}, {1,2,[...]}, {1,3,[...]}, {2,1,[...]} I want to add records...more >>

Changing rows to Columns
Posted by Josh Gerszewski at 6/10/2004 4:46:41 PM
Hello Everyone, I have a big favor to ask. I have some data that I need to take out of some tables and report them in an excel spreadsheet. I can do the export just fine but I'm having trouble formatting the data how I want it. Here's my tables: Table: Questions QuestionID | Question |...more >>

Trigger on Insert with Identity
Posted by David at 6/10/2004 4:45:03 PM
I have a stored proc to add records to a table. I would like to also add a record to a 2nd table immediately after the insert to table 1. I know how to do it in code, but thought that a trigger would work better. I have written triggers before but this one has to use the newly created identity...more >>

about 2 Highest value in the expression MAX Aggregate Functions
Posted by SimonKuo at 6/10/2004 4:21:24 PM
Hi, I hope some one can help me, I want to select from a single table the records with the highest value in two columns.=20 E.g. (MAX IssueDate and OutTime) CarNo IssueDate OutTime IssueID =20 -------- ---------- -------- -----------=20 XT-017 2004/06/04 16:38:24 298307 <--...more >>

using table name as input parameter in SP?
Posted by GSK at 6/10/2004 4:04:56 PM
Is it possible to use a table name as an input parameter in a stored procedure? i.e. CREATE PROCEDURE sp_Proc @var1 nvarchar(150), @tbl nvarchar(10) AS UPDATE @tbl SET VO_Bit = 0 WHERE (VO_ID = @var1) GO (The above says that @tbl must be declared) Of course, all the dynamic tables...more >>

help with format file
Posted by NotGiven at 6/10/2004 3:10:01 PM
I am trying to do my first format file. Let's say it's a fixed length field delimited text file with the following example data: 11 2982jones samual 23988 12 2911smith stan 22324 .... Please help me with the format file to import this: 8.0 5 1 SQLCHAR ...more >>

String or binary data would be truncated, but fields are big enough
Posted by clintonb NO[at]SPAM fflax.net at 6/10/2004 3:09:51 PM
One of our software customers is getting an error from the SQL Server ODBC Driver that says: "String or binary data would be truncated." when trying to add or update a record in one of the tables using one of our programs. I don't understand why that customer is getting truncation errors when ...more >>

how to improve sp's execution.?
Posted by Aruna Tennakoon at 6/10/2004 3:03:04 PM
Hi guys, I have a moth end strode proc which will process millions of recodes in a table. can any one advice me how to optimize it to the best. same samples that I can follow .. Thanks -Aruna ...more >>

Which programming language
Posted by Tyrone at 6/10/2004 2:59:44 PM
Hi, I will later on in the year be moving an application from Unix/ISAM to Windows/SQLServer. I will need to port a simple program to Windows but I am no familiar with windows programming. My question is, what would be the prefered programming language to write a program to : Connect to...more >>

Search all tables, all fields?
Posted by eagletender at 6/10/2004 2:59:06 PM
Is there a way (a relatively simple way) to search an entire database for a word or phrase in the data without searching each table, each field, etc, etc. Thanks. ...more >>

How to trap the error in stored procedure while executing it.
Posted by Suresh Ponraj at 6/10/2004 2:48:09 PM
Hi All, I want to trap the errors in stored procedure(SP) while executing it. (Like VB can we use exeptional handling in SP) Can anyone help me how to trap the error in SP while executing it? Thanks and Regards, Suresh P ...more >>

Copy data from Access to MS Sql
Posted by SomSallyX at 6/10/2004 2:47:56 PM
Hi How data synchronization can be done between a MS SQL Server and a MS Access database. The source is a MS Access MDB which is in a remote location and it has 2 tables which have to be synchronized. Regards ...more >>

how to get the number of active connections for a given DB??
Posted by Senthil at 6/10/2004 2:24:52 PM
Hi how to find the number of active connections for a particular db in sqlserver in the folowing methods? 1.using stored procedures 2. using ado.net. i tried with sp_who, and sp_who2 these get me the number of connnections to whole Sqlserver not to any particuylar db.. any sp avail...more >>

Taking too long to run
Posted by Tim at 6/10/2004 2:15:31 PM
I am trying to optimize the following query and would like some assistance. For one, there is an index on transactionhistory.postdate that this query is not utilizing. I have already updated statistics and still I get 'Clustered Index Scan'. Any help would be appreciated. I have also included ...more >>

how do I call BULK INSERT/COPY for fixed-length text file import from within stored proc?
Posted by NotGiven at 6/10/2004 2:10:27 PM
I need to code a button in a .Net (windows or asp) app that will import several fixed-length-field text files into existing SQL Server tables. I've written stroed procs before but have not deralth with DTS or bcp before. Any help, links, or direction would be much appreciated! ...more >>

Wrong command.state during stored procedure execution
Posted by juhu at 6/10/2004 2:01:29 PM
Hi there! I've got a problem with an ADO Command object, which is executing a long running (~5 min) stored procedure asynchronously. The problem is that the State property during the execution suddenly (after 5-15sec) evaluates to adStateClosed, even though the sp did not complete yet. The qu...more >>

declare variable to be of some table's column datatype
Posted by Kanan at 6/10/2004 2:01:06 PM
Does SQL Server have the capability to declare a variable to be of particular table's column datatype? This is a featur available in Oracle. Please let me know. I am not able to find any documentation on this in my SQL Server book thank Kanan...more >>

impossible to delete rows
Posted by HPA at 6/10/2004 1:44:05 PM
Hi all, I try to delete about 4000 rows in a table which contains 150000. This table is referenced with DRI in several other tables (inheritance or foreign key). The firts instructions of the stored procedure delete the rows in the associated tables, and the last one is as simple as : dele...more >>

Function
Posted by simon at 6/10/2004 1:31:04 PM
I'm creating my function but I can't use getdate() inside my function. Why? It's more complicatede but this is some example: CREATE FUNCTION Time2Date (@Time As Datetime) RETURNS Datetime AS BEGIN RETURN ( select max(date) FROM table where date<getdate() ) END Thank ...more >>

HELP: Can I open an xml document from stored procedure by passing an URL?
Posted by Jordan Tan at 6/10/2004 1:23:16 PM
Any advice greatly appreciated. Cheers, j. ...more >>

SQL Query Help
Posted by CJM at 6/10/2004 1:17:14 PM
I am try to build an SP that queries two table, Filters and Locations. Each filter is in one location only. I want to list all the locations, and for each location, list the PartNo and the number of filters in that location, eg: PartNo, Location1, Location2, Location3 ----------------------...more >>

Correct Syntax
Posted by Jasmine at 6/10/2004 1:11:42 PM
What would be the correct syntax if I have the following scenario: Appt. Code Client_id 1/1/04 A 3 2/15/04 BF 3 3/9/04 CD 1 3/18/04 NS 1 5/25/04 NS 2 6/10/04 CD ...more >>

SQL Query Help
Posted by CJM at 6/10/2004 12:28:29 PM
I am try to build an SP that queries two table, Filters and Locations. Each filter is in one location only. I want to list all the locations, and for each location, list the PartNo and the number of filters in that location, eg: PartNo, Location1, Location2, Location3 ----------------------...more >>

CHanging the name of a role
Posted by el_kano at 6/10/2004 12:25:22 PM
Hi there, just wondering if anyone is able to help. I am looking to change the name of a role I have in a database. Say the name of the database is "Customers" and the Role I want to change is "User". How would I change the name in sql to "Users"? Thanks for any help. ...more >>

passing parameters to stored procedure
Posted by pauli NO[at]SPAM lead.org at 6/10/2004 12:20:51 PM
Hi I am trying to write a store procedure with a query that takes a comma separated list and use it as the criteria. the code is below. ************************************************** CREATE PROCEDURE [dbo].[getPersonbyC] @varC varchar(20) AS declare @varC1 varchar(100) set @varC...more >>

Cross database stored procedure problems
Posted by Brian Henry at 6/10/2004 12:17:20 PM
here is an example.. the following stored procedure does not work it returns Server: Msg 229, Level 14, State 5, Procedure BENESP_GetJournalEntrySubTypes, Line 10 SELECT permission denied on object 'UsersPermissions', database 'bene_users', owner 'dbo'. now the database the stored proc is on...more >>

insert trigger help
Posted by soc at 6/10/2004 12:13:12 PM
Hello database A is contacts database B is clients they both have columns "email" and "accountno". When a record goes into A, I would like the accountno field in B to be filled where A.email=B.email. Can anyone advise? Thanks Soc. ...more >>

accessing drives on remote machines?
Posted by warren at 6/10/2004 11:47:17 AM
i'm trying to figure out file sizes of files on a remote machine(doesn't have sql installed). My sql server and the remote machine are on the same network and use the same credentials. i've tried using 'net use' to map the drive of the remote machine, then using xp_getfiledetails to acces...more >>

DeNormalization
Posted by Thomas at 6/10/2004 11:46:02 AM
Hey All, I am trying to figure out how to DeNormalize a table for a report. The closet thing i have been able to find is an access crosstab, but i need to do it in TSQL. TRANSFORM Avg(CH.p_Date) AS AvgOfp_Date SELECT CH.RecID, CH.p_name FROM tbl_Campaign_History CH GROUP BY CH.RecID, CH.p_...more >>

cursors & sp's
Posted by Laura at 6/10/2004 11:16:32 AM
I have a cursor inside of a stored procedure. I try to use the sp's input variables after the cursor is closed and it can't recognize the variables exist. Help? SP text is below: create procedure sw_AmendmentType_Update ( @stringOfAmendTypes varchar(60), @amendid int, @lastuser...more >>

executing a stored procedure in query analyzer
Posted by Sean at 6/10/2004 11:07:28 AM
HI There, Could someone help me out with the syntax of executing a stored procedure in query analyzer. I have tried the code below but I keep getting an error, what am I doing wrong? Sean exec GetLoginForUser @Username 'test', @Password = 'test', @errmsg1 CREATE PROCEDURE GetLoginF...more >>

Project
Posted by Jeff Thur at 6/10/2004 11:06:02 AM
I have been assigned a project. I am totally new to SQL/VB6. I need to create a lookup scenario for end users to search the database by name or zipcode The name or zipcode will change each time the user makes a request from the database Since the user will have no knowledge of writting SQL querie...more >>

returning nchar parameter from stored procedure - novice question
Posted by Sean at 6/10/2004 11:03:47 AM
HI There, Could someone help me out with the syntax of returning an output parameter from a stored procedure? I have tried to use SSelect @RoleName = G.Name, but this returns an error. Could someone help me out with the syntax? Sean - thanks in advance CREATE PROCEDURE GetLoginForUs...more >>

Can I do this with SQL
Posted by Jeff Thur at 6/10/2004 10:51:03 AM
I have been assigned a project. I am totally new to SQL/VB6. I need to create a lookup scenario for end users to search the database by name or zipcode The name or zipcode will change each time the user makes a request from the database Since the user will have no knowledge of writting SQL querie...more >>

Select case statement
Posted by simon at 6/10/2004 10:29:54 AM
I have SELECT statement declare @quantity int set @quantity=3 select value=case @quantity when 0 then 10 when 1 then 20 else 30 end It works. But I don't know how I can use < operator, something like this: select value=case @quantity when < 0 then 10 when <5 then 20 else 30 end ...more >>

a little typical
Posted by suji at 6/10/2004 10:21:01 AM
Gurus Is there a quick way to find how may total transaction(could be remote as well) took place today, how may succeeded and how may failed(may be with the help of writing some code). My manager don't want to use auditing O whenever any thansactions fails I get a popup or something I appreciate...more >>

Simple migration
Posted by Stu at 6/10/2004 9:55:16 AM
I would like to write a util to copy an SQL database over to another server. Can anybody see anything wrong or offer any suggestions over the sequence below? 1. Source: exec sp_detach_db SourceDB, False 2. Copy SourceDB.mdf -> DestDB.mdf 3. Copy SourceDB.ldf -> DestDB.ldf (And any othe...more >>

Output to XML File
Posted by John Cobb at 6/10/2004 9:51:29 AM
Problem Description: I have a Archival process in a VB.Net app that needs to kick off a stored procedure on a SQL Server 2000 box. This sproc should accept one parameter and execute 10 Select statements. These Select statements should return as XML and be output to a file. Because of the...more >>

Looping issue
Posted by jduran at 6/10/2004 9:47:01 AM
I have inherited the following code and the looping function only give me MAX(amount_paid) for first record. I have never seen this particular looping method. Question how can I either get the existing looping to work or what should I change it to? CREATE PROCEDURE dbo.fhkivrexport AS D...more >>

Problem getting USER_NAME
Posted by Bryan at 6/10/2004 9:34:36 AM
Hi all - I am trying to retrieve the username of the logged on user with SELECT USER_NAME() but when it is executed by a member of the System Administrators role it returns 'dbo'. Is there a way I can retrieve the actual user and NOT 'dbo' Any help is appreciated. Thanks! ...more >>

Table variables and UDFs
Posted by Rand E. Gerald at 6/10/2004 9:12:56 AM
Do Table variables have any problem with UDFs? I'm trying to re-write some temporary table code to use table variables. ---- Start Code ----- -- Create temporary table for CityStateZIP declare @tblcsz table ( kCityStateZIP int ,sCSZ varchar(255) NULL ,kCountry varchar(10) ,kAddress...more >>

Getting Process Info as a Query result set
Posted by checcouno at 6/10/2004 8:56:01 AM
I need to get process info (process id, user, database, application, host etc) as a query result set from query analizer, is it possible? Thanks...more >>

Autonumber
Posted by Pradip at 6/10/2004 8:53:02 AM
How do I generate a complex autonumber involving combination of date, text, sequenceNumber and also some logic behind the combination. Can I do it using a Trigger? In that case where do I store the Sequence Number. Any Ideas please... Thanks in Advance....more >>

"Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable
Posted by Scott McNair at 6/10/2004 8:39:37 AM
Hi, I'm creating a stored procedure to compare record counts for the same table on an AS400 versus a SQL box. I've got both boxes linked to my SQL box. I've created the following sproc: CREATE PROCEDURE CompareSFM(@TBLNAME varchar(50)) AS exec(' select '''+@TBLNAME+''' as [Table Na...more >>

Anything like Constants in SQL Server?
Posted by Steve at 6/10/2004 8:25:02 AM
Is there any way to create our own constants in SQL Server 2000 which can then be used within stored procedures? ie, so that where we do an 'ISNULL (Field, Val)' we can in place of Val just insert a constant name in different SP's? TIA ...more >>

Linked Server vs Linked Table in Access 2000
Posted by Ola Hällvall at 6/10/2004 7:41:02 AM
I have a problem regarding preformance when quering a linked server in SQL Server 2000 In Access I have a linked table based on a connection to an ODBC connection (Ingres ODBC driver 3.5) I'm joining 4 tables white very good performance (around 150 000 rows in each tables) Now I want to do the s...more >>

Long Select Statement
Posted by niv at 6/10/2004 7:00:08 AM
Hello, I am curious on how to eliminate the time it takes for my select statement to return. I have 9 Inner Joins and 2 Left Joins. I am in the process of optimizing the query, but I am also curious on other methods to increase the query return period, like Indexes on tables. Anyhow,...more >>

Pivot Query problem
Posted by Subir Kumar at 6/10/2004 6:40:18 AM
Hi, I am migrating my access database to SQL Server. I have a crosstab query in Access which is TRANSFORM Sum(tblCurrentMonth.[Total Price]) AS [SumOfTotal Price] SELECT tblCurrentMonth.[Long Code], tblExpenseCodes. [Report Client], tblCurrentMonth.[Billing Cycle Name], Sum (tblCurrent...more >>

Insert Query Help
Posted by Jeff York at 6/10/2004 6:22:19 AM
Hi- I am having trouble with a query, perhaps you comeone can help. I am trying to insert into a table some values that are a result of a select statement. I am finding that this won't work. What is the best way to do this. I am attaching the failed query. THanks!! Insert into Xref_com...more >>

create a trigger
Posted by gazawaymy at 6/10/2004 6:21:02 AM
i am trying to create a trigger which when I insert a "y" on a student table in insCheck column, instructor table will create a record of the same person The reason is there are two tables are in my DB, student and instructor table. Student can be a instructor so whenever insCheck conlum in studne...more >>

SQL Query Help
Posted by ARTMIC at 6/10/2004 5:16:01 AM
I have a query that joins 2 tables and reports on those transactions in a given date range,........ Is there a way to report on the other data? as in list all parts that do not have a corresponding record in the download tabel for example? my original query looks like this, but it reports on thin...more >>

Help with recursive query for Hierarchal information
Posted by Karl Rhodes at 6/10/2004 4:43:12 AM
We have a table which hold three fields. HID - An Id field for hierarchal information HName - The friendly name for the field HPID - The Parent ID of this field. I need to build a query where I can input a HID value and it will return all the sub values, all the way down through the tree...more >>

HowTo make from rows to a delimitered String
Posted by Andreas Klemt at 6/10/2004 2:43:36 AM
Hello, when I do this SELECT names FROM users I get this results: adam joe tim mike How can I make a function (or is there any other solution?) to return only one row as delimtered like this: adam, joe, tim, mike Thanks for any help in advance Andreas ...more >>

Table locking and Deadlocks
Posted by Kornél Pál at 6/10/2004 1:33:02 AM
Hi, I'm using an SQL database to track my web page's hits. I have a table to record the latest IPs to can I decide wether the hit is unique or a reload. I have tables to record different thing about the hit. I'm storing strings like path, user agent in separated tables associated with an autoi...more >>

How to read an SQL Server into a ASP page and then change, add, delete and write it back to SQL Server
Posted by belindacur NO[at]SPAM yahoo.com at 6/10/2004 1:20:10 AM
Hello All I need to read a SQL Server table into a Web Page and within the Web Page to permit my users to make changes to the records, delete or add new records and then save the entire contents back to the SQL Server table back. The functionality I am looking is almost the same as In the S...more >>

How to read a SQL Table into Excel change the data and write back into SQL
Posted by belindacur NO[at]SPAM yahoo.com at 6/10/2004 1:11:13 AM
I want to use Excel as a frontend to maintain a few SQL tables. All I want to do is read the contents of the SQL Server Table into a Excel worksheet within Excel now I want to change, add or delete entries and writeback this data into the SQL Server table. Please would you be kind enough to sh...more >>

Running generated SQL Script
Posted by Willianto at 6/10/2004 1:01:34 AM
Hi all, I used to run SQL Script using SQL Profiler found on my SQL Server Developer's Edition. Problem arise because I need to send some script to my client, and my client use MSDE as the engine. Q: Anybody knows how to run generated SQL Script using tools found in MSDE installation? I am ...more >>

Help ! how can i use stored procedure's return in select statement directly ?
Posted by xc at 6/10/2004 12:46:01 AM
I want to write a script like following select name from (exec tsp_nameview) ' tsp_nameview is name of a stored procedur I don't want to create a temporary table , like create table #nameview (...), then insert into #nameview exec tsp_nameview, because there are too many columns in the...more >>


DevelopmentNow Blog