sql-server

New SQL Server - help with request of requirements for installing server w/SQl Server

So my employer has asked me to come up with list of "requirements" to put in a SQL Server. Just very general, however I am pretty inexperienced at such a thing. So my list looks like: SERVER SQL SERVER ENTERPRISE EDITION ADDITIONAL SOFTWARE and that is about it. I know very little about the make up of servers, so I have no idea what...

Calculating total time that falls outside of dataset within date/time range

I'm looking to add some new functionality to an existing application (database is Microsoft SQL 2005). Basically, I'm trying to calculate how many minutes (or seconds) a particular department was "unmanned" for a particular set of date ranges. I'm looking to query the dataset ideally with one statement. I have a routine that loops throug...

LINQ-to-SQL Locks SQL Server during query?

Having a weird problem. I'm testing an ASP.NET application I wrote that queries SQL server via AJAX. The application is using LINQ-to-SQL to load data from approx 8 or so tables in a join, and every once in a while, the call to SQL server locks up and never returns. My first thought was that it was getting deadlocked, but from what I'...

Is there a utility for finding SQL statements in multiple files and listing any referenced tables and stored procedures

I'm currently looking at a terrible legacy ColdFusion app written with very few stored procedures and lots of nasty inline SQL statements (it has a similarly bad database too). Does anyone know of any app which could be used to search the files of the app picking out any SQL statements and listing the tables/stored procedures which are ...

Expanding list of databases in SQL Server 2008 Management Studio Takes Longer than SQL Server 2005

Is it just me, or does expanding the list of databases in SQL Server 2008 Management Studio take significantly more time than expanding the list of databases in SQL Server 2005 Management Studio? If it isn't just me, is there an explanation for this behavior? Whatever it is doing in the background that makes it take longer, can we tur...

C# timer for database cyclic polling

I'm not very familiar with C# so far, at least not enough to feel confident when choosing ways of doing something when it comes for the first time. What could be the best way to organize SQL Server database timer based polling from my WPF application for controls updating? Could you please share some thoughts on this issue or, maybe, ...

Is there a way to suppress "x rows affected" in SQLCMD from the command line?

Is there a way to suppress "x rows affected" in SQLCMD from the command line? I'm running an MSBuild script and don't want it clogging up my log on my build server. I'd rather not have to add "SET NOCOUNT ON" in every script, so if there's a way to do it from the command line, that would be fantastic. ...

Connecting to commercial databases from an Adobe AIR application

I'm new to Flex and Adobe AIR, but I'm writing a desktop application that will need to connect and query commercial databases such as DB2, SQL Server and Oracle. How do I connect to these type of databases from ActionScript in an AIR application? ...

Determining SQL data path for DB RESTORE with MOVE

I'm trying to write a script which automatically restores a database backup. I know I can use the following RESTORE command: RESTORE DATABASE [DBRestoredName] FROM DISK = N'C:\path\to\backup.bak' WITH FILE = 1, MOVE N'DBNAME' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\DATA\DBNAME.mdf', MOVE N'DBNAME_log' TO...

Connection problem in Win2k3 server 64 bit with JDBC

DriverManager#getConnection() returns null when I am deploying my JSP/Servlet package in a Windows 2003 Server environment (64 bit). The database is Microsoft SQL 2005 Enterprise Edition. The code is: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:calsoft2k","xxx","xxx"); The same code is ...

what is the correct syntax for creating a database trigger for insert, modify and delete

i have what seems like a basic scenario for a db trigger in SQL server and i am running into an issue. i have table Users (id, name, phone, etc) and i have tables UsersHistory (id, user_id action, fields, timestamp) i want a database trigger where anytime inserts, updates or deletes into Users, i want a new record created in UsersHist...

How do reduce transaction log growth for batched nvarchar(max) updates

Our app needs to add large amounts of text to SQL Server 2005 database (up to 1 GB for a single record). For performance reasons, this is done in chunks, by making a stored procedure call for each chunk (say, usp_AddChunk). usp_AddChunk does not have any explicit transactions. What I'm seeing is that reducing the chunk size from 100MB t...

grouping items in sql query

I have a table with columns like (in sql server 2000) MailCode Mode Name Group -------- ----- --------- ------- 1 1 abc 0 1 1 def 0 1 1 qwe 1 2 2 aaw 0 2 2 aad 0 I want to group the Name field based on the rest of the fil...

SQL server queries are really slow only on first run

Somewhat strange problem... when I start my .NET app for the first time after rebooting my machine, the SQL Server queries are really slow... when I pause the debugger, I notice that it's hanging on getting the response from the query. This only happens when connecting to a remote SQL server (2008)... if I connect to one on my local mac...

Is there a way to have SQL server validate object references in Stored Procs?

The following code executes fine in SQL Server create proc IamBrokenAndDontKnowIt as select * from tablewhichdoesnotexist Of course if I try to run it, it fails with Invalid object name 'tablewhichdoesnotexist'. Is there any way to compile or verify that Stored Proc are valid? ...

Two Rows Get Inserted with One INSERT statement?

Hello all, How is it possible that this function below inserts two rows in my database? //called like save_session_db($_SESSION['user_id']); function save_session_db($session){ include('includes/db-connect.php'); $connectionInfo = array( 'Database' => 'Belior'); $conn = sqlsrv_connect( $serverName, $connectionInfo); if...

Change Sql "Not In" To "Left Outer Join"

Hi, I don't want to use "not in" this sql query. How can I do it? thanks SELECT T2.Sno, T2.Name, T1.description, T2.UserCode FROM Table1 AS T1 (nolock) INNER JOIN T2 (nolock) ON T1.UserCode = T2.UserCode WHERE g.xid= @p_xid and T2.Sno not in (select Gid from T3 (nolock)) ...

How many PHP scripts can run concurrently via http request?

Hello all, I know PHP scripts can run concurrently, but I notice that when I run a script and then run another script after it. It waits for the first to finish and then it does what it has to do? Is there an Apache config I have to change or do I use a different browser or something?!! Thanks all EDIT If I go to a different browser...

Ensure "Reasonable" queries only

In our organization we have the need to let employees filter data in our web application by supplying WHERE clauses. It's worked great for a long time, but we occasionally run into users providing queries that require full table scans on large tables or inefficient joins, etc. Some clown might write something like: select * from big_t...

Add user in database?

I have a user which can login in sql server. Now i need to add user in database, however i am not sure if that user already exists in database or not. So i need script, which checks if the user exists in database or not, and if doesn't it should add that user in that database. How can i do that? ...