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 2007

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

Pivot query problems - Sum by Row type
Posted by morleyc NO[at]SPAM gmail.com at 8/31/2007 11:31:18 PM
Hi, i am trying to get a pivot/crosstab query working but i am having a hard time working out what im doing wrong. I have googled for a number of samples for use with my database but i cant apply to my scenario so i would appreciate some guidance. I have an employee's table, and an AsencesTabl...more >>


Scripting Extended Properties
Posted by Mark Assousa at 8/31/2007 7:34:41 PM
I am running on SQL Server 2000 SP4. I am attempting to generate SQL Script and include extended properties. When doing so, the extended properties for one table (i.e. Column Description) are not generated. Extended properties for all other tables script just fine. I've even gone so far a...more >>

SSIS on SQL 2000 to SQL 2000 ?
Posted by at 8/31/2007 5:09:14 PM
Can SSIS moving data from one SQL 2000 db to another SQL 2000 db? If so, can anyone tell me what i need to do this? Execute SQL Task ? Data Flow Task ? OLE DB Source ? OLE DB Destination? It's a little confusing even after reading for a day. Any examples great appreciate and will award ...more >>

SQL Select
Posted by brandon at 8/31/2007 4:58:56 PM
I have following tables: 1. Registration with RegistrationId, Name 2. EventMeal with MealId, MealFee 3. RegistrationMeal with RegistrationId, MealId, MealQuantity (this can have more than one row for same RegistrationId) 4. EventSession with SessionId, SessionFee 5. RegistrationSession with Re...more >>

Calculate time intervals
Posted by Mark Goldin at 8/31/2007 4:17:54 PM
I have data as following: create table #test (jobcategory int, startsusptime datetime, endsusptime datetime) nsert into #test values (1, '2007-05-03 14:12:39.033', '2007-05-04 06 insert into #test values (2, '2007-05-03 14:19:26.547', '2007-05-03 14:21:53.890') insert into #test values ...more >>

How can I find out the size of a database?
Posted by PSULionRP at 8/31/2007 12:42:02 PM
How can I find out the size of our SQL Server Database??? Any help would be greatly appreciated. Thanks in advance for your help. PSULionRP...more >>

query
Posted by bobby at 8/31/2007 12:42:01 PM
The following gives me the error u.username is invalid in seklect list because it is not contained in either an aggregate function or the group by clause SELECT u.Username, u.Email, ar.RoleName, uc.LastActivityDtm, COUNT(t_Proxy.ProxyUserID) AS Expr1 FROM t_Roles AS uar INNER JOIN ...more >>

History question: when did the sp_oa_* procs get introduced?
Posted by KJ at 8/31/2007 12:41:47 PM
I'm doing a bit of research for a short posting on the sp_oa_* procedures, used to handle COM objects in SQL Server. Can anyone provide the history of these, including in which version of SQL Server they made there first appearance? Thanks in advance, KJ ...more >>



calling a function
Posted by seema at 8/31/2007 12:16:03 PM
how can i call a function from a stored procedure...more >>

Combine rows in single row
Posted by seema at 8/31/2007 11:44:01 AM
I have a table username Roles Seema Admin Seema AppAdmin Seema Testing Bobby Manager Bobby Admin I want a query so that i can get something like seema Admin, AppAdmin, Testing Bobby Manager, Admin...more >>

rebuild Index
Posted by at 8/31/2007 10:12:33 AM
I want to rebuild index on all the tables on my database with the exception of 7 tables. how can I do that? Thanks ...more >>

Best Practices
Posted by Mike DeYoung at 8/31/2007 9:14:02 AM
I have a small client who wants to consolidate Terminal Services and SQL Server on the same box to save money. I have never been a proponent of this but I also can't find a Microsoft best practice that addresses this. Has anybody seen a Microsoft blessed best practice on this? Do you know w...more >>

grouping records into half hour slots
Posted by VJB at 8/31/2007 8:25:45 AM
Hi, I have 2 tables: one with real time data, and another is lookup Table Data col1 date col2 amount table lookup col1 identity col col2 slot col3 alias col4 start_time sample of table data dt amount 2007-08-06 00:01:00.000 0 2007-08-06 00:01:23.000 0 2007-08-06 00:02...more >>

INSERT trigger doing the wrong thing on multiple insert
Posted by francis.moore NO[at]SPAM gmail.com at 8/31/2007 8:06:16 AM
Hi, I posted some trigger code yesterday that somebody was kind enough to fix, but further testing has thrown up another problem with the code. What I want to do is add a subnet into Table B for every IP that gets inserted into Table A, if that subnet does not already exist. If I add an IP ...more >>

YOU MUST KNOW THIS MAN
Posted by abdo911 at 8/31/2007 7:27:09 AM
Allow me to share with you here some information about one man his name is muhammad. In The Name Of Allaah, Most Gracious, Most Merciful YOU MUST KNOW THIS MAN MUHAMMAD (May peace and blessings of God Almighty be upon him) You may be an atheist or an agnostic; or you may belong to anyon...more >>

CrossTab Query Question
Posted by PeterNEA NO[at]SPAM gmail.com at 8/31/2007 6:44:22 AM
Hi, I have a SQL table that has data like this: Title Month Info 1 ---- 7 ---- 100 1 ---- 7 ---- 100 1 ---- 8 ---- 200 1 ---- 8 ---- 250 2 ---- 7 ---- 150 2 ---- 7 ---- 150 2 ---- 8 ---- 300 2 ---- 8 ---- 300 3 ---- 7 ---- 250 3 ---- 7 ---- 250 3 ---- 8 ---- 100 3 ---- 8 ---- 200 ...more >>

Debugging SQL
Posted by Doogie at 8/31/2007 6:26:42 AM
Hi, I'm sure this is probably a silly question, but I'll ask anyhow. I'm trying to debug a large proc (sigh) and am putting print statements in it to do so. Working fine, but everytime it does a update or insert it prints out the rows affected as well, like the example below. This adds a lot o...more >>

Combine Query results side-by-side as one query
Posted by morleyc NO[at]SPAM gmail.com at 8/31/2007 6:21:29 AM
Hi, i have two queries with the following data: Hours worked query: EmployeeID_FK HoursWorked OvertimeHours Absences query: EmployeeID_FK SickTaken HolidayTaken They are independant calculated columns (from hours worked table and absences table), however the EmployeeID_FK is como...more >>

Fetching records - Cursor or not?
Posted by Harish Mohanbabu at 8/31/2007 6:18:03 AM
Hi, I have two tables - Table1 and Table2. Table 1 contains dates and Table 2 contains records. I need to get first two records from Table1. And in table 2 I need to get all records falling within those two dates in Table1. After that I need to move to next two records in Table1 until ...more >>

Select latest entries
Posted by billy.watt NO[at]SPAM nov.com at 8/31/2007 6:01:26 AM
I require a query from a login audit table that will select the latest entry only for each user. The data I want to see consists of three fields: 1. username 2. login_date 3. login_time I can get as far as creating a temporary table with the entries sorted by username, login_date (descendin...more >>

out of time
Posted by Hans - DiaGraphIT - at 8/31/2007 2:50:01 AM
Hi! what am I doing wrong. declare @val1 int set @val1 = cast (count (Select * From table1 where col1 is not null) as int) update table2 set mycol = Case @val1 = 0 then 3 else case @val1 > 2 then 1 else 0 end where mycol is null ...more >>

SQL Server 2000 Lock question
Posted by Jason Huang at 8/31/2007 12:00:00 AM
Hi, In my application, I have some SQL like SELECT Max(No) FROM Prod My app coding logic is if the max no is now 1000, then the new No for the inserting Prod will be added 1, namely 1001. Now comes the situation, if many users are inserting the Prod and the concurrent connection is als...more >>

How to improve this query
Posted by Faye at 8/31/2007 12:00:00 AM
This query works beautifully. What I want to do is, select the SURV_YY_DT available in the table and sum without having to hard code each year. SELECT ABA_NR , SUM(CASE YEAR(SURV_YY_DT) WHEN 2006 THEN 1 ELSE 0 END) AS c2006, SUM(CASE YEAR(SURV_YY_DT) WHEN 2005 THEN 1 ELSE 0...more >>

Schema XML on column
Posted by Franck at 8/31/2007 12:00:00 AM
Hello I would like to know on the xml column if there is a schema associated. What query must i use ? Franck ...more >>

IN / AND differences curiosity
Posted by luna at 8/31/2007 12:00:00 AM
Just playing around and i came across the IN function eg select name from table where name in('smith',jones') or you could just select name from table where name='smith' or name='jones' they both do the same thing, only issue i found was you cant seem to use wildcards unless you do a sub...more >>

Transaction failure when remoting
Posted by Johan Karlsson at 8/31/2007 12:00:00 AM
Hi! I have an application where the client call the server over .net remoting (tcp). The application has three parts (Database on server A) -> (BI Services on server B) -> (Testclient on server B) The final code to be called looks something like this: Public Sub Update() Usin...more >>

Refresh Views
Posted by JCP at 8/30/2007 11:48:02 PM
I'm using the store procedure below to drop and recreate all my views. It works fine if the string is <=4000 char. I tried to change data type for @text parameter from nvarchar(4000) to varchar(8000) but the error still occur. Question. How can I do to refresh (drop and re-recreate) all view...more >>

using references on sql server
Posted by Roy Goldhammer at 8/30/2007 6:18:33 PM
Hello there On the place i work with they always used references in all the database for better checking, design ect.. Now when they need to load huge amount of data the reference has slow the performance in 50%. It is obvieous because when the sql check valid data it reduces performance...more >>

need help with deleting duplicate rows
Posted by mitra at 8/30/2007 4:38:04 PM
Hi All, I am trying to delete rows with duplicate values in the 'nId_mail' column of a table and keep at least one of each nId_mail. I have tried several delete statements posted on this website but none worked for me... not sure why! When I group the columns, I don't get any rows with havi...more >>

STATS_DATE is NULL
Posted by Jay at 8/30/2007 3:23:05 PM
I need to get the STATS_DATE on all indexes in the database, table by table. The procedure is being created in the [master] database and it returns correct information for tables in [master]. However, it returns NULL as the STATS_DATE for all other databases. When I switch the database cont...more >>

Will a Blocking incident resolve with time?
Posted by John Kotuby at 8/30/2007 2:34:14 PM
I was thinking of removing the ADO command timeout values in a VB Application that uses SQL Server 2000 Standard as the backend. Users have complained about timeouts making their life difficult. I have watched the server and noticed very occasional blocking (once or twice a month) during hea...more >>

Deleting a trigger
Posted by dkroll NO[at]SPAM commercialtax.com at 8/30/2007 2:00:14 PM
Using SQL Server 2000. I have a trigger (update,insert) that copies the current record to a change log table. I want to delete the trigger, but when I try to do that, Enterprise Manager hangs up and I have to end the process. Do I have to take the database offline before I do this? I've even...more >>

how to exclude the seconds and millisecs from a date argument?
Posted by Rich at 8/30/2007 1:54:01 PM
I have to pull sets of data (users of my client application will pull sets of data) from a table where the different sets are distinguished by a data column. Example: one set containing 2100 rows were inserted on 2007-08-29 14:03:06.887 another set was inserted on 2007-08-29 13:45:37...more >>

best book on performance tuning
Posted by John Grandy at 8/30/2007 11:38:01 AM
Any suggestions for best book on performance tuning ... ...more >>

What is meant when someone refers to a SQL Server "Instance"???
Posted by PSULionRP at 8/30/2007 10:18:03 AM
What is meant when someone refers to a SQL Server Instance??? Does that refer to a SQL Server??? I'm pretty sure it's not a Database. Does it refer to a SQL Server within a bigger server??? For instance...we have a SQL Server called DEV and then within that we have WEB, APP, and REPORTS.....more >>

Returning the Nth partition of a result set
Posted by dalton at 8/30/2007 10:12:03 AM
I am trying to select a set of records into an XML result. To do this I have the following query: SELECT [CODE] '@a',[DESC] '@b',[RATE] '@c',[ALT_CODE] '@d', [CHANGE_DATE] '@e',[CHANGED_BY] '@f',[EXTRA_ASC_1] '@g',[EXTRA_ASC_2] '@h',[EXTRA_ASC_3] '@i', [EXTRA_ASC_4] '@j',[EXTRA_NUM_1] '@k',[...more >>

forming a string with dateparts
Posted by rgintexas at 8/30/2007 8:33:22 AM
I want to create a string using the week number and year of a date. For instance, if i have a date of 1/3/2007, which would be week 1 of 2007, i want to create a string that says 'Wk1-2007'. i know it's basically 'WK' + CAST(DATEPART(WK,'1/3/2007') AS VARCHAR) + '-' +CAST(DATEPART(YEAR,'1/3/200...more >>

Using MS-Access as a report writer
Posted by JimP at 8/30/2007 7:44:37 AM
Is there any literature/documentation about "best practices" when using MS-Access with SQL Server? ...more >>

if in check constraint
Posted by HDI at 8/30/2007 7:22:07 AM
Hi, Is it possible to use a if or iif in a check constraint or should I use a UDF? Thx ...more >>

hierarchy sql queries
Posted by agarwal.libra NO[at]SPAM gmail.com at 8/30/2007 5:57:25 AM
i have a problem in sql. there is table of employee in which one column is empid and another is manager_id. and one wants to go to the hierarchy that is emp->manager->manager- >...->root. so how to find that one? ...more >>

Application Security Question
Posted by Tim Morrison at 8/30/2007 5:30:58 AM
MSDE, SQL Express When my customers install our software, i would like them to go thru a "registration" process, that, in part, will create a record in a single record table that identifies the computer that database is installed on. Then when the workstations first login to the database, ...more >>

Help with 'Distinct'
Posted by Harish Mohanbabu at 8/30/2007 4:32:03 AM
I have this requirement to pick up the last record based on date and time. For example here are some sample records - 701,1,2007-08-03 00:00:00, 1899-12-30 15:28.000 701,1,2007-08-03 00:00:00, 1899-12-30 21:28.000 701,1,2007-08-04 00:00:00, 1899-12-30 21:28.000 701,1,2007-08-04 00:00:00, 189...more >>

Trigger failing on multiple INSERTS
Posted by francis.moore NO[at]SPAM gmail.com at 8/30/2007 3:44:22 AM
Hi, I've written a trigger that inserts data into Table B if it doesn't already exist in Table B when data is inserted in Table A. The trigger works perfectly for single inserts, but seems not to work at all for multiple inserts. The data is still inserted into Table A, but the trigger does...more >>

strange problem with sp_executesql and like
Posted by Sergei Shelukhin at 8/30/2007 1:30:38 AM
Hi. We are having a weird performance issue with a query launched thru SqlDataAdapter from C#. Data adapter executes parametrized queries using sp_executesql, and the query that is concerned is pretty complex and uses a LIKE clause like this Blah LIKE '%' + @Name + '%'. When we launch the ...more >>

Comment on SQL Report Builder
Posted by sam at 8/30/2007 12:24:08 AM
Is anyone using this tool to generate reports? General Comments on usage? TIA Sam ...more >>

SQL Connetion from Pocket PC2003 to SQL2000-SP4 Arabic Coallation
Posted by Peer-Prologic First at 8/30/2007 12:08:01 AM
Dear All Please help in this ,it is very crtical and very urgent.I am using SQL Client in Vb.net Compact Framework 2.0 to connect SQL Server 2000.It is working fine with English collation (SQL_LATIN1_General) but same code gives error with Arabic collation. Error was Plattform not supported ...more >>

correlating spid to objectid
Posted by Neo at 8/30/2007 12:00:00 AM
does anyone knows if theres a way to correlate session to the objects it uses? ...more >>

Insert Into Select query - Why slow?
Posted by Chris at 8/30/2007 12:00:00 AM
I was wondering if someone can explain the following. I am trying to optimise a query and can't figure out why SQL Server is behaving is a particular way. To begin with I am calling two DBCC statements to make sure i've no cache. In the example below I am doing a simple EXISTS check. If ...more >>

Execute permission of sp
Posted by Rotsey at 8/30/2007 12:00:00 AM
Hi, I have a .Net 2.0 windows app that connects to a SQL Express DB. I have 2 Clients using it fine. It accesses stored procs to update data. The clients use integrated security. data source='SQLSERVER\SQLEXPRESS';initial catalog=tbrPData;integrated security=SSPI The problem is on ...more >>

querying distinct records based on date time
Posted by sony.m.2007 NO[at]SPAM googlemail.com at 8/30/2007 12:00:00 AM
Hi, I have a table with following data Tablename:test Pr dt vs_val 11 2007-08-30 12:57:12.143 1 11 2005-06-11 00:00:00.000 2 12 2005-06-11 00:00:00.000 2 14 2005-06-11 00:00:00.000 2 11 2007-08-30 13:24:42.600 1 11 2005-06-11 00:00:00.000 2 15 2005-06-11 00:00:00.000 ...more >>


DevelopmentNow Blog