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 > march 2004 > threads for tuesday march 16

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

Counting with distinct - Optimizer Problems
Posted by Shawn Meyer at 3/16/2004 9:55:14 PM
I have a table defined as : CREATE TABLE [dbo].[job_13_event] ( [id] [int] IDENTITY (1, 1) NOT NULL , [recipient_id] [int] NULL , [event_type] [int] NULL , [mail_type] [int] NULL , ) ON [PRIMARY] There is about 5 million rows in this table; 1,063,337 have event_type=3; When I run ...more >>


Case statements
Posted by MBurns at 3/16/2004 9:39:42 PM
Hi, I've created a view that uses a CASE statement to set the value of a field depending on the value of another field. The view is created ok however I need the view to be updateable and this isn't the case at the moment. Is there another way to approach this problem so that I do get an u...more >>

Data transformation SQL query...
Posted by GB at 3/16/2004 8:46:50 PM
Hello, I have a table with following data in it: Company_name | Date | Old_company_ID | New_company_ID ---------------------------------------------------------------------------- ---------------------------------------- A |2001-12-20 ...more >>

DBSERVERENUM function in C++
Posted by Allan at 3/16/2004 7:31:05 PM
Hi This is probably pretty basic, but what do I need to include in my Visual C++ STDAFX.H file in order to use the dbserverenum function? My compiler doesn't recognize the function. I am using it to look on a network for an SQL server instance so I can update a database. Thanks for any help Alla...more >>

Working with Sheridan Grid
Posted by Vlad at 3/16/2004 6:40:16 PM
I'm moving my VB application from Access to SQL Server and have some problems. I have Sheridan Grids on several screens. They are working in unbound mode, which means I create an updatable recordset with SQL statement in VB. Sheridan Grid has special events such as UnboundDataRead, UnboundDataWr...more >>

Backup Question
Posted by SStory at 3/16/2004 5:53:46 PM
I am reading up on doing a TSQL Backup. I have some questions. My log file will keep growing if not truncated I have read. If I do a full database backup does this backup the database and the log or just the database? If just the database then I assume to get a good backup I should Do ...more >>

SMP Sum(*) slow
Posted by R-D-C at 3/16/2004 5:37:34 PM
Hi, I have a query that needs to sum selective wors out of a table (which is linked to two others for the query). When I select just the value that I am going to sum (SELECT Value FROM...) I get three results and it takes about 3 seconds. When I ask for the sum (SELECT sum(Value) FROM...)...more >>

NULLS in view
Posted by David Chase at 3/16/2004 5:19:49 PM
Below is a line of code in my view that does not work. Can anyone help? For some reason, when the firstname is null it does not work and I get a blank field. Customer = CASE COALESCE(dbo.Customers.LastName, '') WHEN '' THEN dbo.Customers.CompanyName ELSE dbo.Customers.LastName + ', ' + dbo.C...more >>



Number of Column inside a "SQL Server 2003" Table
Posted by vikash.verma at 3/16/2004 5:02:06 PM
Hi All, Can any one tell me how many column can be accomodated inside a Table of SQL Server 2003. In SQL Server 200 we could add 256 columns in a Table. What about SQL Server 2003.?? Hoping to hear frm you Thanks Vikash ...more >>

INNER JOIN newbie question
Posted by francois at 3/16/2004 4:54:54 PM
Hi all, I am building queries joining data from many tables (5, 6 and more) As I am afraid of performance consequences of joining so many tables together (and so much data for some tables), I would like to know what kind of policy I should follow when I join tables together. Usually most of...more >>

Object Permissions query
Posted by brian at 3/16/2004 4:31:09 PM
H I am wanting to construct a query to retrieve a list of tables and views that a user and it's group have access to. This need to include default group-level permissions, such as ddl_admin, etc for instance. I have a user "A" who is part of Group "XYZ". I want to retrieve a list of views and ta...more >>

Money type doesn't display the decimals
Posted by Jeroen de Graaff at 3/16/2004 4:21:10 PM
Hi all, Maybe you can help me with my problem concerning a column with datatype money: When I use Cognos ReportNet to retrieve the data from Column_A (datatype: money) all values are ALWAYS displayed as xxx.00 For example: the value stored in the database is: 17.95 (. is the decimal sign) then...more >>

Stripping out unwanted characters
Posted by Robert Wilder at 3/16/2004 4:15:38 PM
I have data that I need to strip out the dollar sign and parenthesis. The parenthesis are indicating a negative number. A B C $2.78 $11.20 ($8.42) $2.78 $11.20 ($8.42) $2.78 $11.20 ($8.42) $3.58 $11.20 ($7.62) My Select statement: ...more >>

Transactions question
Posted by Saga at 3/16/2004 3:54:09 PM
I have a question about a transaction that I have. Here is part of it: begin transaction declare @hstId int declare @curId int declare @newId int select @curId=max(id) from hdrData select @hstId=max(id) from histhdrData if @curId > @hstId select @newId = @curId + 1 ...more >>

getdate() in UDF
Posted by EdAk at 3/16/2004 3:26:07 PM
this question seems basic and trivial but i'm stumpe code snipped from UDF... declare @rtnval in set @rtnval = if @pm < getdate() set @rtnval = when attempting to create the UDF i get the following error "Invalid use of 'getdate' within a function why the only thing i want to do is t...more >>

Why Do I Get This Error
Posted by EdAk at 3/16/2004 3:01:08 PM
this seems like a very basic and trivial thing but, i could use some assistance code snippet within a function..... declare @rtnval in set @rtnval = if @pm < getdate() set @rtnval = when creating the function i get the following error. Why Invalid use of 'getdate' within a function ...more >>

how I combine two case statement into one under same heading
Posted by anonymous NO[at]SPAM discussions.microsoft.com at 3/16/2004 2:53:04 PM
this is how my syntax looks like: SELECT distinct(Field1) as Div, sum(case when dt between '08-Mar-2004' and '14-Mar-2004' then '1' else '0' end) as A, sum(case when when dt between '01-Mar-2004' and '31-Mar- 2004' then '1' else '0' end) as A from test group by Field1 output: DIV ...more >>

Oracle & SQL Server
Posted by Nils Magnus Englund at 3/16/2004 2:44:14 PM
Is it possible to create a view in SQL Server which incorporates tables from an Oracle database? It can be a ODBC connection, I don't care much about speed etc. Just is it possible? :) Any tips/suggestions/links to more information etc. would be great! Thanks. Sincerely, Nils Magnus Engl...more >>

Help with Blocking
Posted by John Faris at 3/16/2004 2:38:20 PM
Hi all. Forgive my ignorance here, but I haven't had to deal with this before. I recently encountered a process blocking two others and want to understand how it happenened so I can stop it happening again. I believe it was caused by a select statement in a trigger, but if so I would like to...more >>

xp_cmdshell path issue
Posted by David Potter at 3/16/2004 2:23:13 PM
Hello all, I am having a problem in a Stored Procedure that is using exec master..xp_cmdshell 'dir /b c:\temp\*' (this directory path does exist on my machine). When I executed this on the Query Analyzer (logged in under the sa login) I get: The system cannot find the file specified. NUL...more >>

Multiple unique constraints
Posted by Ron Langereis at 3/16/2004 2:06:56 PM
Hi, I'm looking for a way to check the results of multiple unique constraints in one action. Consider the following table: create table t1 ( f_id int identity(1,1) not null, f_code char(10) not null constraint code_unique UNIQUE, f_desc varchar(50) not null constraint desc_unique U...more >>

Join in a constraint
Posted by ploppy at 3/16/2004 1:57:16 PM
I'm wondering if there is a way to base a constraint on a condition in another table. For example: CREATE TABLE Orders ( OrderNumber int, RepID int ) CREATE TABLE Reps ( RepID int, CreditApproved char(1) CONSTRAINT CK_CreditApproved CHECK (CreditApproved = 'Y' OR CreditApproved = ...more >>

Check name
Posted by J. Hays at 3/16/2004 1:43:51 PM
Do CHECK constraint names have to be unique within the table or within the database?...more >>

Server does not exist or access denied
Posted by Buzby at 3/16/2004 1:24:21 PM
I have a bit of an issue with my usually excellent isp. I have 4 web sites all with an underlying sql db which have worked perfectly for 2 years until the sites were moved to new servers (Win2003), and sql was upgraded from SQL7 to SQL2000. One site mostly remains up (which holds the SQL accou...more >>

delete in blocks of 1000
Posted by chris at 3/16/2004 1:21:44 PM
I appreciate your guys ideas from earlier. But if I wanted to delete rows from a table in blocks of 1000 to avoid long locking/ deadlock issues, would this work for me? while (select count(*) from Table1 where ColumnDate > '2- 29-2004') > 0 begin set rowcount 1000 delete Table1 where C...more >>

using upper
Posted by Melounjan at 3/16/2004 1:12:36 PM
How do I go about updating a field with below value Amalio juan Alonso sebastian to this: Amalio Juan Alonso Sebastian Thanks.. -Melounjan ...more >>

SQL QUERY
Posted by Arvind P Rangan at 3/16/2004 1:08:04 PM
Hi, Can anyone tell me how to make sqlqueries case sensitive. let me give u a example. Suppose i want to check for name and last name in a table. I want check for name 'SuRaj' not 'suraj' and last name 'oak' not 'Oak' So if passed query is select * from emplist where name ='suraj' and las...more >>

Connecting Securely?
Posted by Richard Morey at 3/16/2004 1:03:34 PM
Hi, I have SQL Server 2000 running on one box and IIS running on another box. I am connecting to the SQL Server via ASP pages on the IIS box. My concern is security -- currently I am using this kind of code to connect: var setListings = Server.CreateObject("ADODB.Recordset")...more >>

Statistics....questions
Posted by Simon at 3/16/2004 12:57:36 PM
I have a query that will perform poorly from time to time. The query plan itself changes. The main culprit appears to be a column in my table called CHECKSW which is an integer with a default of zero and can only zero or one. It is not part of any index but is used in WHERE clauses. When...more >>

2000 Std. edition physical size limits?
Posted by Chris at 3/16/2004 12:56:09 PM
Are there any physical size limits on a DB using 2000 standard edtion? As there are on exchange 2000 standard editon (16 GIGS)...more >>

Optimizer not optimizing?
Posted by Hugo Kornelis at 3/16/2004 12:54:57 PM
I always try to write my code as portable as possible. Even though the queries I'm wirting are intended for a SQL Server 2000 environment, I always keep in mind that there might one day be a need to move to another platform. Therefore, I try to limit myself to using only ANSI-compliant queries. ...more >>

Errors when Syncronizing
Posted by Atley at 3/16/2004 12:49:09 PM
When I syncronize my tables, I get this error: Cannot insert duplicate key row in object 'POHFIL' with unique index 'IPOHFIL0'. (Source: CMTSQL2 (Data source); Error number: 2601) What do I do? the help was not much. I am trying to replicate tables between two SQL servers. Thanks for an...more >>

ANSI Vs MSSQL Join Style
Posted by MrBug at 3/16/2004 12:46:25 PM
Hi All, I have questions related to ANSI Join Style (See query 1.1 and 1.2) -What is the performance difference in ANSI Join Style and MSSQL Join Style? -How both join internally works? (See query 2.1 and 2.2) -What is the performance difference in ANSI Join Sty...more >>

Oh... no....
Posted by Utada P.W. SIU at 3/16/2004 12:30:09 PM
I am really need your help... How to pass a date with format "yyyy-mm-dd" to a stored procedure? I have tried many method 1. the data type of the date_variable in stored proc have been set to "DATETIME" using parameter object of ADODB.command to password a string with a type adDBTimeSta...more >>

FOR XML AUTO - Cutting off XML
Posted by Andrew Banks at 3/16/2004 12:26:14 PM
I'm using Classic ASP with SQL Server to read in XML data. If I return about 5 records everything seems fine but returning 10 records, the XML seems to cut off towards the end. Is this a problem people have come across before and if so how can I correct it? Code and sample output below AS...more >>

How To Handle User Defined Fields?
Posted by ANTHONY at 3/16/2004 12:21:17 PM
Greetings, I have received a request from my client where they'd like me to allow THEM to add their own fields on the fly, and have the column dynamically available for use right then and there. I've been developing for decades and I haven't quite heard of such a request but I am aware that...more >>

Monday and Sunday of current week
Posted by Edgard Riba at 3/16/2004 12:11:13 PM
How do I get the Monday and Sunday of the current week? Thanks, Edgard ...more >>

Start job from another server
Posted by Ray at 3/16/2004 12:06:10 PM
Hi all I like to know the syntax to start a job on server2 from within a job in server1 Thanks in advance Ray ...more >>

Table Structure Question
Posted by Dennis K. at 3/16/2004 11:46:36 AM
Which is the better structure if I have 100,000 parts? My users need to be able to change the description of the part type if need be. I have intentionally left out the part description and other part information for simplicity of this example. There will not be over 255 part types. If so ...more >>

Security by proc
Posted by Url Onz at 3/16/2004 11:35:16 AM
I have a table from which I want my users to get information that is applicable to them but nothing else. I just tried this on my test server. I denied my test user all permissions to the table. I wrote a proc that has one parameter that will limit the data selected to the data for that pe...more >>

not so random connection error... MDAC??
Posted by HernĂ¡n Castelo at 3/16/2004 10:59:04 AM
Hi i use sql2000 in win 2000 server with Mdac 2.8 i'm connecting with provider : sqloledb from Asp pages, thru ADO calling stored procedures the question is that time to time there is an error 800a01fb in : 1) set cmd.activeConnection= cnx either in 2) cmd.execute then, doing a SP_WHO ...more >>

How many records were updated?
Posted by bruce at 3/16/2004 10:58:42 AM
I have a procedure that update records if the values are different. Is there a function that I can use to find out how many records have been updated and store that number into a variable? Thanks, Bruce...more >>

Month Name
Posted by Jason at 3/16/2004 10:55:35 AM
Probably an easy solution but I can't seem to get it. I have numbers from 1 to 12. I would like to display the 3 character month abbreviation. I have tried DATENAME but it always returns Jan. Could anyone help?...more >>

Recurring events in a booking system
Posted by Nils Magnus Englund at 3/16/2004 10:45:18 AM
Hi all! I'm working on a meeting room booking system which, apart from the lack of recurring bookings, is almost complete. In addition to the user tables (which aren't really relevant for the query), I have two tables (somewhat simplified): rooms id (PK, integer) name (varchar(50)...more >>

Emptying the buffers
Posted by Jonathan Derbyshire at 3/16/2004 10:36:08 AM
Hi I'm working on a project to optimise the retrieval of data via Stored Procedures I intend to run a particalur SP 10 times in a row to calculate the mean running time However, i am aware that the SP will make use of the buffers after the initial execution I need to test the average time of...more >>

newbie silly question
Posted by djc at 3/16/2004 10:28:48 AM
I am new to real sql server stuff. I am coming from an access background. In access, I could easily export a query to a spreadsheet by right clicking on the query object and choosing export... or something along those lines. In SQL I have created a 'view'. How can I get that view into a spreadshe...more >>

bcp_exec and ASP
Posted by Dmitriy Shapiro at 3/16/2004 10:12:23 AM
Hi, For performance reasons we have a little weird architecture: ASP -> COM -> bcp_exec -> data file We have problem to make it work with the several concurrent users. The bcp_exec function return codes are FAIL, SUCCEED or SUCCEED_ASYNC In our case it fails with the return code -2147352567 If...more >>

Openrowset Accessing problem
Posted by Alex Wei at 3/16/2004 9:45:11 AM
I have two SQL server 2000 (sql_1 and sql_2). I try to use follwoing statement to access sql_2 in the program located in sql_1: SELECT * FROM OPENROWSET ('SQLOLEDB','sql_2';'uid';'pwd','SELECT * FROM svr2.dbo.users') But I alwat get error: SQL Server does not exist or access denied. Even ...more >>

Row Level Security
Posted by Jeff Dillon at 3/16/2004 9:44:50 AM
I've installed Microsoft Reporting Services, and we want to be able to give our clients the ability to create their own reports. Obviously we need to let them view only their own records. Currently we have an Accounts table, and users login via ASP Post where we match their username and password ...more >>

How to check a linekd server is available
Posted by Franck at 3/16/2004 9:43:31 AM
Hi evererybody, i have a question. I'm using sqlserver 2K. I have two servers (A and B). They are linked and would like to know how can i check from a SP stored on A that B is available ? Thanx. Franck. ...more >>

Shrink Logfile
Posted by rikesh at 3/16/2004 9:31:41 AM
I have a 44GB log file, any ideas how I can shrink the size? -- Kind Regards Rikesh (SQL2K-SP3/W2K-SP4) ...more >>

Language problem
Posted by simon at 3/16/2004 9:30:18 AM
I have collation setting of my database: Slovenian_cl_as Then in application I have settings of my connection: Locale Identifier=1060 ;Current Language=Slovenian; So, everything is set to Slovenian. And everything works fine just in one example when I call procedure e_olap_prenosPodatko...more >>

Prevent deletion or update of multiple rows
Posted by basistrdr NO[at]SPAM hotmail.com at 3/16/2004 9:20:08 AM
is it possible to create a login in MS SQL that will prevent users from UPDATE/DELETE multiple rows? i know i can restrict UPDATE/DELETE altogether, but my concern is preventing accidental deletion of multiple rows. i.e. DELETE FROM TABLE WHERE KEY=123 and we put WHERE KEY>123 my accident....more >>

Newbie question...
Posted by crowbird at 3/16/2004 8:51:07 AM
I'm using QA to write some queries, and I'm more comfortable with queries MS Access. In Access, I could create a query, save it, and use the results of the query in another query. Is there a similar way of doing this in QA or do I need to create a view in Enterprise Manager? (A subquery won't work...more >>

delete locking
Posted by chris at 3/16/2004 8:43:40 AM
sql2k sp3 Ive got a huge delete to do. (over 1 million records) delete table1 where DateColumn1 between ThisDate and ThatDate I want to use begin/ commit trans and go maybe 1000 rows at a time to avoid long locking/ deadlock issues. However I dont want to have to sit here all day a...more >>

security and stored procedures
Posted by toylet at 3/16/2004 8:18:21 AM
Using stored procedures to retrieve/update data would be more secured than enabling a user to do it. Truth? Myth? -- .~. Might, Courage, Vision. In Linux We Trust. / v \ http://www.linux-sxs.org /( _ )\ Linux 2.4.22-xfs ^ ^ 8:16am up 3 days 11:41 load average: 1.00 1....more >>

BCP utility Skips lines in import...
Posted by Timm at 3/16/2004 7:47:50 AM
--SQL Server 2000 I execute a BCP import from the command line, which works great.... I import 96 files but I notice that it skips a few lines at the BEGINNING of some files... thinking it was something in the file, I import a small group of files including the ones that had a problem, bu...more >>

sp_executesql with ntext variable
Posted by Patrick at 3/16/2004 7:38:26 AM
Hi, I,d like to know how to pass a ntext variable as the @statement parameter to sp_executesql since SQL does not allow to create a ntext local variable. Thanks!...more >>

Restore with a different database name
Posted by ggao NO[at]SPAM och.ca at 3/16/2004 7:14:19 AM
Hi all, I am a new SQL user. Here is my problem. On a SQL2000 server I do daily full backups. Now I would like to restore Dec 31, 2003 data to the same server but with a different name. I don't want to replace the current production data. I copied back the old backup file to a temp directory...more >>

Select Statement - Please Help
Posted by hngo01 at 3/16/2004 7:14:19 AM
Hi all, I have this DDL below: I need advice what's best way to do this!! Please look at my DDL and sample data. I believe that unique key is PtNumber and givenDt. I want to do following: 1- For each patient, by looking this raw data, I like to fill the UnitNumber Column by taking FIR...more >>

GETDATE() or CURRENT_DATE
Posted by Tim at 3/16/2004 6:41:07 AM
The more I learn, the more confused I get. Sometimes there are two ways to do things and I'm not sure whych is better. It might depend on the conext of usage. An example is GETDATE() and CURRENT_DATE. Which is better to use, the BOL say they do the same thing. Is one preferred over the other? ...more >>

Security - Please Help
Posted by Kostas at 3/16/2004 6:14:04 AM
Hello ALL, How to restrict the user, to access my DB only from my application. Any help will be appreciated, Thanks you. ...more >>

IF UPDATE (column) in a trigger
Posted by Anand at 3/16/2004 5:02:31 AM
Hi All, Example Trigger with IF UPDATE: IF UPDATE(prorate_type) BEGIN UPDATE table1 SET prorate_type = 0 FROM inserted i JOIN dbo.table1 c ON c.objid = i.objid END Example Trigger without IF UPDATE: BEGIN UPDATE table1 ...more >>

space used for each row
Posted by JB at 3/16/2004 1:31:11 AM
Hi how is it possible to return the sapce used for each row, considering each row has a text datatype column plus others. What I am aiming to do is see the intermediate report size for each report in reporting services TIA JB...more >>

BCP Nightly Extracts
Posted by bkc98 NO[at]SPAM excite.com at 3/16/2004 1:23:46 AM
Hello all, I have currently existing code that exports my entire SQL Server 2000 application database to many extract files each night. The process is made up of a series of custom DTS packages that splits up the extracts by table. The tables that are too large for one file are split up by id...more >>

Grant EXEC on Stored Procedure
Posted by gtaz21 at 3/16/2004 1:05:43 AM
Using T-SQL how can I grant EXEC permissions to a user in the same database? Is there a system stored procedure that will do this? GTaz21 *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!...more >>

How to register sql server database on web site?
Posted by Luqman at 3/16/2004 12:47:53 AM
I have just got my company domain and I would like to register sql server database on my domain to my enterprise manager on my laptop, my domain name is: www.pearlsoft.com.pk. How can I register the database whose name is : pearlsoft Best Regards, Luqman ...more >>


DevelopmentNow Blog