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 > february 2006 > threads for friday february 17

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

Query Design
Posted by Bill Bob at 2/17/2006 11:18:02 PM
I am going mad with this Query. I need to join 3 Tables. Their Formats are Vouchers [VoucherID] [uniqueidentifier] NOT NULL , [VoucherTypeID] [int] NOT NULL , [VoucherNo] [int] NULL , [VoucherDate] [datetime] NOT NULL , [VoucherNarration] [varchar] (255) CONSTRAINT [PK_Vo...more >>


SQL Query
Posted by cash pat at 2/17/2006 11:13:42 PM
I am going mad with this Query. I need to join 3 Tables. Their Formats are Vouchers [VoucherID] [uniqueidentifier] NOT NULL , [VoucherTypeID] [int] NOT NULL , [VoucherNo] [int] NULL , [VoucherDate] [datetime] NOT NULL , [VoucherNarration] [varchar] (255) CONSTRAINT [PK_Vouche...more >>

Can't figure out how to write query
Posted by ninel g via SQLMonster.com at 2/17/2006 7:48:19 PM
I have a table TABLE1. My company has 2 sites. This table contains employees with the amount of hours they worked on which project at which sites. [CODE] CREATE TABLE #TABLE1 ( Calldate varchar(10) NULL, Employee varchar(10) NULL, Project varchar(10) NULL, Hours decimal(10,4) NULL, Si...more >>

separate columns
Posted by perspolis at 2/17/2006 7:39:16 PM
Hi all I have a tables like this.. fCode Number 1 10 2 -3 3 4 1 -2 2 8 I want to separate postivie and negative values for fCode. like this fCode PNum NNum 1 10 -2 2 ...more >>

Timeout expired - on a simple SqlDataReader:Read() call
Posted by CuriousGeorge at 2/17/2006 5:15:10 PM
I have a very simple .Net 1.1 app that I'm writing to upgrade our applications database for a new version. This app has a pretty tight loop where I'm using a SqlDataReader to walk through all records in a fairly large table, manipulate the data, then write one of the columns back out. The p...more >>

Is it possible to join two tables in a View/Query where the Second Table is based on a Name in the First Table?
Posted by james at 2/17/2006 5:08:02 PM
How can I do this?? <TableA.tableName> is my psuedo for the TABLE I want to JOIN to but I can't figure out how SELECT TableA.tableName, <TableA.tableName>.someData FROM TableA LEFT OUTER JOIN <Tabl...more >>

Primary Key Question
Posted by Jeff S at 2/17/2006 4:57:00 PM
I'm planning to keep track of many [types of people], including patients, doctors, and referrals. Additional types will likely be added in the future (possibly "employees" or "staff") I plan to have a People table in which common attributes are stored, and then separate "type-specific" tabl...more >>

Called Web Services from a stored prcedure
Posted by Martin Waller at 2/17/2006 4:17:57 PM
Hello, Does anyone know if it is possible to call a web service from a stored procedure? Failing that is it possible to use exterbal object? I'm thinking along the lines of: @obj = CreateObject("xyzzy.f") @obj.j = 1 call @obj Is this wishful thinking ? Many thanks... ...more >>



delete contraint
Posted by Robert Bravery at 2/17/2006 4:03:54 PM
HI all, Hope I have the correct terminology. I have related tables, with cascading deletes off. In otherwords, you cannot delete a parent row if there are related child row. Now when this happens a correct error is produced. Is there any way to have a single return statement stipulation which c...more >>

Scheduled Backup for SQL Server Express
Posted by BCS at 2/17/2006 3:50:05 PM
Not sure if this is the right forum, so please correct me if I'm in error. I've written a Timeclock application in VB6 for our small chain of retail stores and storing the data in a SQL Server Express database. All is working well, but I want to perform a nighly backup of the database and there...more >>

Error in SQL 2005 Maintenance Plan
Posted by The Cornjerker at 2/17/2006 3:25:04 PM
I'm trying to setup a nightly backup to a remote computer using an SQL Server 2005 Maintenance Plan. It keeps giving an error. I've narrowed the cause down to an execute command... EXECUTE master.dbo.xp_create_subdir N'\\\\10.2.32.15\\Backup_SQL2005\\\\IOC' which is giving the error below...more >>

find out which tables used a specific field
Posted by js at 2/17/2006 2:36:05 PM
hi, how to find out which tables used a specific field in one database? Thanks. ...more >>

SP_DATABASES on SQL Server 2005 problem
Posted by Brian Henry at 2/17/2006 2:19:45 PM
In sql server 2000 we used sp_databases for users to return a list of databases (the users were not admins and had no special permissions besides had rights to a database or two) but in 2005 the non admins when they execute sp_databases to get a list back, well get nothing back! what has cha...more >>

Having a hard time with a Query for total + most recent Pass/Fail
Posted by Lucas Graf at 2/17/2006 2:14:16 PM
Here is a watered down DDL of my tables. CREATE TABLE Apps ( AppID smallint, AppName varchar(32), PRIMARY KEY (AppID) ) CREATE TABLE TestCases ( TestCaseID smallint, AppID smallint, TestCase varchar(32), PRIMARY KEY (TestCaseID) ) CREATE TABLE Reports ( ReportID smallint, ...more >>

nText in Triggers
Posted by Steph at 2/17/2006 2:06:35 PM
I want to do something like this Select @MyText = LongDescription From MyTable Where id = inserted.[ID] I get an error message telling me that nText is invalid for a local variable how can I do this? ...more >>

Code and diff sql servers
Posted by mikeb at 2/17/2006 1:55:16 PM
I'm running out of ideas... Given the following example of code: set @partialname = 'u' SELECT col1, col2, col3 FROM tbl1 WHERE col1 LIKE @partialName + '%' ORDER BY col1 Why would two different sql servers, having exactly the same data, give different results? One server returns ...more >>

How to order???
Posted by Daviso at 2/17/2006 1:44:13 PM
Hi. I have a table with 2 fields (personalName, companyName). I can insert person Names or company Names and one field tells me about what kind of field is. I want to retrieve the data, but ordered by person and company. Is there a way to do that??? Thanks ...more >>

Databasepropertyex problem
Posted by Amish Shah at 2/17/2006 1:02:48 PM
Hi when I run this query SELECT * FROM OPENROWSET('MSDASQL', 'DRIVER={SQL Server};SERVER=test;UID=sa;PWD=amish;','select name, databasepropertyex(name,''status'') as status from master..sysdatabases') AS a Result is Name Status master 0x4F004E004C0049004E004500 tempdb 0...more >>

Update record need self join problem
Posted by Rich at 2/17/2006 12:45:26 PM
Hello, My detail table has a subID column and a CompanyName column. For each subID there needs to be a corresponding CompanyName. subID CompanName a-01 JoneCo a-01 JoneCo a-01 Null b-01 ShmoCo b-01 ShmoCo b-01 Null I need to update this table to replace the Null ...more >>

ADO.NET 1.x, How to mimick Query Analyzer Batch Execute??
Posted by Crash at 2/17/2006 12:26:29 PM
Hi, ..NET v1.x SP1 VS 2003 SQL Server 2000 SP3 Server 2000, XP, Server 2003 I would like to programmatically execute {possibly many} SQL Server batch scripts. Aka I have many scripts that drop/add stored procedure definitions, alter table definitions & constraints, etc... and I would li...more >>

Export many users to new database
Posted by AkAlan at 2/17/2006 12:13:57 PM
Is there a system stored procedure or other method for mass exporting all users from one database to another on the same server?...more >>

Table-Value Functions in SQL 2005
Posted by Paul Rausch at 2/17/2006 12:01:12 PM
I have a multi-statement table function that works great in SQL 2000, but in SQL 2005 it will work great for awhile then after you call that function a bunch of times it goes from taking 2 seconds to run to 60 seconds to run with the same exact paramenters. This only happens through ADO.NET ...more >>

Automaticaly popluating Current Date in a Db Field
Posted by pmud at 2/17/2006 11:56:28 AM
Hi, I have a field in he db called LogDate. I have made it a timestamp type. Is there a formula or a default value i can set for this field in the table design view so that everytime a record is added, this field is automaticallly populated with teh current date? Thanks -- pmud...more >>

Data Access components with MSSQL 2000
Posted by MedioYMedio at 2/17/2006 11:30:04 AM
Can I use an application developed with DAO, ADO or RDO with MSSQL 2000? (I'm migrating the server) Are there compatibility issues? Greetings,...more >>

problem restoring backup of DB
Posted by Rich at 2/17/2006 9:12:26 AM
Hello, I copied a backup file of a production DB on a production server to another location on a Development server. When I try to restore this backup on the Dev server - from Enterprise Manager, I am getting an error message that states I need to use "With Move" to identify a valid locat...more >>

Determine security access to stored procedure through ASP
Posted by webJose at 2/17/2006 8:33:24 AM
I have an ASP application running in a MS Windows Server 2003 computer joined to a Windows 2000 Active Directory domain. Different users have different roles, and the security in the SQL database is based on Active Directory security groups (SQL server is configured for Windows security and no...more >>

Extract Phone Number String - Please Help!
Posted by Tom at 2/17/2006 7:26:32 AM
Hello Experts: I am a newbie to T-SQL, and I wonder if this is possible. I have the following possible phone number strings coming in: 1. 8882223333 2. 18882223333 3. +8882223333 4. 888 222 3333 What the expected end result is case #1: 8882223333. Is it efficient for T-SQL to proce...more >>

Help with Stored Prcoedure
Posted by star at 2/17/2006 7:03:21 AM
Hello I have written this stored procedure but I am getting following error. Server: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near '1'. Server: Msg 50000, Level 16, State 1, Procedure CopyDataArchive, Line 24 Error occured while copying data to December Here is the co...more >>

general questions
Posted by KBuser at 2/17/2006 6:52:33 AM
I guess I'll just post as much about my situation which I feel is pertinent, and hope I get the feedback I'm looking for. I'm not exactly sure what it is I am trying to figure out here, but I think I'll get some good suggestions... I'm working on a program in C# which takes files (either delim...more >>

Help with Stored Prcoedure
Posted by star at 2/17/2006 6:46:05 AM
Hello I have written this stored procedure but I am getting following error. Server: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near '1'. Server: Msg 50000, Level 16, State 1, Procedure CopyDataArchive, Line 24 Error occured while copying data to December Here is the co...more >>

Novice needs help with search
Posted by dtw at 2/17/2006 6:16:31 AM
I am a novice who hasn't mastered the SQL language yet. Your help will be appreciated. I need a query to search a table for records matching one or more of four conditions and then return them with the most matches first. For example, a table with name, birthdate, gender and zip code. S...more >>

tool for creating documentation for stored procs
Posted by Dirk Theune at 2/17/2006 6:15:33 AM
Hi, I am looking for a tool to automatically create documentation for stored procedures. I am thinking of something similar to ndoc in .NET, which creates doc from the comments in the stored procedure. Does anybody know of such a tool? Kind regards, Dirk...more >>

OBJECTPROPERTY problem
Posted by drink.the.koolaid NO[at]SPAM gmail.com at 2/17/2006 6:06:07 AM
Why does the first query work properly and return 1 for the IsMsShipped column when the second and third query do not? use Northwind go SELECT convert(varchar,name) as ObjectName, id, OBJECTPROPERTY(id, N'IsMSShipped') as IsMSShipped FROM sysobjects WHERE name='dt_adduserobject' use Mo...more >>

Calculate integral of time series
Posted by Ami Einav at 2/17/2006 5:48:28 AM
Hello, I want to compute an integral of values in a table that has 2 columns: Column A: Time-stamp (T) Column B: value (KWH) I need to compute the sum of (KWH*(T(n)-T(n-1))) Could you suggest a way to do it in T-SQL? thanks Ami ...more >>

optimize queries with unexpected results
Posted by Tristan at 2/17/2006 4:54:45 AM
Hi, This is one for the MVP’s. I am trying to optimize queries but I am finding un-expected results. I am using sql 2000. For example, I have read in several sites that referencing objects with qualified owner names is faster. The truth is that I am experiencing all the contrary. Am I ...more >>

XACT_ABORT AND char insert in INT datatype
Posted by verbani at 2/17/2006 4:45:16 AM
Hi, I have a series of insert statements and if it fails he has to rollback the transaction, do logging and set the current row in status 99. So after each insert statement I check @@ERROR to see if it failed. If the statement failed I will do all the above things. This works fine when m...more >>

Stored Procedure Perfornance
Posted by John McDonald at 2/17/2006 4:45:04 AM
In a recent discussion a statement was made that stored procedures perform better than dynamic SQL statements execution. This assertion was challenged and it there has been a remark that in SQL Server 2000 that stored procs are not faster although it is not sure if ths holds for SQL Server 20...more >>

MSSQL Mistake
Posted by juokaz at 2/17/2006 3:41:52 AM
I have only this piece of code and its said that there is mistake, it's excercise, so i dont have full code. SQL wrote: > *declare @UserID uniqueidentifier > SET @UserID = @@ROWCOUNT > SELECT @UserID > > this will throw an error yes, assuming your @UserID is an int this > should work >...more >>

link server with case expression
Posted by soonyu at 2/17/2006 2:16:28 AM
anybody know how many case expression can be in linked server query? when i have more then 10 "case" expression witjh linked server, sql query give this message : Server: Msg 8180, Level 16, State 1, Line 1 Statement(s) could not be prepared. Server: Msg 170, Level 15, State 1, Line 1 Line 8...more >>

best bulk insert command
Posted by Sammy at 2/17/2006 2:01:26 AM
I have a 5 million row table that gets truncated and new values get imported. The new values are obtained by values that have changed in other tables. Does anyone know the quickest way this can be acheived. I have tried this took around 34mins insert in attritable (attrivalue,attri_id,...more >>

Qty - decimal, money, or ...
Posted by Rock at 2/17/2006 1:30:27 AM
which data type will be the best for the qty column? - R...more >>

DROP DATABASE Question
Posted by chris at 2/17/2006 1:25:28 AM
Hello, in our project i have to drop an existing sql server database and immediately create a new (and empty) one with exactly the same name. MSDN says that in case of dropping a database also the physical files on the harddrive are deleted but this is not the case, as sql server complains ...more >>

"Where date" problem
Posted by גלעד at 2/17/2006 1:04:28 AM
Hi all, I bumped into this issue: If I run the following statement : "select sum(total) from sales where date>=dateadd(m,-14,getdate())" I get the result in 2-3 seconds, but if I run the following: "select sum(total) from sales where date>='2005-01-01 00:00'" it takes more than 40 seconds....more >>

T-SQL: How to loop through the resultset from another procedure?
Posted by Ronald Kloverod at 2/17/2006 12:00:00 AM
This is a SqlServer 2000 question. In my Transact SQL-code (actually a procedure called proc2) I'm calling a procedure called proc1. proc1 is returning a resultset, typically 1-3 rows. There is only one column in the resultset. In my T-SQL code in proc2 I want to loop through the resultset retu...more >>

Custom labels for DTS steps
Posted by Joe Gass at 2/17/2006 12:00:00 AM
Hi, we have DTS packages which call other DTS packages, sometimes a few levels deep. In our error logs out DTS steps are labelled like "DTSStep_DTSExecutePackageTask_4" Is there a way to give our DTS steps custom labels so that it'll be easier to work out which dts and which step has failed...more >>

Most basic transaction?
Posted by Lasse Edsvik at 2/17/2006 12:00:00 AM
Hello I was wondering if you could show me the most basic transaction in code? And rollback if error :) ...more >>

Backup error
Posted by Lasse Edsvik at 2/17/2006 12:00:00 AM
Hello I was told by email someone got an backup error and I gotta reply something to him, what reasons can there be for this error? All services are running and disk isnt full SQL Server Scheduled Job 'Transaction Log Backup Job for DB Maintenance Plan 'Backup All Databases'' (0xE09A5EC5A9A...more >>

Database Properties
Posted by Prasad at 2/17/2006 12:00:00 AM
Hi, From where can I get SpaceAvailableInMB and KB for a database for SQL 2000 and SQL 2005. sp_spaceused gives the Size of the Database, Data Space Used, Index Space Used. SQL-DMO gives it. Thanks Prasad ...more >>

case
Posted by ichor at 2/17/2006 12:00:00 AM
can i use case in an update statement? UPDATE pn SET pn.payg_tax = pn.witholdingtax, pn.witholdingtax = 0 FROM @PaymentNotification pn where witholdingtax > 0 and ato_payment_id is null UPDATE pn SET pn.witholdingtax = pn.payg_tax, pn.payg_tax = 0 FROM @PaymentNotification pn where...more >>

SQL & ASP
Posted by DNKMCA at 2/17/2006 12:00:00 AM
Hi, Im using ASP and SQL Server. The processed values from ASP are stored in the SQL Server When there is concurrent users say about more than 10 then only 3/5 users only getting updated to SQL Server immediately and remaining users takes approx 30 min to update in the database. here i'm ...more >>


DevelopmentNow Blog