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 > december 2003 > threads for wednesday december 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 31

RESTORE A DB
Posted by Arpan at 12/10/2003 11:47:23 PM
I have a database back-up named SBSI4200.bkp is my C: drive. Please note = that I haven't created the back-up on my machine; I got it from someone. = Now to RESTORE this database, I am using the following code: RESTORE DATABASE SBSI4200 FROM DISK=3D'C:\SBSI4200.bkp' WITH MOVE 'SBSI4200' TO 'C...more >>


Why is the view slower than sql in query analyzer ?
Posted by Lasse at 12/10/2003 10:33:59 PM
Hi, When I excute this view it takes between 10 to 20 sec to finish, if I execute the sql statement in the query analyzer it takes no time to finish using same conditions in where clause. How can that be so? The view calls 2 other views. Lasse ...more >>

Transaction log backup. Starting a fresh daily
Posted by martin at 12/10/2003 9:55:25 PM
Hi, I wondered if anybody could tell me if this is possible in sql via a sheduled maintence plan or backup job or whether I have to implement my own script for it. I ma a server with approx 250 databases on which do not currntly get backed up (not sure how this happend..) most of the dat...more >>

Queries With Optional Columns
Posted by Roger at 12/10/2003 9:22:54 PM
Hi All, I have a database that is modeled similar to Quickbooks. A table called "Names" includes address information for Customers, Employees, and Vendors and each record's key is a foreign key in various other tables. I want to display a list of say Vendors where the user can select what co...more >>

SQL Insert Trigger
Posted by J G Gonzales at 12/10/2003 8:56:05 PM
I would like to somehow break a row like this inside the trigger col1 col2 col3 col4 col5 AA BB BB CC AB into a table that would look like this id value 1 AA 2 BB 3 BB 4 CC 5 AB BTW, since all metadata will be in the INSERTED table, how do I go about capturing th...more >>

Encryption error while attempting to Login
Posted by Amit at 12/10/2003 8:50:51 PM
Hello Friends, When I am trying to connect to SQL Server 2000 from my C# application by providing the following connection string: "server = ServerName; uid = amit; pwd = amitagarwal; database = pubs; encrypt = true"; A MessageBox popped up in my C# application saying "Encryption is no...more >>

Quickest way to copy a recond in one table to another
Posted by dave at 12/10/2003 8:17:16 PM
I have a quote table and a quoteDetail table They share a ID. What is the quickest way to copy a record in the quote table to the sales table and the quoteDetail records to the salesDetail table. I have to copy the sales record Identity and put it along with the salesDetail records Dave ...more >>

How to get rid of date 1/1/1900 ?
Posted by news.verizon.net at 12/10/2003 8:05:57 PM
I have created a column for ship date. If ship date is blank, I want to display blank. But SQL is displaying 1/1/1900 if date column is blank. Any suggestion ? Thanks. ...more >>



select query
Posted by kloepper at 12/10/2003 7:36:05 PM
My data tables have been reorganized and now I have a new problem. My Where clause has to be restructured in a way that is unknown to me. I have columns named: Period, Symbol, Revenue The Periods (rows) are named. Here's the catch; this is a flat table at this point and these Periods repeat ...more >>

can SUM return Zeros instead of NULLs ?
Posted by James Hardy at 12/10/2003 7:00:40 PM
I have an application that makes use of SQL Server 2000, one particular aspect of it has ceased working recently. Specifically a report that logs expected income started producing null values. I tracked the problem to a specific query SELECT DISTINCT (SELECT SUM(income.amount) * 12 AS m ...more >>

comma every 3 digit
Posted by haode at 12/10/2003 6:12:33 PM
I want to put commas every 3 digits. for exampe 39298384 should look like 39,298,384 the value I want to show is the type of number. Thanks. ...more >>

How to loop recordset and lock the table at stored procedure
Posted by Mullin Yu at 12/10/2003 6:03:48 PM
-- Lock the Table ???? How to Lock e.g. OutboundQueueItems -- Get recordset (0 to N JobItemdID) from a table select ***JobItemID*** from OutboundQueueItems where JobID = 123 and IsLocked = 0 and AddToProcessing = 1 -- Loop to update () to N) ***JobItemID**** ???? How to get and loop updat...more >>

Determine the Max(IDENTITYCOL) value for all my tables
Posted by Ted at 12/10/2003 4:35:13 PM
I am looking for a query (or simple stored proc) to return the max value for all my identity columns ( MAX(IDENTITYCOL) ) in my database. I would like this query to be dynamic in that, I do not need to specify the table names or the column names. If not, I guess could I iterate through the ta...more >>

Table Data Dump with DTS
Posted by Arvin at 12/10/2003 4:35:04 PM
hi, i am doing a query to get all the tables froma a database so i did this. SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE '%dbt%' but my next step is to get all the contents from those table results and dump it into a single table. how should i go about it? thank...more >>

Triggers
Posted by Mario at 12/10/2003 3:51:59 PM
When I encounter an error in my trigger, my entire transaction gets rolled back, so far so good. But I want to preserve my transaction and I dont care if my trigger goes wrong. I have tried Commit at the beginning, what this does is that it strops the trigger, I tried a Commit and then a ...more >>

Update Statement with a Join...
Posted by Greg Kaufman at 12/10/2003 3:45:05 PM
My mind is mushy - hopefully I'm just missing something obvious here. I'm trying to do an update on a table, based on info in a related joined table. In Access, I'd simply run the following query: UPDATE tblCities INNER JOIN tblStreets ON tblCities.City = tblStreets.City SET tblStreet...more >>

Float Problems
Posted by dan at 12/10/2003 3:41:08 PM
I have some weird things happening to data in a column defined as float(8). Values returned from select statments are returning werid values.. ...03 returns 2.9999999999999999E-2 ...09 returns 8.9999999999999997E-2 .....etc. Also I tried to insert values and had diff values end up in the d...more >>

Help coming up with a data structure
Posted by George Durzi at 12/10/2003 3:34:20 PM
Hey all, I need help trying to come up with a data structure to represent an illustration of a wine cellar. Let's say I have 4 sections in an example wine cellar, Top, Left, Middle, Right. For the sake of illustration, I would use the following html to describe what this wine cellar is suppose...more >>

Where using variable
Posted by Ian Piper at 12/10/2003 3:30:04 PM
Hi I have a column called abc and the data is numberic. I have a variable called def and this is also numeric How can I search the database to get records where abc=def. Select @ from table where abc=def - doesn't work Select @ from table where abc=&def & - doesn't work I get error c...more >>

SELECT, INSERT & IDENTITY:
Posted by I_AM_DON_AND_YOU? at 12/10/2003 3:09:16 PM
I have a very simple problem: -- TABLE OLDTABLE create table oldtable (id int, code varchar(20)) insert into oldtable values (904,'x') insert into oldtable values (905,'y') insert into oldtable values (906,'z') insert into oldtable values (907,'w') I want to copy all this data to an EXIST...more >>

Defining Working hours trigger question
Posted by z666z NO[at]SPAM yahoo.com at 12/10/2003 3:04:38 PM
I am developing an update trigger that checks some stuff on the table and if it meets certain criteria sends an email out. What I want to do is figure out code that will limit the checking to a certain time span. The hours I am interested in monitoring are from 9:00 AM to 5:15 PM, Monday throu...more >>

Export text with headers
Posted by Lauren at 12/10/2003 2:24:06 PM
I'm trying to automate an export process to export a table as a flat text file, and include the column headers (names) as part of the data. BCP will export the data ok, but there are no column names included. Any ideas?...more >>

SQL SERVER
Posted by Charlie at 12/10/2003 2:03:31 PM
How can I do to estimate the space disk that I will need to the future in a SQL Server Database?...more >>

Adding a counter to the results
Posted by Ed at 12/10/2003 2:00:52 PM
Here's my query: SELECT FNAME, LNAME, SALARY FROM USERS U, SALARY S WHERE U.USERID = S.USERID AND SALARY < 50000 ORDER BY LNAME Is it possible for this query to return a counter that is incremented from 1 to n, where n is the total number of rows returned? sampl...more >>

Updating field in sql table
Posted by Jeanie at 12/10/2003 1:51:05 PM
I have a field in a sql table which includes the path of document. The field reads as follows: F:\files\corr\plead\this is my document.wpd. I would like to globally change the F:\ to read as S:\. How can I accomplish this? Many thanks...more >>

Programatically tell Recovery mode
Posted by martin at 12/10/2003 1:44:07 PM
Hi, I have ascrript that uses a cursor to loop through all of the databases and back each one up, back up the transaction log and then truncate it. This script works fine, except it always tries to back up the transaction logs of dbs that are in simple recovery mode. my question is can I p...more >>

running a program inside a stored procedure
Posted by Gary at 12/10/2003 1:28:45 PM
I hope someone else has had to do this in the past..... I have a vb 6 program that performs a series of calculation on a table in a sql server (7 or 2000) database. It can run from the client side but can be incredibly slow, especially over a poor (256kb dsl) connection. What i would like to do...more >>

sql statement error
Posted by Tony at 12/10/2003 1:12:36 PM
I have a problem with sql statement in the query design in MS Access 2000 which is giving me an syntax error in expression error message. My sql statement is: ==================================================================== SELECT DocumentsDR.ID, DocumentsDR.[Document Number], DocumentsD...more >>

Data Difference...
Posted by Brett at 12/10/2003 1:12:11 PM
Hello I am trying to figure out the best way to keep only 30 days worth of data in my table. Right now I have 9 months worth of data... I need to be able to extract that data and archive it into another table. So that I have the most recent 30 days worth of data. I am using SQL Serve...more >>

Query Help - is this possible?
Posted by divmax at 12/10/2003 12:56:07 PM
H I have a table of, say, articles. Looking something like this datestamp datetime, article varchar, company_id numeri I get many articles throughout the day. I need to produce a report with the latest article for each company. How I trie select max(datestamp),company_i from table group by...more >>

Tape drives and DMO
Posted by Chris Whitehead at 12/10/2003 12:54:41 PM
In enterprise manager, when I select Backup, put a tick in Tape and click the Add button, the "Select Backup Destination" dialog appears. I can either select a Tape or I can select a Backup device. I'm trying to code a similar dialog in DMO. I can display the Backup Devices easily by looping ...more >>

How do I calculate the "integer bitmask" value of a column?
Posted by G at 12/10/2003 12:49:48 PM
Hi All I'm trying to write a trigger and need to figure out how to identify whether a column has been updated. The column is number 12 from the left that I want to trigger an action if it is updated. I want to use the IF (COLUMNS_UPDATED()) but don't know how to calculate the value of the b...more >>

How do I calculate an "integer bitmask"
Posted by G at 12/10/2003 12:49:18 PM
Hi All I'm trying to write a trigger and need to figure out how to identify whether a column has been updated. The column is number 12 from the left that I want to trigger an action if it is updated. I want to use the IF (COLUMNS_UPDATED()) but don't know how to calculate the value of the b...more >>

Separating one field into multiple fields
Posted by Michael at 12/10/2003 12:18:11 PM
I have a field in a table which contains a string including Carriage Returns, can anyone tell me how I could separate this field into separate fields based on where the carriage returns are using a simple SQL command. Thanks Michael ...more >>

BCP or Bulk Insert file containing quoted strings, embedded delimiters
Posted by Robert Tuck at 12/10/2003 12:08:09 PM
Hi, Anyone know if it is possible to use Bulk Insert or BCP commands to import a text file into SQL 2000 which contains single or double quotes around string values, and tell it to ignore any embedded column delimiters? 1 Row Example: 9382,"Test, Description",349.00,"N","Joe Smith" (...more >>

How can i split this into columns using case?
Posted by ajayz90 NO[at]SPAM hotmail.com at 12/10/2003 12:06:22 PM
I have data as follows in a sql table.I want to split it into columns using case...any idea how I could do this? rmonth QtyShipped material shipto ----------- ---------------------------------------- ------------------------- --------------- -4 0 ...more >>

ANSI_NULLS ON/OFF
Posted by Rayan Yellina at 12/10/2003 12:00:45 PM
Hi, When I create a Stored Procedure, View etc, I always SET these two of them to SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS OFF GO By default, every time, I SET these two to this setting, without even thinking of anything. Am I right setting ANSI_NULLS OFF. Would you please dir...more >>

clustered index on date
Posted by Daniel P. at 12/10/2003 11:38:32 AM
How do I convince someone that it is better to have a clustered index on (ProcDate, ClientID) than on (ClientID, ProcDate)? Thanks! Daniel ...more >>

database design
Posted by Chris Strug at 12/10/2003 10:37:52 AM
Hi, I've been tinkering with the idea of re-designing a database that our company uses and have encountered a problem that I hope someone can clear up... Basically, how should a design account for a relationship that does not always exist. For example, I have a Stock table and a Hazardous t...more >>

Field Exists
Posted by Darren at 12/10/2003 10:35:26 AM
In a SP, how can i loop through every User Table and determine if a field exists and add it if it does not? ...more >>

Truncated INSERT statements when using sp_generate_inserts by Vyas
Posted by MOS NO[at]SPAM satx.rr.com at 12/10/2003 9:57:27 AM
I downloaded the code by Vyas for generating the SQL Insert statements necessary for transfering data from one database to another. While the code is excellent, I am having an issue with a couple of my tables, where the INSERT statements are getting truncated at 8000 characters. Between the erro...more >>

What is this Error ?
Posted by Tanveer H. Malik at 12/10/2003 9:52:40 AM
I'm using SQL Server 2K and VFP8. When I save a record, the following ODBC Error Message is displayed. 'Column Name [RefNo] appears more than once in the result column list.' Pls help....more >>

Cleaning up: multiple records to one record
Posted by B at 12/10/2003 9:45:25 AM
Say I have three records thus (I really have hundreds of thousands, but let's just say): Date Name Address1 Address2 Contact ------- --------- ------------- ----------- ------ 9/21/03 John null null Judy 12/5/03 John Address1 nu...more >>

Excluding updates from a trancation
Posted by John Grant at 12/10/2003 9:35:56 AM
We have some long running transactions and we want to log the process to a table, but if the transaction fails we want the log records to be in the table. Begin Trans Loop Update........ Insert record in log outside the transaction to report progress or errors End loop Rollbac...more >>

Query Analyzer debugger not waiting on 1st statement
Posted by Suresh Kumar at 12/10/2003 9:26:10 AM
We have 2 servers - Test and Development. On the Test server the Query Analyzer debugger runs fine like the way it should. On the Development server the debugger will not stop on the first statement, even if it has break point. It starts to run all the statements without stepping one statem...more >>

Why SQL Server reject string with double quotes?
Posted by Willianto at 12/10/2003 9:25:54 AM
Hi all, I'm a newbie in SQL Server. I just found out that: INSERT INTO some_table (a_char_column) VALUES ("This is a string") doesn't work. Took me almost half an hour to got the idea that I should use single quotes instead of double quotes. Remind me of my days in college with C language...more >>

Query Result Sets
Posted by Wilson Castillo at 12/10/2003 9:19:17 AM
Hi! I'm writting a program that needs to do the same thing that Query Analyzer does. I'm using Delphi 6 as my development platform. I ran into the following problem when I executed a Query that does not return a result set I get an error. My questions is, is there a way to check the Q...more >>

Pattern Matching with Numbers
Posted by liz at 12/10/2003 9:13:51 AM
How do I do a numeric pattern search in sql? What I have is a field with a length of 30 that contains text and numbers. I need to find the zip code in the field. (I've already done a right trim to remove spaces on the right side) For example, field 1 It dept 2 ...more >>

Disable warning?
Posted by Etienne M. St-Georges at 12/10/2003 9:11:13 AM
Hi there, Simple question: how do i disable the warning messages in ms-sql 2000 ? I have a script that returns (sometimes) some warnings, and i don't the customer to see this when running my scripts on their machine... Thanks! Etienne ...more >>

@test = "" <-- worked in 7.5 but not 2000
Posted by Tim at 12/10/2003 8:47:56 AM
i'm modifying a stored procedure that was written in 7.5. and i have varibles that i set to empty like this select @test = "" i pull it into the query analyzer in 7.5 and it works fine but with 2000 I run it and it says... "Server: Msg 1038, Level 15, State 3, Line 85 Cannot use emp...more >>

How to do this
Posted by Darren at 12/10/2003 8:45:23 AM
I need to maintain a copy of all transactions made in a database and who made them. My current thinking is to create another database called MyDB_History and maintain copies of all of the original tables in this database. What I need is everytime table data is changed, I want to copy that data...more >>

Full Text Search for numeric values
Posted by Pinto at 12/10/2003 8:41:05 AM
I'm using Full Text Search to query a table, when i search for the string 333 no results are returned but when i search for 22-333-4444 using FREETEXT or CONTAINS results are returned. Does anyone know if there is a problem looking for numeric values? The data type on my column is NVARCHAR. I hav...more >>

Creating Security Rule
Posted by Steve at 12/10/2003 8:24:05 AM
How can I create a security rule for my database? ...more >>

One FOREIGN KEY refrences a Table with two Primary Keys
Posted by Steve at 12/10/2003 8:23:27 AM
How can we create a table with one FOREIGN KEY column that refrences a table with two or more PRIMARY KEYS? (I need just one of the primary keys for referencing) ...more >>

Import to and Export from a text file
Posted by Steve at 12/10/2003 8:21:32 AM
1- How can I export a table to a text file (by SQL Script)? 2- How can I import a text file to a table in my database(by SQL Script)? ...more >>

INSERT INTO + SELECT
Posted by Steve at 12/10/2003 8:20:40 AM
How can enter data from a different table using "INSERT INTO" and the SELECT statement? ...more >>

Ideas for a password field...
Posted by Roz at 12/10/2003 7:19:08 AM
Hello, all. I'm create a table that'll need to store a Password field. What's the best datatype to use? I've read about "Binary" being used to store confidential data, as it converts the actual data into unreadable garbage. Is this the most common used method? Also, will I be able to ...more >>

Format Date
Posted by Don Grover at 12/10/2003 6:36:26 AM
How can i get a formated date string from GetDate() to return this string Thu, 11 Dec 2003 17:00:00 +1100 I need to set an expiry date on a cdo message header to +3 hours from request time Don ...more >>

sp_who2
Posted by Offeral at 12/10/2003 6:36:08 AM
Is is normal to have multiple lines with different CPU Times assigned to the same SPID?...more >>

Change Management of SQL Objects/Scripts
Posted by MattJazzyPants at 12/10/2003 6:16:09 AM
I'm currently tasked with designing an appropriate way of the change management of SQL Objects and static data scripts. We currently use VSS to manage code and it works well for the usual VS code and docs. However, for the SQL, one or two extremely large and unwieldy script files are used to create...more >>

Fiscal Week Conversion
Posted by sharon at 12/10/2003 5:51:52 AM
Hi, How do i convert a given date to fiscal year,week and day using T-sql? any help is appreciated Sh....more >>

row number?
Posted by chris at 12/10/2003 5:41:05 AM
Hi All In other versions of SQL (UDB, SAS) it is possible to get the row number returned from a select. Is this possible in SQL server ex select rownum(), nam from mytabl return 1 SALL 2 TO TIA Chris...more >>

SP error upon creation
Posted by Darin at 12/10/2003 5:11:11 AM
I have created a stored procedure: CREATE PROCEDURE dbo.Update1213 AS DECLARE @intErrCode int SELECT @intErrCode=@@error BEGIN TRANSACTION IF @intErrCode=0 BEGIN ALTER TABLE POCompany ADD pcmp_lastorder int NOT NULL DEFAULT(0) SELECT @intErrCode=@@error END IF @intErrCode=0 BEGIN...more >>

Execute Permission
Posted by Anand at 12/10/2003 3:49:32 AM
Hello All, I have a Database "UserDB". This database has a user "USER_A". He has very minimal permissions. But I want to grant him permission to execute xp_sendMail. Is it possible? I tried this way, but it says GRANT EXECUTE ON master..xp_sendmail TO USER_A Server: Msg ...more >>

Stored procedure - OUTPUT parameters are default if first one set to NULL
Posted by leeatkinsonlincs NO[at]SPAM hotmail.com at 12/10/2003 3:31:11 AM
Hi - if I have a SP CREATE PROCEDURE Test ( @a nvarchar(32) = NULL OUTPUT, @b nvarchar(32) = NULL OUTPUT ) AS SELECT @a='aaaa' SELECT @b='bbbb' I get the output parameters values, @a='aaaa', @b='bbbb' However, if the SP is: CREATE PROCEDURE Test ( @a nvarchar(32) = NULL OUTPU...more >>

Table Define
Posted by Aris at 12/10/2003 2:13:05 AM
Hi all, I want to define a membership table like (Pyramid). It can be search from up to down or down to up member list. What is the best way to define or use OLAP cube? For Example Level 1 - Tom Level 2 - John Level 3 - May Level 4 - Apple Level 5 - Cat Level 6 - Candy Level 7 - Joh...more >>

ADODB CommandType and User Defined Functions
Posted by Martin Smith at 12/10/2003 12:47:01 AM
What ADODB CommandType should optimally be used to execute SQL 2000 User Defined Functions returning a table? I can't find any documentation on ADO/UDFs and would be grateful for any info. Cheers, Martin ...more >>

Licensing MS SQL 2000
Posted by Alex at 12/10/2003 12:31:20 AM
We plan to use MS SQL 2000 for ASP.NET application Can we use License "Server plus Device CALs : 667$(Server)+146$(1 Client Device)=813$" Users send request to IIS, and IIS send query to MSSQL ...more >>


DevelopmentNow Blog