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 > september 2007 > threads for tuesday september 25

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

Join Question
Posted by tshad at 9/25/2007 5:59:16 PM
I am looking at joins and was curious about why this is happening. I have 2 RIGHT Joins but only the last one seems to be happening. If I have the following: SELECT e.EmployeeID,e.EmployeeName,Department.DepartmentName,o.Name,s.Name FROM Employee e LEFT JOIN Department ON e.DepartmentID =...more >>

Need help with query
Posted by Sandy at 9/25/2007 5:34:00 PM
Hello - I have a table as follows: tblLoans LoanID PK DateEntered FileNumber LoanType etc. And another as follows: tblBorrowers BorrowerID PK BorrowerLast BorrowerFirst etc. LoanID FK These tables have a one to many relationship with tb...more >>

dynamic column name
Posted by luna at 9/25/2007 5:01:06 PM
can you use something like ? declare @column varchar(75) select @column=('column1') select * from table where @column='mytestdata' I understand you can do it dynamicaly by building a sql query but was just wondering if this way can be used cheers mark ...more >>

Having issues on and off with this page
Posted by Daniel at 9/25/2007 4:53:20 PM
Here is what i have ( just an overview ) Table: CREATE TABLE [dbo].[EmpHis]( [cid] [int] NOT NULL, [qhiscomp1] [varchar](50) NULL, [qhiscompc1] [varchar](50) NULL, [qhisrespon1] [varchar](255) NULL Procedure: ALTER PROCEDURE [dbo].[emp_insert_his] @cssn varchar(9), @qhiscomp1 ...more >>

SQL Server and delay writes
Posted by chaynes01 NO[at]SPAM sbcglobal.net at 9/25/2007 3:59:46 PM
I hope someone can explain this to me, as I am stumped. I am not a SQL Server master by any means, so I hope this is a simple fix. We are using SQL2005 Enterprise, Win 2003 server and the server is only running this database. The client app is a VB.Net 2005 using SQLClient for db interface. ...more >>

"USE" command with SQL Server Express
Posted by Bob Bartel at 9/25/2007 3:39:18 PM
SQL Server Express allows you to "attach" directly to a database file using the AttachDBFilename property in the connection builder. When the file is connected, it can be seen in the Server Management Studio like the following: C:\myfolder\mydatabase.mdf Here's my challenge. We query m...more >>

SQL Server not liking where clause
Posted by ChuckW at 9/25/2007 2:50:00 PM
Hi, I am converting from Access to SQL Server. I have the following where clause which worked fine in Access but does not work in SQL Server. I identified the statement ((Customer.IsActive)=-1) as being the problem. If I remove this I get results which includes records where the IsActive f...more >>

SQL syntax problem
Posted by ChuckW at 9/25/2007 2:34:23 PM
Hello, I am moving my database from Access to SQL Server. I have a query which is listed below. The date restrictor worked in Access but is not working in SQL server. It returns zero results for no error message. When I remove the date restrictor I get results. It ran fine in Access as...more >>



Index Defrag - Clustered vs Non-Clustered
Posted by Dragon at 9/25/2007 2:29:02 PM
Hello Everyone, I have a quick question. If I have a job that defrags Clustered indexes on a nightly basis, does it help with non-clustered indexes at all? I am getting conflicting information regarding this. Some say, no, non-clustered index will remain in previous condition (fragmented if...more >>

lock question
Posted by is_vlb50 NO[at]SPAM hotmail.com at 9/25/2007 1:04:47 PM
I need help with next problem: Exist table my_rows with next columns: id - int identity name - varchar is_locked - bit I need create store procedure which will return every time diferent row for every request from different processes. the pseudo code for the procedure : 1 select statem...more >>

default value question and temporary tables
Posted by R C at 9/25/2007 12:38:04 PM
hi, i have the following query: CREATE TABLE #Prod ( filtItemID varchar(30), sortIndex int default 0 ) insert into #prod select 'abc123' it doesn't work. how can i get this to work without specifying the sortIndex field in the insert statement?...more >>

Which is better DISTINCT or GROUP BY performance
Posted by Derekman at 9/25/2007 12:18:04 PM
When attempting to get a distinct value is there a difference in performace between using DISTINCT or GROUP BY? I have looked at the execution plan for using DISTINCT OR GROUP BY in the below statements and they are identical. Am I missing something? USE [AdventureWorks] SELECT DI...more >>

recovering from Select expression error?
Posted by ChrisA at 9/25/2007 11:54:06 AM
Hi. I have a select that includes: "Select ... Cast( Cast( MyDate as Char(8)) as dateTime) , ..." where MyDate is a char(8) YYYYMMDD thing. The data, which I don't control, has values for MyDate that don't convert, and I get "Syntax error converting datetime from character string." ...more >>

Passing Part of an SQL-Statement to a Stored Procedure
Posted by Karl at 9/25/2007 11:23:56 AM
Hello, I created a stored procedure using dynamic SQL to find records in different Tables. A part of the procedure is created by the Code of my Application and sent to the procedure as a parameter. This is the string given to the parameter: ' WHERE dbo.tbl_Kd.txtKdBGNr = N'MyValue''. The Prob...more >>

SQL syntax error
Posted by s.s.chary NO[at]SPAM gmail.com at 9/25/2007 11:17:32 AM
what is wrong in the following query I get the error 'Incorrect syntax near t2'. select t1.c1, (t1.c2 * t2.c2) as Estimate from table1 t1 inner join ( select it2.c1, it2.c2 from innertable2 it2 ) as table2 t2 on t1.c1= t2.c1 Thanks, Chary. ...more >>

Which version is right for Vista Home Premium
Posted by R2278 at 9/25/2007 10:56:01 AM
I have Windows Vista Home Premium 32-Bit OS. I want to learn Sql Server programming. So am trying to download the trial version from the Microsoft website. What version is right for me.Is it 180-day trial of Developer edition or Express edition(Free) . What is this Express Edition about? DO i ...more >>

Backup statement won't work with Stats=10
Posted by DB at 9/25/2007 10:00:02 AM
I run the following query in Query Analyzer while using Terminal Services (Application Server Mode) on a Windows 2003, SQL 2000 SP4 box: BACKUP DATABASE [MyTestDB] TO DISK = N'E:\Backup\TEST.bak' WITH INIT, STATS=10 I receive the following error: 10 percent backed up. [Microsoft][ODB...more >>

when max() does not yield a valid maximum
Posted by michael sorens at 9/25/2007 9:48:01 AM
This query tells me how many digits to the left and to the right of the decimal point for each value: ----------------------------------------------------------- SELECT MyField, 'Ldigits' = case when charindex('.',MyField) > 0 then charindex('.',MyField) - 1 else len(MyField) end, 'Rdigi...more >>

parsing c style strings with variable arguments in a table
Posted by georgejetson at 9/25/2007 9:02:06 AM
Hello, I have a table with 5 columns [C_STYLE_STRINGS] field type msg nvarchar(50) var1 nvarchar(50) var2 nvarchar(50) var3 nvarchar(50) var4 nvarchar(50) Typically, the msg field has content with c style escape sequences with var args that match as in the follo...more >>

problem - including null values in query
Posted by Rich at 9/25/2007 8:42:07 AM
CREATE TABLE #tmpA (intID int, RecordID int, UniqueID varchar(50)) INSERT INTO #tmpA SELECT all 1, 31589, 'CSW1-11042004A31589' UNION SELECT ALL 2, 40876, 'CSW1-11172004A40876' UNION SELECT ALL 3, 40876, 'FreeCSAR/AR05' UNION SELECT ALL 4, 40876, '' UNION SELECT ALL 5, 45308, '' UNION SELEC...more >>

Is this 3NF?
Posted by JXStern at 9/25/2007 8:40:33 AM
Current data model is full of this, and I don't like it, but I'm not entirely certain if it qualifies as 3NF or not. Or 2NF, or 1NF. create table person ( goodPK varchar(32) PRIMARY KEY,-- whatever, not the issue height int, weight int, height_or_weight_flag char(1) -- either...more >>

how to write a query to find all the users and their database permission?
Posted by SQL apprentice at 9/25/2007 8:22:50 AM
Hi SQL team, I am using Enterprise Manager (SQL2000) to check the users and the permission in every databases. I am also checking for the server roles like SA and who is in the server roles. Then I write everything on a report. My problem is that I have lots of databases and too many users s...more >>

Endpoints with Port other than 80?
Posted by Matthew Bando at 9/25/2007 7:56:04 AM
Has anyone successfully implemented SQL endpoints using a port other than 80. I can't seem to get this to work. I can successfully create the end point, but when I try to add a web reference from within Visual Studio, I can never locate the wsdl URL. I have tried the following: http://...more >>

Is it possible to do it in a single SQL statement?
Posted by ydbn at 9/25/2007 7:04:01 AM
For example, I have a "People" table which has a column "Age". I need the result like this: Group, Count <10, 122 <5, 233 <40, 232 20 to 30, 234 >25, 2342 The key is the group criteria may create overlap subsets....more >>

Deleting undo file in a restore
Posted by Adalberto Andrade at 9/25/2007 6:50:02 AM
Deleting undo file in a restore In my STANDBY routine when I run my SP the last line that worked Ok is : alter database DBTAL set SINGLE_USER with ROLLBACK IMMEDIATE After this, the next line below don´t works : restore log DBTAL from disk = \\smfw2k3desv01\d$\StandBy\DBTAL\b0921162.b...more >>

Need help in the process of moving/copying the .LDF file
Posted by Learner at 9/25/2007 6:45:44 AM
Hi, we had a production error this morning and the error says "Out of Disk Space XXX.LDF" (I exactly don't remember the error message). So to fix that we created a new XXX_New.LDF file and pointed it to D:/ drive on the same machine. This solved our problem and we are not getting this error...more >>

Group by and having causes time out
Posted by RichGK at 9/25/2007 6:23:44 AM
The following statement causes the server to time out. When not using "Group By" and not summing the cost field the same query takes about 3 secs. The database is about 600MB in size. Am I using the sum function incorrectly? As I didn't thing simply summing the results would cause such a pr...more >>

Name Table
Posted by shapper at 9/25/2007 6:20:28 AM
Hello, Can a SELECT return records and give that table a name? So instead of, in my C# code, the tables in the dataset get an index (0,1,2, ...) will get a name (TableA, TableB, ...) Thanks, Miguel ...more >>

No primary key ?
Posted by bruno.barral NO[at]SPAM altran.com at 9/25/2007 6:11:45 AM
Hello, I created a database, added several tables and defined a primary key for each (as an auto incremented counter, starting with 1). I installed this database for my cleint, but discovered that the primary keys for those new tables where not added(even if the columns were correctly cre...more >>

SQL Server 2005 Schema / Permissioning Question
Posted by Michael Burgess at 9/25/2007 4:10:36 AM
Hi there, My quert is as follows: I've created a website with an app pool that uses a network service account to hit the server. On the database that the website accesses, I need to be able to grant access to certain tables, like this: 1) UPDATE / INSERT / SELECT / DELETE access on Gifts ...more >>

SQL Query from Access to SQL Server
Posted by rune NO[at]SPAM totalweb.no at 9/25/2007 2:58:13 AM
Hi I'm trying to convert an SQL Query from Access to SQL Server. The Access Query goes like this: SELECT Format(EntryDate, 'ddd mm dd') AS [Day] FROM JournalEntries This query returns the name of the day followed by month and date (Su aug 21) What would this be like in SQL Server ? Wh...more >>

please help
Posted by Farhan Iqbal at 9/25/2007 2:56:01 AM
I have implemented the Transactional Replication on SQL Server 2005. right now the issue is my transactions are not replicated over subscriber. I have reinitialized the subscriber but the issue is same. gives me error : No active subscriptions were found. The publication must have active su...more >>

Restoring 2 versions of the same base
Posted by bruno.barral NO[at]SPAM altran.com at 9/25/2007 2:30:38 AM
Hello, I am running a SQL Server 2003 on my PC, with a database nammed myBase. I'd like to compare it to another version of the same base, which seems to be out of date. I have a backup of this other version. I tried to restore the backup, but I got a message from SQL Server telling that...more >>

sum a difference
Posted by balldigy NO[at]SPAM gmail.com at 9/25/2007 12:06:02 AM
i have the following sql select statement: select col1, (max(col2) - min(col2)) from table1 (nolock) where TransDate> '2007-09-22 07:59:59.999' and TransDate < '2007-09-22 09:00:00.000' group by col1 This will run fine, however, I need to be able to add all the values in col2 and display t...more >>

Insert takes to long !
Posted by bzh_29 at 9/25/2007 12:00:00 AM
Hi, I'm working on apps which records some data in simple table : CREATE TABLE [TABLE_A] ( T smallint NOT NULL, UID uniqueidentifier NOT NULL, C1 varchar(50) NULL, C2 varchar(50) NULL, C3 varchar(50) NULL, C4 varchar(5...more >>

Default value not less than 0
Posted by littleccguy at 9/25/2007 12:00:00 AM
Can I set the properties of a column to have a default value of 0 and not allow the number to be less than 0 in SQL 2005? Think inventory items. Thanks, ...more >>

sql server 2005 editions requirements
Posted by Roy Goldhammer at 9/25/2007 12:00:00 AM
Hello there I've heared that the using of Stadard or enterprise edition on sql server 2005 is also depend on the hardware type: Some of servers provide hardware which is compatible to sql server enterprise edition only. Is it true? and if so does microsoft have offical documentation abo...more >>

Bulk Insert after validation of uniqueness - SQL Query
Posted by Peri at 9/25/2007 12:00:00 AM
Dear All, I have uploaded one large file (Containing 2 Fields - SymbolCode and SymbolName) using bulk copy that contains 1 million records into a temp table (Say SymbolTemp). The SymbolCode is unique in this file. Now I need to insert records to the actual Symbol table validating uniquen...more >>

xp_cmdshell
Posted by Carlo at 9/25/2007 12:00:00 AM
Hi i wrote a bat file that extract some data from tables (using bcp) and ftp these data to another pc, if i run this file from console it runs correctly, if i try to run it using mssql it returns me errors: NULL C:\WINNT\system32>echo off A subdirectory or file 22 already exists. > Perfl...more >>

How to check database is replication database
Posted by SOHO at 9/25/2007 12:00:00 AM
Thanks! ...more >>


DevelopmentNow Blog