sql-server-2005

SQL Server database script

i need a script to script all the database object (like tables,sp,view).....like IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fnSplit]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT')) DROP FUNCTION [dbo].[fnSplit] GO /****** Object: UserDefinedFunction [dbo].[fnSplit] Script Date: 12/14/2009 ...

How should i work in this scenario . Should I use Trigger or Leave on User to manage

I am creating an application in which i am using stored procedure where i m implementing my logic. Now what i need to know is that- i want my database not to contain any invalid entry, for this purpose should i create triggers, for implementing my data validation logic such that when FailPasswordAttemptCount is changed to some value th...

How to reduce timeout period when sql 2005 database unavailable

Hi, I have some ASP (Classic) code that queries a SQL 2005 Express database. I'm currently handling programmatically if this DB goes down by handling the error when someone tries to connect and can't. I capture the error and bypass subsequent db queries to this database using a session variable. My problem is that this first query take...

SQL return rows where count of children does not equal column value

I have a table called Item with columns ItemID (PK), ItemName, ExpectedSubItems and another table called SubItem with columns SubItemID (PK), ItemID (FK), SubItemName. I want to return all rows from Item where the number of SubItems is different from ExpectedSubItems. I tried to use something like:- Select * From Item Join SubItem on ...

Getting the Nth most recent business date - very different query performance using two different methods

I have a requirement to get txns on a T-5 basis. Meaning I need to "go back" 5 business days. I've coded up two SQL queries for this and the second method is 5 times slower than the first. How come? -- Fast with BizDays as ( select top 5 bdate bdate from dbo.business_days where bdate < '20091211' order by bdate Desc ) ,BizDate ...

Office 2007 updates after installing Visual Studio & SQL Server 2005

I just installed Visual Studio 2008 TS and SQL Server 2005 Enterprise and I get a bunch on Office 2007 updates in Windows Update. I don't even have office installed. Should I: Just install the updates (~20MB only) Don't install and hide them (possible security issue) Uninstall to get rid of those updates I already uninstalled some ...

Primary key violation exception with SqlDataAdapter bulk insert

Hello, I have a WinForm 2.0 application that uses a standard DataGridView control to allow inserts, updates and deletes. I am implementing the bulk insert via the SqlDataAdapter bulk insert functionality, but am getting a primary key constraint violation of my table I am trying to insert into. Violation of PRIMARY KEY constraint ...

Date of last login or read operation on a SQL Server database?

Lets say I have a SQL Server with 100 databases on it. How can I find out which ones are actually being used? (without turning them all off and waiting for the complaints to come in) So 'have been accessed in the last week' or something like that. I've tried the data file dates but they don't seem to represent that and databases do no...

Whats the SQL Server TIMESTAMP equivalent in Oracle?

In the program I have, I depend on the SQL Server TIMESTAMP data type to tell me if a row's "content" has changed. What's the way to find out if a row's content has changed in Oracle (preferably without having to add a extra column for this in a table) ? ...

How to insert content of large xml file into tables in sql server 2005?

Hi all, I need to insert the content of an xml file of size 350 Mb into tables in sql server 2005. How to insert? I have tried to use bulk insert but got out of memory exception. Please help. ...

SQL Statement from DML Trigger

How can i know which sql statement fired through trigger for select, insert, update and delete on table? Thanks, Paresh Prajapati http:\paresh-sqldba.blogspot.com ...

Sql Server 2005 Express Edition Question

We have a Sql Server 2005 Standard Edition running on a Production website. We'd like to move to a cloud hosting but they only offer Sql Server Express Edition on there. My question is, will there be any problems in moving over? We only use tables, views, stored procedures and a few user defined functions. And we also have a Backup Mai...

Help needed in getting total resource count (SQL Server 2005)

I have a requirement. I have been given the following table DownLineid UplineId Name DirectResources 1 2 Sarvesh 7 2 NULL Admin 5 3 2 Lonesh 10 4 2 Swapna 2 5 2 Priyanka 12 8 2 Sumi 1 6 ...

Maximum number of dbprocesses already allocated

I'm running a Delphi application that uses BDE for database connection. Ocassionally (more often than I'd like) this error pops up when opening a query. Googling for this error, most picks refer to MS SQLServer database, and speak about a dbsetmaxprocs function, which I can't seem to find. So the question is: how can I prevent/correct ...

Computing aggregated values in a hierarchical structure bottom-up

Hi, I need to recompute quantities in a BOM structure which only guarantees correct quantity values for leaf nodes. If the above is a bit blurry don't worry, below is a simplified example. Consider a hierarchical table defining three columns: ID (PK), PID (parent ID in the hierarchy) and Q (quantity - of something, for the current rec...

SQL server Query help

I am passing a list of zipcodes to a stored proc (say 11111, 11112, 11113, 11114, 11115) and the zip code table contains only few rows (say 11111, 11112, 11113) and now I want to write a query which returns the zip codes that are not exists in the table (11114 and 11115) Could anyone please help me to write a query like this? Thanks in...

SQL: Using Where in a query with a function

SELECT col1, col2, dbo.myFunc(@param1, @param2, col1, col2) FROM theTable how do I add a "WHERE" here to the result of the function dbo.myFunc, like WHERE resultOfMyFunc > 10 for example? ...

Oracle's Bitmap Index in SQL Server

I've been successfully using bitmap indexes for years in Oracle environment. Now I'm working on a data warehouse project which will be hosted on SQL Server 2005. So far, I was unable to find an answer for bitmap like indexes in SQL Server. Any Ideas? ...

SQL Server stops processing for 20 seconds

I can't figure this one out. On SQL Server I have a process that is run dozens of times per second (data being sent to the server). The process runs great, processing requests takes between 50ms and 200ms. Then, roughly (but sporadically) once every 1.5 minutes all requests suddenly take 15000ms to 22000ms (15 to 22 seconds). At the same...

Can I install SQL 2005 x86 developer on Windows 7 Professional

Can I install SQL 2005 x86 developer on Windows 7 Professional ...