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 > july 2007 > threads for wednesday july 11

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

SQL CLR - Return complex types
Posted by kerry at 7/11/2007 11:40:01 PM
I'm looking to return an object hierarchy from a .net clr function/procedure call, i.e. parent classs with children classes (different class type). I am aware of the following options for doing this: - Serialize to xml and use sql xquery to work with it - De-normalise into a flat structure an...more >>


Datediff function
Posted by vanitha at 7/11/2007 11:12:04 PM
Hi, my query is declare @startdate datetime declare @enddate datetime select @startdate = '2006-09-09 14:06:49.347' select @enddate = '2006-09-09 14:07:26.020' select datediff(n,@startdate,@enddate) select datediff(s,@startdate,@enddate) it's returning 1 37 the difference be...more >>

Raid 1 for log files
Posted by Mark at 7/11/2007 9:46:02 PM
We are purchasing a Dell 2950 for the backend of a write intensive vendor application running SQL Server 2005. 2 fixed disks will be Raid 1 and remaining 6 disks will be Raid 5. OS will be on RAID 1. Data Files will be on Raid 5. Should the log files go on the Raid 1 or Raid 5 drives? I h...more >>

calculating Execution time
Posted by bb at 7/11/2007 6:23:56 PM
I have tuned a stored procedure. Now before I apply the changes to the production, I want to compare the execution time of tuned SP on dev machine and non tuned SP on the production server. I am seeing how much time a query takes to run on the status bar of query analyser. But the time display...more >>

How sort ascending but with nulls at end?
Posted by Ronald S. Cook at 7/11/2007 5:39:30 PM
Let's say I have a Product table like this: ProductName ProductRank Alpha 1 Bravo NULL Charlie 5 Delta 2 Echo NULL Foxtrot 4 Golf 3 I want to write a query to return the data like this: ProductName ProductRank Alpha 1 Delta 2 Golf 3 Foxtrot 4 Charlie 5 Bravo NULL...more >>

collations compatibility issue
Posted by daveygf NO[at]SPAM gmail.com at 7/11/2007 4:52:20 PM
We are installing SQL 2005 on a server that has windows regional settings defined as Spanish (Chile). All the clients will also use Spanish (Chile) regional settings. We don't want to change the collation of the db (it is set as SQL_Latin1_General_CP1_CI_AS throughout the database at the column ...more >>

Recursive Manager Hierarchy
Posted by Justin Doh at 7/11/2007 4:44:02 PM
I am trying to write a stored procedure that could create a table called [B]tblManagerHierarchy[/B]. It is a table that contains recursive data. The data is coming from tblEmployee where it contains fields called EmpNum and ManagerEmpNum. [B]tblEmployee[/B] (EmpNum, ManagerEmpNum) The t...more >>

views vs stored procedure
Posted by at 7/11/2007 4:29:42 PM



Nested Sets
Posted by INTP56 at 7/11/2007 4:24:04 PM
Has anyone tried implementing the Nested Sets representation of hierarchies? I'm curious to hear of other's experiences, other than Celko's of course! The biggest question I have is how do you handle the DML? The article's I've read want to limit INSERTs to one at a time, say, via PROCEDURE,...more >>

Simple problem for competent programmer. Trying to use CASE to go from one table or another.
Posted by Finny388 at 7/11/2007 3:41:48 PM
Hello all, I haven't done SQL in years and I can't see what I'm doing wrong. I have two tables. A primary and a secondary. I am trying to pull items monthly quantities from primary but check a second table and if item has a qty for it in that month, use that qty instead. I've simplified it d...more >>

Backup Durations
Posted by Loren Z at 7/11/2007 3:36:02 PM
I have job which runs a stored procedure which (among other things) sends information including the duration of the backups of each database. The backups are done through maintenance plans we have created. In SQL Server 2000, this was easy to get at through the duration column in the sysdbm...more >>

Where SQL Server Dedicated Server Managed?
Posted by Al Franz at 7/11/2007 1:44:39 PM
Any recommendations on a hosting company for a dedicated Windows Server that is MANAGED and would allow one to install SQL Server on the box. ...more >>

converting an empty texbox to a null datetime field...
Posted by Brad Pears at 7/11/2007 1:25:09 PM
I am using vb.net 2005 and SQL server 2000. In my table I have a date field of type "smalldatetime". In my vb application, the user may or may not enter a date value into the appropriate text box. I then want to pass the value of this text box as a datetime variable to my stored procedure whic...more >>

Can SQL 2005 run every single SQL 2000 command?
Posted by Alex Castillo at 7/11/2007 1:25:04 PM
Hello... Are you aware of any case where a MS SQL 2005 Server can't run a command writen for a MS SQL 2000 Server? Thanks..! ...more >>

LAST DAY OF LAST MONTH IN ORACLE FORMAT DD-MMM-YYYY?
Posted by jobs at 7/11/2007 1:06:00 PM
Hello, In SQL server, how can produce First day of last month and last day of last month in oracle date format from the system time ? for example 01-Jun-2007 and 30-Jun-2007 Thanks for any help or information. ...more >>

Profiler - replay error
Posted by Derrick at 7/11/2007 12:26:13 PM
I am taking a sql2k profile, using the replay template of a few simple db operations. All local, I have all access, etc. I replay the trace against a backup of the pretrace db, with all the same user names, pwds, roles, default dbs, etc. The first few trace statements execute ok. After hitt...more >>

create application wide connection object - HOW?
Posted by JP at 7/11/2007 12:26:10 PM
Is there a way to create an application wide connection object in C# so I don’t have to create a new one for every page? My issue is that while I can do this within the scope of a single aspx page. It can really drag down performance because each portion of the page is made up of user contro...more >>

sql server constraint
Posted by Wendy Elizabeth at 7/11/2007 12:10:01 PM
I want to be able to change the value of two tables where the key in one table is a key in another table. There is a check constraint set on the main table so that you can not change the value in both table. However for one user, I want to change the value of the key from one number to an...more >>

ISO8601 and convert not working as I'd expect
Posted by Mark at 7/11/2007 12:04:02 PM
Hi... I was experimenting with getting dates in and out of Sql Server 2005 and working with them programmatically, and I was running into behaviors I didn't expect. From what I've seen in the docs, the last line should produce the same output, but it doesn't. Basically I'm trying to go ...more >>

Monitoring sql 200 activities for XP
Posted by mecn at 7/11/2007 12:02:56 PM
Hi, I have a special user extended Stored Proc in master db. UDFunction in each database to call that XP. I need to create a log table to monitor users every time they execute that XP either by UDF or by calling XP directly. I need to know username hostmachine datetime and sql statement ......more >>

Variable Usage?
Posted by Linn Kubler at 7/11/2007 11:35:36 AM
Hi, This is probably a simple question, at least I hope so. I would like to use a variable in place of a list of items used in the IN() command. But I can't quite figure it out, here's what I've tried... Select * From mytable Where acctperiod IN ('2006_11', '2006_12') -- This works fi...more >>

ROW_NUMBER datatype
Posted by Smokey Grindle at 7/11/2007 11:20:03 AM
I am looking in BOL at the ROW_NUMBER function and it doesnt specify what data type the returned number is in, is it integer, bigint? any ideas? thanks! ...more >>

Code running without affecting the result
Posted by Jack at 7/11/2007 11:10:04 AM
Hi, I posted this code earlier. However, it was a different issue which got resolved. Here I am using a Access form to update record in sql server pubs databse using parameterized stored procedure. However, the update is not taking place. I appreciate any help on this. Thanks CODE: Private ...more >>

Bad stored proc code compiles and deletes all table data!!
Posted by Wasyl at 7/11/2007 9:54:05 AM
I have inadvertently came across a way to delete every record from my table by using invalid stored procedure code. Basically by adding a subquery which is invalid to the stored proc, it passes validation and is created on the database. Later executing causes all table data to be deleted. B...more >>

ignoring time on datetime field
Posted by doofy at 7/11/2007 9:24:11 AM
Is there some easy function that would allow me to ignore the time portion of a datetime field when running a query? I don't care if it sets the time to 12:00:00. I only want to know that something happened on a certain day....more >>

Concatenating TEXT Columns into single TEXT columns across rows
Posted by Todd Wilkins at 7/11/2007 9:12:03 AM
The following query truncates my data to the first 8000 bytes. Any suggestions on how I should accomplish this? UPDATE TARGET_DB.stix.MedChart SET ChartNote = (CONVERT(VARCHAR(8000),b.Notes) + CONVERT(VARCHAR(8000),b.Notes2) + CONVERT(VARCHAR(8000),b.Notes3...more >>

Federated partitioned views
Posted by Suri Nagarajan at 7/11/2007 9:06:01 AM
I am trying to created federated partitioned views (for update), my ideas is to split a table to two servers and create a single view based on the split local table and a table on the linked server. Customer Id (Integer) is PK for the table (see DDLs below) , to spread the load equally I ...more >>

Semi Colon in the middle of a string of numbers Options
Posted by Dan Bridgland at 7/11/2007 8:05:41 AM
HI All, I'm trying to produce a report, but I'm having trouble with a field which contains numbers and semicolon separators the filed looks something like this... 38100 4400 4430 4400;4430;4490;45000;4520;45510;4511 3841 4430 48400 4400 I need to find every occurrence 4430 and ...more >>

Date query to show +120 days ??????
Posted by bcap at 7/11/2007 7:22:27 AM
Hi, How do I get a query to show a range of dates from today to 120 days ahead. I want to show the results of an event between today and anything in the next 120 days. This is what I have for a where statement but does not seem to be working: WHERE (dbo.MediaDetail.EventDate BETWE...more >>

Sql Server does not exist or access denied
Posted by Jack at 7/11/2007 6:52:07 AM
Hi, I have the following code which I am testing to check the process of passing paramter to sql server stored procedure from an access form. However, the code throws me the above error. I am running this on my local sql server setup and I am sure that the userid and the password is correct. ...more >>

set ansi nulls off
Posted by Kevin at 7/11/2007 5:24:01 AM
I originally created a table with option ansi nulls off. now how do I turn ansi_nulls on for this table without drop/create? ...more >>

Pivot Data
Posted by David at 7/11/2007 3:16:02 AM
Hi All I have a table that I want to pivot as illustarted below and I am unsure how to go about doing this in SQL Server 2005. Any assistance would be appreciated. CREATE TABLE Sales ( col001 VARCHAR(30), col002 VARCHAR(20), col003 VARCHAR(20), col004 VARCHAR(20), col005 VA...more >>

Defining "Use double quote as Text identifier" on BCP.
Posted by geir at 7/11/2007 2:34:01 AM
Hi all. How do I define "Use double quote as Text identifier" using BSP file export from a SP (SQL2005). I am moving for old DTS to directly export to .txt files..... EXEC master..xp_cmdshell 'BCP multicase..vekRptItegraFilExport out K:\MultiCase\Filexport\SQL2005Eksport\ProduktFile.txt...more >>

change dbo on msdb and model db
Posted by majid at 7/11/2007 1:52:01 AM
Hi all, Now I inherited a new sql2k instance (itanium 64 cluster) and some fantastic things, that I've never seen. sp_helpdb did not work. I found out that the owner of some user db's did not match to logins in master. I used sp_changedbowner for them and everything is ok with them. Remain...more >>

read xml file content
Posted by farshad at 7/11/2007 1:22:01 AM
There is a folder which contains several different xml files. Question for each xml file, how can I get the contents of the xml file and then pass it to a Stored Proc? Is this to do with a sql function that takes the file path of the xml file, i.e. openxml or something similar? Thank...more >>

Distributed transactions using transactionscope very slow...
Posted by tdk at 7/11/2007 1:04:24 AM
Guys Quite a tough question. We are using .net 2 and the new transactionscope class to execute a distributed transaction across two SQL2005 servers from a webserver running windows 2003. The code in test simply calls a stored proc on both sql servers that just inserts a row into a test table ...more >>

Get time from table
Posted by Leszek Gruszka at 7/11/2007 12:00:00 AM
Hello! I have a problem with specific query. I don't know how to write it... :/ My table looks like that: Time_stop | Time_Start | Name 2007-07-10 11:00:00 | 2007-07-10 11:45:00 | A 2007-07-10 12:00:00 | 2007-07-10 13:00:00 | B As result I need to get 1:45 (total sum of difference betwee...more >>

stored procedure question
Posted by Steve at 7/11/2007 12:00:00 AM
I have a stored procedure that only allows for one input at a time, how can I change this procedure to allow more then one? I want to pass several items to this procedure such as this name1,name2,name3,name4, instead of having to calling over and over again ...more >>

SQL2005: What is the best way to define global settings in TSQL stored procedures?
Posted by Max2006 at 7/11/2007 12:00:00 AM
Hi, I want to store some global settings for all of my TSQL stored procedures and SQL statements. This is something similar to what we have with app.config in C# programming. So far I am storing all of my settings in a table and a function returns the values. Something like this: pri...more >>

@@ROWCOUNT with restore in SQL Server 2005 Express doesn't work
Posted by Rauno.Uusitalo NO[at]SPAM gmail.com at 7/11/2007 12:00:00 AM
I run into problems after I updated MSDE to SQL Server 2005 Express. The following script used to work with MSDE. Now with 2005 Express the @@ROWCOUNT returns always a zero value and the last restore operation fails! RESTORE DATABASE Test FROM TestDev WITH NORECOVERY DECLARE @Backup...more >>

good practise (2)
Posted by Chris at 7/11/2007 12:00:00 AM
Hi again, I need another good practise advice. Everybody (100 persons) in our compagny manages one or more projects. Each projects needs two tables: table 'project' (general information), table 'projectdetails' (details of projects) and one or more result tables (one per project) like ...more >>

update a column in one database using a value from a different database/server
Posted by hals_left at 7/11/2007 12:00:00 AM
What is the syntax to update a column in one database using a value from a different database/server. I either get this error, if I leave out dbo: The column prefix 'Comp-102.dev.tblCentre' does not match with a table name or alias name used in the query. or this eeror if i put dbo in: The...more >>

OnBeginTransaction And OnCommitTransaction
Posted by ABC at 7/11/2007 12:00:00 AM
As I need to do some tasks when Begin Transaction and Commit Transaction raised, How can I do to like OnBeginTransaction Event() And OnCommitTransaction() on SQL Server? ...more >>


DevelopmentNow Blog