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 > august 2005 > threads for tuesday august 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 31

Text File
Posted by Hoosbruin at 8/9/2005 6:51:49 PM
I'm trying to create a text file that I can send to rightfax for automatic delivery. Here is what I have so far. declare @startstring char(80), @endstring1 char(80), @endstring2 char(80), @endstring3 char(80), @endstring4 char(80),...more >>


SQL-DMO Restore Object
Posted by TC at 8/9/2005 6:06:15 PM
I'm trying to write a VBScript to work with SQL-DMO. What this VBScript does is to restore database and its transaction log files. How can I specify the WITH NORECOVERY, WITH RECOVERY, or WITH STANDBY before running this script. Thanks. TC ...more >>

dbo owner
Posted by JFB at 8/9/2005 5:43:17 PM
Hi Everyone, I'm still with this problem and now I have little bit of time to find the solution. After any user import data to a table I want to have that table as dbo owner. I dont want to give my users full administrator permisssions. I try to setup in each database access as db_owner, db_...more >>

Using WHERE clause inside CASE WHEN programming
Posted by .Net Sports at 8/9/2005 4:31:01 PM
Is it legal syntax to insert a preliminary WHERE clause inside a CASE WHEN statement when trying to alias field names according to a criteria. I want to make an aliased field called 'inactive' that looks for order types less than 3, but are attached to rows with a date stamp of yesterday: i...more >>

Parameters best practice
Posted by chuck rudolph at 8/9/2005 4:06:06 PM
Folks, What is the recommended best practice for the following? Let’s say we are in the pubs database and we want to return some employee information via a stored proc with an optional parameter of last name. The issue at hand is how do you structure the stored proc to allow multiple last ...more >>

Database Statistics
Posted by John at 8/9/2005 3:33:02 PM
I am trying to find an efficient way to get the number of times that each row in a table is selected. I want to avoid using triggers. Any ideas? Thanks John jpd0861@msn.com ...more >>

Average Value Script
Posted by Joe K. at 8/9/2005 2:35:44 PM
The table listed below is sampled every minute with a [CounterDateTime] [char] (24) format. I would like to create a script that will average the MarketValue, FirstMarketValueA, and MarketCount fields in hourly format using the same counterIDs. Please help me create a script for a...more >>

uniqueness contraint question
Posted by PJ6 at 8/9/2005 2:02:17 PM
Is there a way I can customize the error message coming back from a uniqueness contraint violation on insert? Right now I use a trigger to enforce uniqueness and throw an error with my own message - works fine but I would sort of prefer using the built-in constraint if possible. Can't have t...more >>



Every query returns 'S1C00 - optional feature not implemented. HELP !!!
Posted by Darius at 8/9/2005 1:53:45 PM
Greetings I'm running; - win2k - SQL Server 7.0 with SP4 - "SQL Server" ODBC driver version 2000.85.1117.00 We have an sql server 7.0 database that gets updated every day by a small app (also running on the database server machine). It uses the 'SQL Server' ODBC driver that was installed ...more >>

Trouble porting from Personal Oracle to MSDE
Posted by brianlgilbert at 8/9/2005 1:52:01 PM
We have ported our product from Personal Oracle 8 to MSDE, and from NT to XP. The product is a set of ~15 Windows applications totalling about 450 KSLOC that interact via COM and manipulate the same database of about 150 tables. Some tables are accessed by only one app, but others are access...more >>

Using outer join
Posted by Cathy Boehm at 8/9/2005 12:59:03 PM
I am working with three tables to produce certain results: Consider the following SQL select: SELECT A.Col1, A.Col2, A.Col3, A.Col4, A.Col5, B.Col6, B.Col7, B.Col8 from Table1 A, Table2 B, (select Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col8 from TEMP_TABLE) C where A.Col_fk = B.Col_pk and...more >>

Return statement
Posted by simon at 8/9/2005 12:53:08 PM
I have stored procedure which at the end returns a value: if @@error=0 and @quantity=0 return 1 else return 0 But I get an error: A RETURN statement with a return value cannot be used in this context Why? regards,S ...more >>

database name
Posted by eg at 8/9/2005 12:50:38 PM
When using query analyzer i need to know what database the scripts is running on and store that name into a variable. is there a global database name variable? I know about @@servername but no @@databasename :( ...more >>

Database Synonyms
Posted by Edgar Rodriguez at 8/9/2005 12:39:16 PM
The following situation appears: two data bases DB1 and DB2 exist. The data base DB2 is fed with the DB1 information, that is to say, some transformations in the DB1 data take place to be protected in DB2. This task is easy to solve programming a DTS, nevertheless, the single transformation ...more >>

Date Formats/Styles
Posted by hals_left at 8/9/2005 12:36:57 PM
Hi, Is there any list available of style codes used in formatting dates e.g Convert(Varchar(11),GetDate(),106) I cant find these style codes or this method documented in BOL. I want to format a date like this: 09 August 2005. How? Thanks. hals_left ...more >>

?HOW: Auotincrement without using autoincrement
Posted by Lee Gillie at 8/9/2005 12:18:38 PM
I have a master table which I have been updating in multiple queries to create a new row. It has a primary key, call it WorkID. I can't make it autoincrement. And it is more complicated because.... WorkID can also appear in two other tables, as references to the master record, but I need to...more >>

Join type based on condition?
Posted by Matt at 8/9/2005 12:00:23 PM
Given two views, I need to join them based on the number of rows returned as follows: ViewA 1+ rows, ViewB 0 rows: ViewA LEFT JOIN ViewB ViewA 0 rows, ViewB 1+ rows: ViewA RIGHT JOIN ViewB ViewA 1+ rows, ViewB 1+ rows: ViewA INNER JOIN ViewB Easy enough to implement in a stored proc with a ...more >>

Can't find objects
Posted by JohnnyMagz at 8/9/2005 11:59:56 AM
I have a database with a bunch of objects owned by a user named, "tims". I am logged into SQL Query Analyzer as the tims user, but I can't locate objects unless I use I qualify them with the owner name. For example, exec sp_select_corridors #doesn't work exec tims.sp_selelct_corridors #works...more >>

Changing Database Context in T-SQL
Posted by Ross Culver at 8/9/2005 11:20:07 AM
How can one change the database context within a stored procedure? In other words, something like this .... Declare @DB varchar(20) set @DB = (Select databasename from databases where activedatabase = 1) Use @DB Select * from Table1 This code doesn't work, but I'm sure there's a wa...more >>

Accessing SQL2K on the net from local pc
Posted by Gérard Leclercq at 8/9/2005 10:15:12 AM
Hi, i'm new to SQL2K. I see in my connect string (ASP) a IP-address. I can choose between a public or a internal IP. If i use the public IP, where can i find examples on how to query the database from a local pc in a Visual Basic 6 program ? Or is this not possible? Gérard. ...more >>

putting error lines in new table or file
Posted by Job at 8/9/2005 10:07:49 AM
I'm importing large text files (12Gig). I know there are rows in the data that will not parse correctly. What I'm trying to figure out is how to set up the import and when there is an error parsing a row, that row either gets saved to another table or text file and then continues to import t...more >>

Does views use table indexes.
Posted by Peter Strøiman at 8/9/2005 10:06:12 AM
Hi. I have a situation where I have a table containg data, but several columns can be used to designate that the data is "hidden". E.g. if we delete a record, it isn't actually deleted but a datetime field called deleted_date is changed from null to the current date-time. Therefore I mad...more >>

Is there a set-based solution for this? <long message>
Posted by Daniel Wilson at 8/9/2005 9:55:27 AM
I am trying hard to avoid writing a cursor to drive a report, but I can't see a set-based solution. Can some of you? The table ScanLog records the time, operator, and machine at which a certain operation was performed as entered by a barcode scanning application. CREATE TABLE [dbo].[ScanL...more >>

Moving instance of Sql server to different location
Posted by LNN at 8/9/2005 9:40:06 AM
Is it possible to move an instance sql server from one drive to another, i.e. C: to D: without changing connection properties referenced in DTS packages, etc.? T.I.A....more >>

variable assignment with Distinct?
Posted by marcmc at 8/9/2005 8:44:14 AM
How come you can't do the 1st one but can do the second claim_ref_id dataType is int DECLARE @claim_ref_id int SELECT @claim_ref_id = distinct claim_ref_id FROM TableName(nolock) WHERE claim_ref_id not in (SELECT claim_ref_id FROM ViewName(nolock)) DECLARE @claim_ref_id int SELEC...more >>

Restore backup error "Media family incorrectly formatted"
Posted by Kalvin at 8/9/2005 8:18:06 AM
I am trying to restore backup from database1 with move to database2. RESTORE DATABASE Database2 FROM DISK = '\\uncpath\database1.BAK' WITH MOVE '_Data' TO 'LocalPath\database2.MDF' , MOVE '_Log' TO 'LocalPath\database2.LDF' , REPLACE , DBO_ONLY , NORECOVERY I am getting the error: ...more >>

Bulk Insert with mid-string newlines
Posted by NeilDJones at 8/9/2005 7:36:33 AM
Hi. I have a text file with several fields. One of these sometimes contains newline characters. Any fields that do include newline characters are enclosed with double quotes. What Bulk Insert command line do I need to use to impot the file without it treating the enclosed newline characters...more >>

PASSING ORDER BY AS PARAMETERS
Posted by Sergey Zuyev at 8/9/2005 7:04:03 AM
I have a stored procedure that excepts @orderby as a parameter and executes following sql statement: select * from titles order by case when @orderby = 'title' then title end asc Is there anyway I can add second parameter @direction and control...more >>

Using TEXT data type fields
Posted by MD Websunlimited at 8/9/2005 6:41:16 AM
I'm in the process of converting a Access Database to MS SQL and have = made the memo fields in the Access database text fields in MS SQL. = However, when I use a SELECT statement in a ADO application, the text = fields data is not returned. The memo fields are all under 4000 = characters.=20 ...more >>

Bulk Insert with Added Columns
Posted by G. Kumar at 8/9/2005 6:34:01 AM
Hi, I'd like to do a bulk copy insert inside a dts package but the table i'm inserting to has more columns than the text file. I know you can change the format file to take care of this, but how do you insert actual values into those extra columns instead of just NULLS? The values for those ex...more >>

SQL Formatter
Posted by jsfromynr at 8/9/2005 5:27:28 AM
Hello All, I am looking for a SQL code indenter . The one I found http://sqlinform.com is good but somewhat limited. Can you guide me to some other links. (preferably freeware) With warm regards Jatinder Singh ...more >>

test
Posted by Enric at 8/9/2005 4:32:05 AM

Difference b/w SPs & Functions
Posted by Rakesh at 8/9/2005 4:22:03 AM
1. cannot hv tran in functions 2. cannot include SPs in select queries or in from clause whereas functions can be included. (exception using OPENQUERY for including SP in from clause) What other differences?...more >>

Is a 'VIEW' automatically updated from tables?...
Posted by trint at 8/9/2005 3:55:04 AM
Ok, I have several tables that receive INSERTs. I have a certain 'view' that I've created that I created like the following: CREATE VIEW V1 WITH SCHEMABINDING AS SELECT t1.MemberId, t1.PeriodID, t8.start_date, t6.amount_type_id, t6.amount_type, SUM(CASE WHEN ...more >>

Decimal to Hex formatting
Posted by stainless at 8/9/2005 3:33:59 AM
I have a specific SQL Server coding problem. I have an 8 character field that is an integer. eg: 16776976 In hex this is FFFF10 This represents the Red, Green and Blue hex values for a colour, in reverse order: ie. 10 is red, FF is green, FF is blue I need my SQL Server stored pro...more >>

Showing an example of a cursor
Posted by Stephen at 8/9/2005 2:51:04 AM
I have been asked to produce an example of a cursor and then to point out why it isn't required to use on. I am having difficulty creating my example and I was wondering if someone could help me with the syntax to write one. Basically I want to select the FavouriteSport table (below) into a ...more >>

Order of execution
Posted by Madhivanan at 8/9/2005 2:22:15 AM
Select Columns from table where col1='value1' and col2='value2' and col3='value' In the above select statement, if col1='value1' is false then there is no need of checking for the other conditions Will SQL Server skip further condition if one condition become false or check for all regardless...more >>

TABLOCKX or NOLOCK?
Posted by Greg C at 8/9/2005 1:58:57 AM
I have large, slow updates. No one else is in the database when I'm loading recs. Would TABLOCKX or NOLOCK help speed performance? TIA! -- Greg C ...more >>

backups
Posted by Enric at 8/9/2005 1:31:03 AM
Dear all, I would like to know in what table the backups are stored. I mean, I see in the SQL Server log registry these lines: Database backed up: Database: DATA1, creation date(time): 2005/07/26(17:11:49), pages dumped: 63699, first LSN: 2724:195:1, last LSN: 2724:197:1, number of dump ...more >>

Enterprise Manager-like application
Posted by at 8/9/2005 12:00:00 AM
I wanted to build my own custom version of Enterprise Manager using vb.net. Where can I get the icons/pictures that enterprise manager uses (eg the icons used in the treeviews for database, table, user, stored procedure, user-defined function etc) ...more >>

combining 2 rows
Posted by Craig H. at 8/9/2005 12:00:00 AM
Hello, I have a query that returns 2 rows, which I need to combine into 1 row. The query looks like this: SELECT t.CName, t.AName, t.ACurrency, Sum(t.NumPayments) AS 'Payments', CASE WHEN t.TCode = 'debit_batch' THEN SUM(t.LAmount/t.ExchangeRate) END AS 'Amount (incl. commissi...more >>

@@ROWCOUNT = 0 in a trigger
Posted by C-W at 8/9/2005 12:00:00 AM
I'm going over some triggers in an old database we have and have come accross the following... .... IF (@ROWCOUNT = 0) RETURN .... Can a trigger ever fire if zero rows were affected? Should I remove this from the trigger? Thanks. ...more >>

What is the maximum length of record for this table ?
Posted by Pedestrian Ooi at 8/9/2005 12:00:00 AM
I'm using MS SQL Server 2000. Here is the table definition: CREATE TABLE BigTable ( Column1 int IDENTITY(1,1) NOT NULL, Column2 nvarchar(10) NULL, Column3 nvarchar(100) NULL, Column4 nvarchar(4000) NULL, Column5 nvarchar(2) NULL, Column6 smalldatetime NULL, Colu...more >>

How to Join?
Posted by Bpk. Adi Wira Kusuma at 8/9/2005 12:00:00 AM
I've 2 tables. Tb1 F1 F2 --------------------- 1 Adi 2 Ytk 2 Yuk Tb2 F1 F3 ------------------ 1 5 1 6 2 7 3 2 I wanna join 2 table above, So I get data like it: F1 F2 ...more >>

Converting Numbers
Posted by Roy Goldhammer at 8/9/2005 12:00:00 AM
Hello there I have numbers that i would like to present it as standart currency: 0.00 and still has it as number So far i could do this only by convert it to text. and it's not good because i'm export it afterword to Excel. I've tried to convert it to Decimal(10,2) and it didn't do the jo...more >>

Index building transactions
Posted by stjulian at 8/9/2005 12:00:00 AM
We have had an unusual experience recently. A literally tremendous amount of transactions occurred on a table. This table had indexes placed on it. We had uncovered the transactions from the log file through ApexSQL Log. The symptoms were that each record in the table was being deleted and th...more >>

Converting Clipper .DBF tables to SQL Server 2000
Posted by David C via SQLMonster.com at 8/9/2005 12:00:00 AM
My company is running a large Clipper application using Advantage Database Server 6.2 as the backend. We have .DBF tables. We have 6 major retail markets with over 200 tables in each folder (market). I am looking for an easy (if that is possible) way to convert these .DBF tables into SQL Serv...more >>

returning records from a stored procedure (SQL Server 2000)
Posted by at 8/9/2005 12:00:00 AM
is there any way to return records from a stored procedure without having to create a table or temporary table structure for the records. What I mean is, is there any way to do something like: select * from sp_my_procedure. What is the closest we can get to that kind of simplicity? ...more >>


DevelopmentNow Blog