sql-server-2005

Joining tables (without a clause)

I want to join to tables and get the following output Table1 TestId1 ---------- one two three four five six seven eight Table2 TestId2 ---------- fiftythree fiftyfour fiftytwo fiftyfive fiftyone I want Table3 as my output with all rows from table1 and the first rows from table2 until there are no more rows left and then they shoul...

Find All References to View

I've got various databases, and what to be sure I am removing something (a view in this case) that is truly orphaned. Is the the correct SQL to be using: SELECT r.routine_name, r.routine_definition FROM INFORMATION_SCHEMA.ROUTINES r WHERE r.routine_definition LIKE '%my_view_name%' The problem with it is that these referenc...

Add default value to existing column

Somehow this customer's database didn't update correctly, and now they have some number columns which should have a default value of 0 with no default value (but not null), and it creates an error that the column cannot be null when I try to do an insert. I tried: ALTER TABLE cesMisc ALTER COLUMN int1 int DEFAULT((0)) But it doesn't...

SQLCmd Hanging On Complex Batch Scripts

My company is currently using the sqlcmd 2005 for deployment and for some reason on certain SQL scripts it tends to hang even though there are no errors, and if run from management studio it completes successfully. It tends to hang on complex scripts that have multiple GO statements and or cursors. By "hang" I mean the process will not...

Strange problem connecting to a database from a published ASP.NET application

Hi. I'm developing an ASP.NET application that is connecting to a SQL Server database using a sql account ie a connection string in the format "Server=THESQLSERVER;Database=theDb;UID=guest;PWD=guest;". Everything works fine in the development environment in Visual Studio. However when I publish the application to my IIS (v5.0) webserver ...

SQL Server "Shared Memory provider" Error

Hi, I am running the following command in a batch file: osql -S dbname -U username -P password -i C:\inputSQL.sql -o C:\postMigration.log -n The dbname, username, and password have all been set correctly. However , when I run the batch file I get this output to the "C:\postMigration.log" log [SQL Native Client]Shared Memory Provid...

how would you get many top root?

I have a parent/child relation table, many to many parentid int not null childid int not null let say I have company a, b, c, d, e a ..b ....c ..c d ..e ....b ......c I got this query to return one top parent FUNCTION [dbo].[getRootCompagny] ( @root int ) RETURNS int AS BEGIN DECLARE @parent int SELECT @parent = companyparen...

Replication Custom resolver changes empty strings to NULLs

We have an C# application which posts to a database which is replicated to another database (using merge-replication) and has one custom resolver which is a stored procedure. This was working fine under SQL Server 2000 , but when testing under SQL Server 2005 the custom resolver is attempting to change any empty varchar columns to be n...

SQL - What type of join is it and the best way to rewrite?

Our 3rd Party app has a custom View with the following: FROM dbo.vwPositionAssetSubWeight INNER JOIN dbo.vwPositionAssetSubTotal ON dbo.vwPositionAssetSubWeight.AssetID = dbo.vwPositionAssetSubTotal.AssetID FULL OUTER JOIN dbo.vwPositionAssetPendingTrades ON dbo.vwPositionAssetSubWeight.AssetID = dbo.vwPositionAssetPendingTr...

SQL Server 2005 - Multiple Processor Usage

We have a 16 processor SQL Server 2005 cluster. When looking at CPU usage data we see that most of the time only 4 of the 16 processors are ever utilized. However, in periods of high load, occasionally a 5th and 6th processor will be used, although never anywhere near the utilization of the other 4. I'm concerned that in periods of tr...

Missing Data Updates

I am having a problem with data not updating on the CRM at my wife's office. Scenario: User loads the app. Data from the DB populates the master view. User opens edit screen. Data is populated for the correct detail item. User changes a value (on any field). The save button becomes active with the data change. The user clicks ...

SQL Server parallels to Oracle DBMS_METADATA.GET_DDL ?

I'm looking for command line or scripted solutions to pull the DDL out of SQL Server 2005+ for all database objects: tables, stored procs, views, indices/indexes, constraints, etc. GUI tools are not of interest. Preference is for built-in tools, since that would be the most comparable to Oracle's DBMS_METADATA stuff. Also, preference f...

SQL Server 2005 edition for Web applications

We are developing a web application (ASP.NET) for a bank, and it uses SQL Server 2005. The bank will have to buy a license for SQL Server 2005. The question is - which SQL Server 2005 version / license will be the least expensive for such purposes? 1) It seems that the SQL Server Express version which is totally free can do. However, i...

Query timeout, depending on dates

Hello, we have some user forms that include a 'period' menu, where the user can request the server to return data for a specific date range, such as "Purchase Orders issued between the 1st and the 10th of October 2008". The logic is then to add "on the fly" the date range to the original sql query and requery the data. The syntax of t...

Join characters using SET BASED APPROACH (Sql Server 2005)

I have a table where the data are like Data a b c I need to write a SQL Query to bring the following output Data abc Note:~ The number of characters are not constrained to 3. I have solved using while loop. But I have to do it using set based approach.So how can I join those characters? I tried using COALESCE but no luck Pl...

Picking info using junction table(SQL SERVER 2005) [ SET BASED]

I have 3 tables 1) tblPurchaser having 2 columns: PurchaserId PurchaserName 1 A1 2 A2 3 A3 2) tblCar having 2 columns: CarId Carname 11 C1 12 C2 13 C3 14 C4 And the last is a junction table tblInformation where the information about those persons are given who has purchas...

Configuring james to connect to Microsoft sql server 2005

I'm getting database connection error whenever I try to connect james to sql server 2005, I already loaded driver sqljdbc in the lib directory in james, then why I'm getting an error? Here's the config.xml file of james which is trying to connect to sql server: <data-source name="maildb" class="org.apache.james.util.dbcp.JdbcDataSourc...

Anyway to create a SQL Server DDL trigger for "SELECT" statements?

I am dealing with some sensitive Accounting tables and I would like to audit any SELECT statement executed on the table or any views associated with them. I did not find any DDL Events on BOL (Books Online) that had anything to do with SELECT statement. And DML triggers are for INSERT, UPDATE and DELETE only. Is it possible to log who ...

delete from gridview using stored procedure

Hi i have a gridview, linked to a sqldatasource. I have added a stored procedure to delete from multiple tables, and then enabled deleting on the gridviews smart tag. When i click the delete button i get an error message, "Object must implement IConvertible". I read that it is a problem passing the parameter to the stored procedure, pos...

SQL SERVER 2005 Connectivity Problems

I am having a hell of a time trying to connect to the SQL SERVER 2005 database. I am using Windows 7. Here is the screenshot of the error thrown: I have been battling this issue for the past week and still no progress. I have tried the following in the server name: (local) localhost computername none of them worked! I just...