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 > december 2005 > threads for thursday december 22

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

Create Table
Posted by TAHA at 12/22/2005 9:43:58 PM
Hi All how can I Create Table (COPY STRUCTURE TO TableName Only ) From Another Table In The Same Database Thanks ...more >>


Finding user tables in database
Posted by Mana at 12/22/2005 8:12:12 PM
Hi, I am using SQL Server 2005.I need to find out all the user tables in a database. For this purpose I have written following query. NSBank is the name of the database. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USE NSBank; select name, type_desc from sys.objects where type='u'; ~~~~~~~~~~...more >>

restore data file only
Posted by Datasort at 12/22/2005 7:47:02 PM
I am trying to restore a data file and not the log file. Acutally, the log file will max out my drive space so i am trying to create a new db from a backup without the log file. Any thoughts? Thanks in advance, -- Stewart Rogers DataSort Software, L.C....more >>

auto increatment
Posted by calvin at 12/22/2005 7:39:29 PM
how can i do that in mssql ? e.g. existing data Column 1, Column 2 A 001 B 001 B 002 C 001 then Column 1 and Column 2 are primary key. how can i set the column propertis for column 2 such that i can get auto-number B003 while ...more >>

getdate() rounded when runned in a job.
Posted by Geir Holme at 12/22/2005 5:50:44 PM
Hi all. I am confusing on this matter so if anyone recognize this please let me know. Simple scenario. I am using getdate() to fill datetime into a column in a table. All within a prosedure. Create a tmp table with datetime column. Insert getdate() Insert the temptable into a physical ...more >>

Stored Procedure Advantages
Posted by David at 12/22/2005 5:04:02 PM
All Can anyone advise me the performance advantages of using Stored Procedures vs. a normal SQL statement. Thanks...more >>

Index Help
Posted by Ed at 12/22/2005 4:37:02 PM
Hi, Can any please explain to me the diff.? Use Northwind I created a Non-Clustered index on "LastName' and "FirstName" (Combined) Select * from customers where LastName = 'Hello' and FirstName = 'World' Select * from customers where FirstName = 'World' and LastName = 'Hello' Does that mak...more >>

newbie tsql/column def'n: default values - SQL Server 2005
Posted by Chris Smith at 12/22/2005 4:24:06 PM
I have a table that has phone numbers, and a phone-type column. The phone type is foreign-keyed into a phone type table, and the phone-types in both tables are integers. I want to change this to use the new UniqueValues data type. In Management Studio I can create the new column easy enoug...more >>



enumerating sql servers in sql server 2005
Posted by Brian Henry at 12/22/2005 3:50:19 PM
Is there anyway new in SQL Server 2005 to enumerate all the servers on the network without sqldmo? I'm working in .NET and want to get the list, im doing it now in sqldmo and it works fine, but would like to do it with managed code instead of using a com object... ...more >>

Finding the right record 2
Posted by John Baima at 12/22/2005 2:24:00 PM
Okay, I can restate this in a more simple way. If I have a table like: EmpSSN EmpID LastTimeIn 001624633 13864 01/28/05 020489644 2897 01/28/05 020489644 3582 12/13/05 041468792 3507 04/05/05 041468792 3614 06/24/05 057627194 3150 06/21/05 057627194 3694 09/20/05 057627194 4081 12/21/05 05...more >>

Is this possible?
Posted by Confused at 12/22/2005 1:45:13 PM
I have a stored procedure and I want to do something like: INSERT INTO @Table (Field1, Field2, Field3, ....FieldN) SELECT sum(a) AS Field1, sum(b) AS Field2, sum(c) AS Field3 FROM @Table2 WHERE n is null SELECT sum(a) AS Field4, sum(b) AS Field5, sum(c) AS Field6 FROM @Table2 WHERE x <...more >>

compare varchar column values case-sensitively?
Posted by n_o_s_p_a__m NO[at]SPAM mail.com at 12/22/2005 1:36:29 PM
Is it possible to case-sensitively compare 2 varchar column values without changing the collation on the column to case-sensitive? For example, I have column called Note on a table called Operation, and I'd like to select distinct note, case-sensitively, without changing the collation. Possibl...more >>

Why query optimizer does not select the index?
Posted by Vagif Abilov at 12/22/2005 1:32:51 PM
Hello, I have a table with a couple of non-clustered indexes. One of them is a single-column index on a time column. The table has several hundred thousands records, so when I search for data within certain time range, I expect the index to be used. However, SQL optimized only selects the i...more >>

ORDER BY question
Posted by yodarules at 12/22/2005 1:20:03 PM
I'm having some issuses with ORDER BY with my query. I'm trying to run the same query in Oracle and SQL Server. select a.APP_ID, a.USER_ID, SUM(a.CB) AS "CB", SUM(a.SB) AS "SB", SUM(a.CA) AS "CA", SUM(a.SA) AS "SA" FROM APP_USER a WHERE a.START_TIME >= 1135044000000 AND a.START_TIME < 1135...more >>

Non-Deterministic function in DPV
Posted by alw at 12/22/2005 12:49:01 PM
Hi! Using the new SQL 2005 functionality where the optimizer determines where the data is based on the check constraints defined on the tables, can you use a non-deterministic function such as getdate() in the check constraints as long as you have another mechanism to make certain the data ...more >>

reorganize data files
Posted by Gordon Cowie at 12/22/2005 12:30:21 PM
Just added a new datafile to my database. How do I distribute all the data evenly across the two files now? I tried dbcc dbreindex on all tables, this results in 75%/25% I also tried creating 2 new files and emptying the main file dbcc shrinkdb. I could not empty the main file completely tho...more >>

bizarre query problem
Posted by John 3:16 at 12/22/2005 12:02:27 PM
Below is part of a stored proc. This code returns an error ONLY if Field.OrderId is included in the query. It runs ok if the OrderID is not included. The error recieved is: Server: Msg 512, Level 16, State 1, Procedure Jobs_TrackInserts, Line 18 Subquery returned more than 1 value. This is no...more >>

Help with query
Posted by ViLo at 12/22/2005 11:35:54 AM
Hi all, I have the following table: CREATE TABLE [dbo].[Company]( [CompanyID] [int] IDENTITY(1,1) NOT NULL, [CompanyName] [varchar](100) NOT NULL, [CompanyTypeID] [int] NOT NULL, [Active] [bit] NOT NULL) These companies can have a variety of CompanyType...more >>

How do I use a UserDefinedFunction in a View?
Posted by James at 12/22/2005 11:12:29 AM
I have a UDF that takes one single INT parameter and returns a Table like So:: CREATE PROCEDURE dbo.TestUDF ( @aParam int ) AS BEGIN CREATE TABLE #TestTempTable ( a INT PRIMARY KEY, b INT, c INT ) INSERT INTO #TestTempTable VALUES ( 1, 2, 3 ) INSERT INTO ...more >>

alternate to "NOT IN " query
Posted by Vikram at 12/22/2005 10:49:23 AM
any better way of writing this Select serialnumber from tbl_test2 where serialnumber not in (select serialnumber from tbl_test) and exportedflag=0 ...more >>

append property value
Posted by Vikram at 12/22/2005 10:34:26 AM
i am using sp_OASetProperty for setting property value for a cdo.message object. But it might happen body size is more than 8000 character... in that case i want to write follwoing statement in a loop ...more >>

Popuate field with value from last row
Posted by rmg66 at 12/22/2005 10:20:31 AM
Does anyone know how -- during an insert -- to automatically populate a field with the same data as the field in the last inserted row? Thanks. ...more >>

Dynamic table and column list
Posted by StvJston at 12/22/2005 10:15:03 AM
Thanks in advance (even CELKO) DDL attached I DID NOT create this application. I am trying to fix it. The application recieves a Access database table once a month. This table contains employees and multiple columns detailing begining and ending balances, pay amounts etc... The tables co...more >>

DBTYPE_DBTIMESTAMP OLE DB question
Posted by dermite at 12/22/2005 9:42:01 AM
Folks, I am trying to use ole db to read a date field created as a DATETIME in C#. It only seems to work if I set the binding type (wType) to DBTYPE_DBTIMESTAMP. When I do this, 16 bytes of data are written to my buffer. The question then is what to do with this raw data. What should I ca...more >>

SET XACT_ABORT: what the f***k
Posted by kevin at 12/22/2005 9:38:02 AM
I got this error, for the first time today: System.Data.SqlClient.SqlException: Unable to start a nested transaction for OLE DB provider 'SQLOLEDB'. A nested transaction was required because the XACT_ABORT option was set to OFF. [OLE/DB provider returned message: Cannot start more transacti...more >>

connections remote SQLExpress
Posted by EWAT at 12/22/2005 9:31:49 AM
how I can connect remotely to SQLExpress?.. I have enabled TCP/IP, but it does not work. error: ..... When connecting to SQL server 2005m this failure may be caused by the fact the under the default settings SQL server does not allow remote connections (provider SQL Network Inter...more >>

Help with writing Triggers
Posted by Jim Abel at 12/22/2005 9:26:02 AM
I have no experience with Triggers and need help to create 2. My goal is to generate the average and Stard Devation for 2 values when they are inserted or updated. In the first field I insert a count that I need to calculate the mean and StdDev based on the values of the past 30 days. The...more >>

64-bit SQL
Posted by MAS at 12/22/2005 9:19:13 AM
I have run into an interesting problem. I have some code that adds a column to an existing table. The column is set as primary key, identity and clustered. On the 32-bit version of SQL Server 2005 it works fine. It fails on the 64-bit version of SQL Server 2005 intermittently with a "could...more >>

Result set from stored procedure
Posted by Confused at 12/22/2005 9:09:29 AM
This is probably stupid, but can I have 3 selects in my stored procedure and get the results back from all of them? I have a set of data and I need to get 3 sets of totals based on different criteria. I've declared my tables, inserted/updated the data in the tables and then have my 3 selects....more >>

Case Statement Really Urgent Please
Posted by marcmc at 12/22/2005 8:53:03 AM
Why will this case statement not work? It checks the length of a char field TRAN_TIME and pads it accordingly. SELECT a.TRAN_TIME FROM QUINN_ST..get_bcp_h_cvcmis a(nolock), QUINN_CT..Rec_Pol_WH b(nolock) WHERE a.POLICY_CODE = b.Policy_desc AND a.TRAN_DT >= '20051221' AND (CASE len(a.TRAN_...more >>

Matching Transactions and Duplicates
Posted by downintheflood NO[at]SPAM yahoo.com at 12/22/2005 8:50:42 AM
Can anyone suggest a good approach to this problem? I need to match transactions from two tables on several columns. When I have a match, I need to set a match flag and a match number in each table. There can be duplicate transactions in either table. If I have two transactions in one table...more >>

Procedure or function has too many arguments specified.
Posted by tomm at 12/22/2005 8:35:58 AM
I've seen others have had trouble with this. Using vs2005 connecting to sql2000, procedure works from command object with parameters but doesn't from a datasource defined on the page. I've tried any number of variations to get it to work, uses a session parameter and three control parameters fro...more >>

Fiscal Month Date Range: 22 thru 21
Posted by JDP NO[at]SPAM Work at 12/22/2005 8:13:07 AM
I'm looking for a script to do the following? I need to have a date range for each month of the year from the 22nd of each month to the 21st of the next. This doesn't work... as it starts at the first, I need it to start at the 22 of the previous month. declare @date datetime set @date =...more >>

Need help with Month / Year Query
Posted by Gomi at 12/22/2005 7:57:05 AM
I have a table with order dates for the past few years. I am trying to write a query that just ives me a distinct month/year for all the orders so that I can do my reports monthly. I have been wracking my brains over this one for the past few days and just can't seem to get it. Basically what...more >>

Need help obtaining query_plan from T-SQL statement (SQL Server 20
Posted by Mike at 12/22/2005 7:41:02 AM
Could some please help me in obtaining the query plan by modifying the T-SQL statement below? Thank you. select top 50 sum(qs.total_worker_time) as total_cpu_time, sum(qs.execution_count) as total_execution_count, count(*) as number_of_statements, qs.plan_handle from...more >>

COnvert
Posted by Phil at 12/22/2005 12:47:01 AM
Hi All, I posted this query a coupe of days ago and had a few repiies but I have only just got around to trying them out, I was trying to convert a nvarchar values of 01112005 which this time I will explain is meant to be the !st of November 2005, this is something that I forgot to mention ...more >>

Finding the right record
Posted by John Baima at 12/22/2005 12:19:11 AM
My brain is not working right now and I need some help. I have two tables Employee EmpID varchar(10) (primary key, unique values) EmpSSN varchar(9) And TimeSheet EmpID varchar(10) (foreign key to employee EmpID) TimeIn datetime The problem is that we have multiple Employees with ...more >>


DevelopmentNow Blog