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 > october 2006 > threads for tuesday october 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 29 30 31

Stored Procedure and Variable Table Names
Posted by David at 10/17/2006 10:40:32 PM
Hello all In my VB6 programme, I have numerous functions that retrieve data from a Jet 4.0 database. As a some of the data retrieval is pretty much the same except for the table and the fields that I require, I have written several generic functions to get my data, similar to this: Publi...more >>


Query Performance
Posted by vanitha at 10/17/2006 10:33:01 PM
Hi, in the query first i am inserting a set of records into a table variable(@orderlist) and then deleting the records from the @orderlist for different conditions. this query takes 23 minutes to execute. please help to fine tune this. my query Declare @Startdate datetime set @startd...more >>

Q: Tip on database design and a "simple" query question.
Posted by Martin Arvidsson at 10/17/2006 8:55:04 PM
Hi! I have a table that contains the folowing fields: ProjectID ProjectAssociation ProjectDescription ProjectTotalMinutes Now an example of the table data could look like this. 1, 0, My Project #1, 0 2, 1, Subproject for myproject #1, 0 3, 2, Sub sub project for myproject #1, 0 N...more >>

Interview Question
Posted by Raymond Du at 10/17/2006 7:32:19 PM
Hi Guys, I was asked an interview question today: "Have you worked on SQL server in an enterprise environment" My answer was yes, but I don't know what it means. Is this about the editions of SQL server? I don't think it's that simple. TIA ...more >>

@@servername value problem
Posted by GB at 10/17/2006 7:02:06 PM
Hello, I changed machine name on my SQL Server 2005 and than I changed default instance name by executing the following statements: sp_dropserver <old_name> GO sp_addserver <new_name>, local GO After that I restarted all SQL related services and executed: select @@servername and the v...more >>

my own global variables
Posted by emil at 10/17/2006 6:54:01 PM
Is it possible to create my own global variable? I want to have a trigger not fire when running from a certain stored procedure but i can't use alter table disable trigger because the table is replicated. Any ideas around this?...more >>

Converting DATETIME to ticks
Posted by Jon Pope at 10/17/2006 6:46:34 PM
Is there a way to convert a DATETIME value to ticks? I'm looking for something analogous to C#'s DateTime.Ticks property. Cheers, Jon ...more >>

Pivot Table
Posted by Carlos Felipe França da Fonseca at 10/17/2006 5:33:39 PM
I need to create a query where lines will become columns (pivot table) Does anybody know the easyest way to do that? It's a SQL Server 2000. Thanks!!! Carlos Felipe França da Fonseca ...more >>



Global variable on server?
Posted by Micus at 10/17/2006 5:17:48 PM
[VS2005 Pro, SQL Server 2000, Win XP Pro] Hello, I have a task which requires me to know the last row updated/inserted. There is an identity column in the table which is used in further operations. When a row is inserted, I can use IDENT_CURRENT() to retrieve this value. However when a ro...more >>

First ever post as I'm stumped (syscomments searching)
Posted by alexander_j_campbell NO[at]SPAM hotmail.com at 10/17/2006 4:13:44 PM
Here's the goal. Our developers have been selecting from tables in stored procs without adding the with(nolock) hint. This is a no-no for our client as it causes contention issues. They have asked me to identify every occurence of the absence of a with(nolock) in any SP for select statements. I'...more >>

Quarter Begining User Defined Function
Posted by Matt at 10/17/2006 2:23:51 PM
I am new to writing User Defined Functions in SQL Server (Ok theses are my first). I need to write two functions. One that will determine the Quarter Beginning and another that will determine the Quarter End dates. Here is what I wrote below. CREATE FUNCTION dbo.QuarterBeg (@when DATETI...more >>

Remove Weekends from Date Diffference
Posted by chfran at 10/17/2006 2:12:05 PM
I have a view that calculates the number of days between two dates. I want to remove the weekends that occur between those two dates. Any suggestions on how I would do that? Example: If it had been 10 days between the two days then really my view should show 8 days (10 days minus 2 weekend ...more >>

Urgent:Rows of data exceeding Microsoft capacity of 8060 do not er
Posted by Matthew Mark at 10/17/2006 2:06:01 PM
Max Row length in bytes is 8060. Through a third party software I found we have records exceeding the max data length. I further investigated and found its true. We have over 600 rows of data that exceed 8060 bytes. In some cases 5 to 6 times this long. Why aren't there any error messages...more >>

SELECT & SET
Posted by RON at 10/17/2006 1:57:28 PM
What's the difference between the following 2 queries especially the 1st line after declaring the variable @OrderCount int in the 2 queries (both the queries output the same resultset): -------------------- DECLARE @OrderCount int SET @OrderCount = (SELECT COUNT(OrderID) FROM Orders WH...more >>

Urgent help needed in writing a tricky Query
Posted by rk2008 NO[at]SPAM gmail.com at 10/17/2006 1:48:29 PM
I have a table with following data. Type Value a NULL a NULL b NULL b NULL b NULL c NULL c NULL c NULL c NULL c NULL I need to update Value column like an enumeration. for example there are ...more >>

Storing pdf files into IMAGE column using odbc or ado
Posted by Leifer at 10/17/2006 1:37:36 PM
Hi everyone, I'm new to this group I've tried a ruby and perl group but no one seems to understand how to do this. I have a pdf (coming in through a webapp, i can make a copy of it to disk) and I need to store it into a image column in sqlserver 2005. the file is too big for me to just conv...more >>

XQuery for all Descendants
Posted by Rob at 10/17/2006 1:26:52 PM
To all, I am new with XQuery and XPath so please forgive my ignorance. This is also an extension of a previous post called "XQuery and Hierarchical Data". I needed to post a new one because it was already closed. I am trying to produce a query that returns a table with a list of every des...more >>

Showing on a One-to-many relationship only one record from the "many" side...
Posted by SammyBar at 10/17/2006 1:17:01 PM
Hi all, I have the following problem: I have two tables on a one-to-many relationship. I need to return all the rows from the first table and only one row for the second table. Declare @A table ( IdA int ,Name varchar(100) ) Declare @B table ( IdB int ,IdA ...more >>

Temp Table's
Posted by Skip at 10/17/2006 12:56:27 PM
Hello All, I use several local temp tables in an application. These tables store information that is built from some text files by the user. This data cannot be mixed up by another user logging in at the same time. Is there a chance that another user can run the app at the same time as another ...more >>

Query Plans and if statements
Posted by john conwell at 10/17/2006 12:40:02 PM
If my stored proc has three sql statements wrapped in if statements like this: if @thing = something <big 'ole sql query 1> else if @thing = somethingElse <big 'ole sql query 2> else <big 'ole sql query 3> Can sql server cache a reusable query plan for this sproc? If so, will...more >>

how to copy columns from one table into 2 other tables
Posted by Hans - DiaGraphIT - at 10/17/2006 12:02:02 PM
I have following cenario where I want copy columns from one table into 2 other tables. (source) tbl1 tbl1ID column1 (bit) column2 (date) where column1 is true and and column2 is not null (destination) tbl2 tbl2ID new_column2 (date) fk_tbl1ID tbl3 tbl3ID new_...more >>

Question
Posted by Manny Chohan at 10/17/2006 11:56:01 AM
Hi Guys, I have a revenue table for my application With followin template data Store ID Reservations Revenue R/N Month Year 1 200 20000 175 1 2006 1 239 37461 183 2 2006 1 235 37213 164 3 2006 1 10 282 15 4 2006 1 139 38471 157 5 2006 2 128 19284 121 1 2006 2 123 19283 193 2 2006 I need...more >>

Need help with query syntax/logic
Posted by Bill Nguyen at 10/17/2006 11:40:57 AM
Table GPS_Vehicle columns: siteID vehicleID firstName lastName datetimestamp lat long I would like to select only records with datetimestamp = max(datetimestamp) for each vehicleID I used the following query and it worked well. Only that I would like to get all other columns ( fir...more >>

Question about DTS to Oracle
Posted by Roz at 10/17/2006 11:35:01 AM
Hello, all. I'm xfering data from a SQL 2000 table to an Oracle 10G database. The table in question contains 41 million records, and is a faily wide record. I've xfer'd this table from another SQL Server months ago, and it ran within an hour...very fast indeed. However, my DTS xfer to Orac...more >>

group by every 3 hrs
Posted by Julio Delgado at 10/17/2006 11:21:51 AM
Hi, I am logging process data every 5 min, every record has a datetime field in addition to the process data one of the requierements of the application is to avg the data every 3 hours. is there any simple way to accomplish this with a query or will it be better create a job that runs every 3...more >>

how to debug a store procedure
Posted by js NO[at]SPAM someone.com at 10/17/2006 10:29:11 AM
hi, I want to debug a store procedure and need to pass a datetime value( 02/11/2001) to it, but it said: [Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification how to pass datetime value in? also, I found if I change regional options to English(Canada) instead of ...more >>

Scope_Identity() returns null when used in a stored procedure with dynamic sql?
Posted by Brandi Lea at 10/17/2006 10:10:27 AM
I am about to scream and was wondering if anyone could help me with my issue. I recently wrote some triggers to act as a changelog system on our production database. The problem I am running into is that we have some legacy code that passes dynamic sql into a stored procedure and uses @@identity...more >>

CHnaging the Login associated with dbo in a Database
Posted by Jothi at 10/17/2006 10:04:02 AM
Hi, I have a database where the dbo user id is associated with a login name of 'Wizard'. How can i change this so that it is associated with sa login. 2)Suppose I try to create a UserId of Wizard in this database it gives me an error that the uSer alreay exists. But i dont see it under Users...more >>

VBScript in a Stored Procedure
Posted by MikeChicago at 10/17/2006 9:19:02 AM
Is it possible to put VBScript in a stored procedure and run it? If so how. Thanks....more >>

Sync data between DBs upon insert
Posted by francis.tatasciore NO[at]SPAM gmail.com at 10/17/2006 8:30:58 AM
Hi, I'd like to sync data between two sql servers. I have the exact same tables on server A and server B. What I need is that whenever data is inserted in one table of server A that it gets inserted in the same table on server B in close-to realtime. I've read that launching a DTS from a tr...more >>

SQL2005
Posted by Peter Newman at 10/17/2006 8:03:01 AM
how can i get the number of seconds since midnight ?...more >>

Conditional From Clause
Posted by adam.lock NO[at]SPAM gmail.com at 10/17/2006 7:53:23 AM
Is it possible to have a conditional FROM clause in a stored proc? i.e DECLARE @dtDate DATETIME SET @dtDate = '30 oct 2005' SELECT item1, item2 FROM CASE @dtDate WHEN < '1 nov 2005' THEN tableA ELSE tableB END Basically, dependi...more >>

Line breaks in text column
Posted by David at 10/17/2006 7:28:55 AM
I am storing notes from a web application into a text data type. It is a running progress of paragraphs separated by "<br />" so that line breaks display on the web view. However, when I export that column to Excel it creates multiple rows. What can I store (and run REPLACE() against) as an...more >>

@@rowcount problem
Posted by Phill at 10/17/2006 5:33:02 AM
I am trying to return a recordset, and if there are no records matching the criteria I want to return a default recordset. I am using the @@rowcount, but it is not working. Am I using it incorrectly? Thanks ALTER PROCEDURE dbo.usp_ServiceType_DDL_Customer @intCustomerID as int = -1 A...more >>

IN clause and string parameters for stored procedure
Posted by Murali at 10/17/2006 5:14:01 AM
I have a stored procedure that takes string parameter as input like below @CustomerCode = "'C1', 'C2','C3'" I am trying to use that in SELECT * FROM Customer where CustomerCode IN (@CustomerCode). The Above statement is not working. I know I can do it using dynamic SQL but I DONT WAN...more >>

insert query with join
Posted by Raghav at 10/17/2006 2:58:31 AM
Hi Friends I am using SQL server 2005 as a database in my project. Situation is like this: I have two tables namely Applicant and PersonalDetails. First we are inserting values in Applicant Table and after that in PersonalDetails. In Applicant Table, ApplicantID is primary key and also Applican...more >>

problem with stored procedure
Posted by Jan Heppen at 10/17/2006 2:49:01 AM
hello, I've a problem with one of my stored procedures why does sql server return no result when I preform [code]EXEC('SELECT * FROM trajecten WHERE rit_afd_nr = ''' + @bedr_afd_code + ''' AND rit_nr = ''' + @rit_nr + '''') [/code] but when I do this then I get a result [code] EXEC('S...more >>

Batched Update
Posted by Bob at 10/17/2006 2:36:01 AM
Can anyone see any problems with this code? I'm updating a large table ( 10 million rows ) in a SQL2K database and am trying to break the update up. Thanks wBob DECLARE @rowcount INT -- Initialise SET @rowcount = -1 -- Limit rowcount so update occurs in batches SET ROWCOUNT 10000...more >>

Newbie COUNT
Posted by RON at 10/17/2006 2:15:02 AM
A SQL Server 2005 DB Table named 'NETOrder' has the following 2 columns - OrderID (int, IDENTITY) & UserID (int). Assume that the table has the following 3 records: ------------------- OrderID UserID ------------------- 4 12 7 12 9 12 --------------...more >>

SQL State=s1000,Native error=0
Posted by Manish Sukhija at 10/17/2006 1:58:01 AM
Hi All, I want to transfer data through BCP utility, evrything i've done this, when i test Txt file on my local machine it is working fine but when i run this on client machine( Staging server) it is giving this error: SQL State=s1000,Native error=0 Error=[Microsof][ODBC SQL Server...more >>

Certification Guidance
Posted by Prasanna at 10/17/2006 1:49:01 AM
Hi All: I work in Data Warehousing domain and I am new to SQLServer. Can you guys suggest me which exams will be useful to me as a developer (not DBA) and the order in which I have to take them? Also, please provide me info on the study materials. Thanks in Advance, -Prasanna...more >>

How to use "FORMSOF Term " in full text index of SQL 2000 server?
Posted by gzwangyang at 10/17/2006 12:55:02 AM
There is a table "searchresult_companyorder_business_e" in my database and this table has a column "branch_name_all".I have created full text index for "searchresult_companyorder_business_e"."branch_name_all". I want to serach those records with 'car','cars'.But I failed,I can only search t...more >>

Maintaining uniqueness
Posted by Veeraraje Urs at 10/17/2006 12:00:00 AM
Hi All I need to maintain uniqueness on two of the columns (id, qty) in the table test1 which has the duplicate data already as shown below. CREATE TABLE dbo.test1( id int, qty int, nametext varchar(25) ); insert into dbo.test1 values (1,10,'YASH'); insert into dbo.test1 v...more >>

insert into with case statement
Posted by Hrvoje Voda at 10/17/2006 12:00:00 AM
@Language nvarchar(10), @FunctionID uniqueidentifier, @Name nvarchar(50), @ShortName nvarchar(50), @Description nvarchar(150) Insert Into UsrFunctions (FunctionID, ShortName) Values (@FunctionID, @ShortName) CASE @Language WHEN 'ENU' THEN UPDATE UsrFunctions SET NameENU...more >>

**collation**
Posted by M at 10/17/2006 12:00:00 AM
Hi I'm working with sql 2000 and I want to know if it's possible to change a server collation. by right-clicking on the name of server and selecting properties in general tab I can find the current server collation. but how can I switch to the other type of it? any help would be thankf...more >>


DevelopmentNow Blog