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 2007 > threads for tuesday march 13

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

SQL Injection
Posted by Rahul at 3/13/2007 11:50:31 PM
Friends, How we can protect our database with sql injection. --Rahul ...more >>


DATE RANGE PROBLEM
Posted by Ram at 3/13/2007 9:52:00 PM
Hi All, I have below table structure: ItemID Price FromDate ToDate --------------------------------------------------------------------------------------------- 1 10.00 01/01/2005 ...more >>

improving performance
Posted by Rob T at 3/13/2007 8:54:32 PM
I have a module that processes sales forecasts and calculates bill-of-materials to figure out product demands. Right now, the processing can take several hours (sometimes 12+) to perform and write about 3 millions records as it figures things out. I also need to reference the data in this ...more >>

bit versus char(1)
Posted by news.microsoft.com at 3/13/2007 5:00:59 PM
Personally, when I see CHAR(1) with 'Y' and 'N' instead of bit, I get mad. But it's apparently so common I have to ask: is there any good reason for it? Paul ...more >>

dynamic FROM and WHERE
Posted by light_wt at 3/13/2007 4:38:00 PM
hi, i have a simple query that needs to be created dynamically... SELECT a.isbn FROM dbo.author a LEFT JOIN dbo.rating...more >>

query assistance - combine two into one
Posted by WB at 3/13/2007 4:36:51 PM
I have two queries SELECT TOP 10 WITH TIES td.InventoryId, SUM(td.Quantity) FROM tblTransaction t, tblTransactionDetail td, tblCustomer c, tblInventory i WHERE t.TransactionId = td.TransactionId AND t.CustomerId = c.CustomerId AND td.InventoryId = i.InventoryId AND t.Custom...more >>

anal syntax question about EXISTS .. whats your preference?
Posted by sloan at 3/13/2007 4:13:58 PM
We have a company standard which says " no 'Select * from " , which I agree with ) . ( This is NOT my question) So I went and self reviewed my code, and I found the only place I had a select * was with EXISTS and NOT EXISTS statements. Below are 4 methods. Which do you use/prefer? And ...more >>

Necessary to Commit a transaction
Posted by tshad at 3/13/2007 4:03:30 PM
In a store procedure, do you need to explicitly Commit a transaction? If you exit the SP where you have done a Begin Tran and haven't done a Rollback Tran or Commit Tran - will the tranaction be rolled back or comitted? Thanks, Tom ...more >>



How do I do this SQL query?
Posted by Alan Silver at 3/13/2007 3:53:13 PM
Hello, I hope someone can help me, as this query is driving me a bit mad! Suppose I have two tables, which contain sales data... create table saleshistory ( buyername varchar(50), email varchar(50), saledate datetime ) create table saleshistoryitems ( saleshistoryid int foreign key ...more >>

Return Cursor from 1 SP to another...
Posted by ThomBeaux at 3/13/2007 3:34:08 PM
How do you call a SP that returns 3 recordsets (cursors) from another stored Procedure? -- Thanks and God Bless, ThomBeaux...more >>

SSIS - SQL Server configuration
Posted by SQL Learner at 3/13/2007 2:39:04 PM
Using SSIS, I want to store my configuration in a database table. I opened Package Configuration Wizard, and selected Configuration Type: SQL Server, Configuration location is stored in an environment variable. Next I created an environment variable SSIS1_CONFIG For integrated security, ser...more >>

Identity - table variables
Posted by slickster79 at 3/13/2007 2:34:31 PM
I have a situation with a table variable where I insert rows, use the data, delete the rows and then subsequently add new rows. I need the identity column (in this case IdentityAppID) to be re-seeded to 1 everytime I insert a new rowset. I've tried using dbcc checkident and various other metho...more >>

Importing excel file into SQL Server using SSIS package ...
Posted by SqlBeginner at 3/13/2007 1:30:13 PM
Hi, I have an .xls file (which is of size 40+ MB). I want to import it into SQL Server 2005 using SSIS packages. I am totally new to that .. can any one help me with that pls? My mgr doesn't want to do it via import/export wizard. Regards Pradeep...more >>

How do I know if I have SP2 for SQL Server 2005 installed?
Posted by Ronald S. Cook at 3/13/2007 1:20:09 PM
How do I know if I have SP2 for SQL Server 2005 installed? Thanks, Ron ...more >>

UDF Runs Separately, but "Error converting data type" on INSERT
Posted by JonOfAllTrades at 3/13/2007 1:04:05 PM
Good afternoon, people. I've bumped into an odd problem, I hope someone can point me in the right direction. I have a list of numbers. I'd like to update those numbers where I one exists in another table. This is a slightly simplified form: DECLARE @BestNumbers TABLE ( ID INT NOT NU...more >>

Stored proc running *really* slow inside transaction
Posted by joelycat NO[at]SPAM hotmail.com at 3/13/2007 1:01:28 PM
We have a stored proc we inherited from the previous developers that is somewhat messy (temp table, cursors, etc.). As noted its not the most well written sproc but we are seeing really strange behavior when running inside a transaction vs. outside a transaction. Outside the transaction it tak...more >>

nocheck constraint
Posted by tshad at 3/13/2007 1:00:46 PM
I am just curious here. In my case, I am creating a diagram showing the relationships between 2 tables that has a CompanyID in the HRUsers table. But I don't want to enforce the restraint. There are cases where there will be no CompanyID and if I enforce the restraint I get an error. S...more >>

Error messages confusion
Posted by tshad at 3/13/2007 12:49:42 PM
Using Sql Server 2000, I am forcing a constraint error for testing and am confused on the errors I am getting: After the error occurs, Scope Identity is blank (not 0) and @@error is 0: The Code: ************************************************ INSERT INTO ftsolutions.dbo.temp (CompanyID,Fi...more >>

how to list a specific row in a dataset as the first row?
Posted by Rich at 3/13/2007 12:06:29 PM
Select * from tbl1 Where city = 'abc' returns 30 rows with unique Names. THe user wants to see all 30 rows with the row containing Name = 'Joe smith' as the first row. If I order by the name column, 'Joe Smith' is in the 15th row. How can I list this dataset where the row containing ...more >>

Query question (did not post first time)
Posted by Mark Goldin at 3/13/2007 11:58:03 AM
I have the following data sample: id job_id old new updatetime updatename 14169 9005 4 3 2007-03-12 14:26:45 msetstatusjob 14161 9005 3 4 2007-03-12 10:37:03 mregisterjob 14158 9005 4 3 2007-03-12 10:30...more >>

Update ordering...
Posted by Ken at 3/13/2007 10:26:13 AM
pknum int (autoinc) pressnum int active bit startuporder int ……. I’m working on a startup list. This query reset the startup order declare @i integer set @i = 0 Update press SET @i = startuporder = @i + 1 where active = 1 The problem is there is no update order by, so the pre...more >>

Partial string link
Posted by SQLFriend at 3/13/2007 10:04:30 AM
Hi, I have 2 tables as follows: Table A: Invoice No ------------- 1234 5487 7894 4545 Table B: Invoice No -------------- 1234/5487 4545/1111 1234/2000 I want to run a query that will show any match between the 2 tables even if Invoice No of Table A is part of Invoice No in Table...more >>

Sql Server 2005 Paging, Dynamic Order By
Posted by Kevin Blakeley at 3/13/2007 9:48:20 AM
I am looking at implementing paging using some of the new features of SQL 2005. Most of the techniques I see on how to do this has a static order by statement. In my case, the sort column and order will be decided by the user when he clicks on my datagrid. I found a technique that generated...more >>

Dynamic SQL low performance in SQL Server 2005
Posted by gilleschristo NO[at]SPAM gmail.com at 3/13/2007 9:16:23 AM
Hi, This is a comparison between SQL Server 2005 and SQL Server 2000. I use dynamic sql in a stored proc as follow : CREATE PROCEDURE MyProc ( @Param1 navarchar(50)) AS BEGIN declare @query nvarchar(4000) set @query = ' ' set @query = @query + ' select Col1, Col2, Col3 , .... ' set...more >>

How to fix this query?
Posted by Zim Babwe at 3/13/2007 8:17:54 AM
I have three tables: InstMaster, InstProducts, and Contacts. The InstMaster contains Master records for Bank information. It has InstID int; InstName varchar(50) The InstProducts table has: InstID int; Proprietaryname varchar(50) The Contacts Table has: InstID int; ContactName ...more >>

need to get max date and min date.
Posted by Andrew at 3/13/2007 8:12:08 AM
this select statment brings back 6 records. select (select Visit from PatientVisit where PatientVisitId = PatientVisitAgg.PatientVisitID) as sVisit from PatientVisitAgg where PatientProfileId = '7847' and PatBalance > 0 How can I get the max date and min date from this record set? ...more >>

table redesign... Am I on track??
Posted by StvJston at 3/13/2007 7:48:00 AM
I have a question/would like some input on a group of database tables design. One of the main goals of this redesign is the ability to maintain a history of who the crews/crewleaders/crewmembers were and when they were assigned to various crews. The objective of this redesign is so product...more >>

Creating a Summary Table - Pivot ?
Posted by ami at 3/13/2007 7:42:51 AM
I have a table with the following structure. There is a unique ID for each column: Unique_ID Grade1 Grade2 Grade3 Grade4 1 A+ A B A 2 C A+ C D etc. Basically, there are rows of grades pe...more >>

SProc Dependencies
Posted by Dave Booker at 3/13/2007 7:37:00 AM
When I "View Dependencies" for a Table in SQL2005, it lists some but not all SProcs that I would say depend on the Table. For example, if a SProc UPDATEs the Table, it lists it. But if the SProc SELECTs from it, it does not. How can I determine all the SProcs that reference a table in any...more >>

PIVOT in SQL 2005 problem
Posted by HÃ¥kanK at 3/13/2007 7:36:53 AM
I'm trying to use PIVOT instead of CASE but can't make it. What's wrong with the pivot query below? create table t1 (a int, b char(5)) go insert t1 values(1, 'SVE') insert t1 values(1, 'FIN') insert t1 values(1, 'DAN') insert t1 values(2, 'SVE') insert t1 values(2, 'FIN') insert t1 value...more >>

Tutorial Website for Smart SQL
Posted by Jay at 3/13/2007 3:28:00 AM
I am looking for a free website where they have given examples/ tutorial on T-SQL, mainly writing advanced smart SQL statements. I am looking for simple tricks that SQL programmers use. These would be things like calculating moving averages, calculating price returns, creating cross-tab type out...more >>

Query an ODBC from Inside a Stored Procedure
Posted by Rob.J.White NO[at]SPAM gmail.com at 3/13/2007 3:23:10 AM
Hi, I'm trying to write a stored procedure that can query the database it is running on, but also is able to query another data source that is accessed via an odbc connection. Is this possible and what steps do I need to take? Thanks for any help. Rob ...more >>

Script to kill all user connections to a db except three
Posted by paullie69 NO[at]SPAM hotmail.com at 3/13/2007 3:13:30 AM
Hi guru's SQL 2000 standard - is there a way of creating a script that will terminate all user processes to a specific database apart from 3 that must remain ? I can find scripts to terminate ALL processes but not specific ones Please let me know if you need any more information Thanks...more >>

C++ and SQL image storage
Posted by Robert at 3/13/2007 3:11:26 AM
Want to store (write/read/update) images into SQL DB from VC++ code. Pls, give me any reference where can get knowledge. Any sample code also awesome. Zanx...more >>

Update fields
Posted by cvandenhaak NO[at]SPAM eaig.nl at 3/13/2007 3:08:05 AM
Hi There. I want to update in 1200 ZIP fields the value A-xxxxx to xxxxx (all different characters exept the A-) how can i solve this. ...more >>

String compare; common part
Posted by Stefan Balan at 3/13/2007 3:05:34 AM
Hi guys, I need your help writing a query that would return the common part of two strings. Ex: from 'Wallet Neo PVC Beige' and 'Wallet Neo Nylon Black' i need 'Wallet Neo' I've been busting my brains, but... maybe I can't think right because of the pressure... Thanks ...more >>

dbcc pintable
Posted by Mal at 3/13/2007 12:12:00 AM
Hi I've never really had the requirement to use but with testing I've found that sometimes this command can be used to improve performance. I've inhereted a system where the developer used this on a table with 250k rows. The process that use this table only runs once a month in the quie...more >>

Management studio - Source control questions
Posted by Paul at 3/13/2007 12:00:00 AM
Hi I'm currently using Sql Server management studio and Team Foundation server as the source control system. I have a database solution which multiple scripts (DDL, stored procedures etc) Developers are allowed to create tables, sprocs etc in the development environment, but when moving...more >>

Return only highest Count
Posted by Morten Snedker at 3/13/2007 12:00:00 AM
select MunicipalityID, DHGridID, DHCompanyID, count (*) as Antal from EnergySUpply where not DHGridID is null group by MunicipalityID, DHGridID, DHCompanyID order by DHGridID, DHCompanyID may return more than one record per DHCompanyID. If that is the case I only want the one with the highe...more >>

Scalar function question
Posted by Mark Goldin at 3/13/2007 12:00:00 AM
Can I declare a cursor in a scalar-valued function? Thanks ...more >>

Sql view pb
Posted by Bragadiru at 3/13/2007 12:00:00 AM
Hi all, How can I get programatically the tables on which my sql view depends ?? Now I'm using .NET Framework 2.0 and Sql.Dmo to get the CREATE VIEW ... script (using SqlDmo.View.Script), but I need to get the table names, too, to create tables first. Thanks for any advice ...more >>

it may be simple to convert..
Posted by Peterpeter via SQLMonster.com at 3/13/2007 12:00:00 AM
in sql table there is column "createdtime" (Int, Not Null) values like 86205 12712 how to convert this int by the simpliest way this to time like 11:05 - for example 12:30 Thanks Peter -- Message posted via SQLMonster.com http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-...more >>

Updating tabel with select.
Posted by Dahab at 3/13/2007 12:00:00 AM
Hi, I'm stuck with a update query and need some help. I'm using OPENQUERY to select data from a linked server to update a tabel on the local server, but can't seem to get it right, Tried something like this: -------------------------------------------------------------------- set @sql= 'S...more >>

Server 'sqlken' is not configured for RPC
Posted by Ken at 3/13/2007 12:00:00 AM
I tried to run stored proc which has mutiple linked servers. When I tried to run, I got the error message like below. Server 'sqlken' is not configured for RPC anybody has an idea why I got this and how to fix? Thanks ...more >>


DevelopmentNow Blog