sql-server

shared stored procedure

Let's say I have many sql server databases which have exactly the same schema. Is there any place where I can write a stored procedure and apply for all databases? If I create the stored procedure for each database, when needed, I have to update them all. ...

MySql sever instance configuration wizard help

I have uninstalled mysql from my system long ago and i have forgot the passowrd i have set to mysql now when i tried to install it its asking for the old password to set the new password in MySql sever instance configuration wizard i am not getting access to mysql command line client. ...

Need help writing a SQL query

Im an SQL noob. Heres my situation. I have the following tables. Customer_table Customer_ID | Last name | First Name | City_ID | Region_ID | Country_ID Country_table Country_ID | Country Region_table Region_ID | Region | Country_ID City_table City_ID | City | Region_ID | Country_ID I need to find the number of cus...

SQL Server Switching Between IS NULL and = in same statement

Snip.. WHERE (dbo.ProductIngredients.Ing_EffectiveTo = (SELECT TOP (1) Ing_EffectiveTo FROM dbo.ProductIngredients AS ProductIngredients_1 WHERE (Ing_Id = dbo.ProductIngredients.Ing_Id) O...

Grand total of accounts SQL

I am a student this is homework... I have one table with four columns: Accounts(numbers), balances(money), and two for descriptions. I have to get a grand total of the balances... This VIEW shows the sums of the balance column but I need to total the sums, also. Any help pointing me in the right direction will be appreciated. CREATE V...

WebPartManager issue in ASP.Net

Hello everyone, I am using ASP.Net + .Net 3.5 + VSTS 2008 + IIS 7.0 + C# to develop a web application. I am using WebPartManager, and I find when personlization feature is enabled to true, the web application will connect to SQL Server Express version database automatically. BTW: I find this by when stop SQL Server Express version serv...

SQL Server Authentication

Hello, I'm new to SQL Server 2008... I have a C# application where: the users are authenticated at application level with a login form after their login the application connects to the DB by using the same SQL Server Account (SQL Server Authentication) for each user My question is: Is there any limit on the number of users which c...

Error "The primary key column of type 'DateTime' cannot be generated by the server."

I have a composite primary key (Int and DateTime) on one of my tables. When I try to add a new record using LINQ (with the DateTime field set to "AutoGeneratedValue = true", and getdate() as default value on the server), I get the following errors: The primary key column of type 'DateTime' cannot be generated by the server. Any ide...

Hey guys, can someone help me in this SQL Query...

This is a query based on the Northwind Database in MS SQL Server 2005. First I have to get the average of the UnitPrice from OrderDetails table, and group it by ProductID for that particular column alone and alias it as AveragePrice. Then I need to find the maximum(AveragePrice) which is nothing but the max of previous column, how can ...

I'd like to know, what columns have been REALLY changed

Hello all, I have an after trigger implemented in SQLCLR assembly. Within it I'd like to know, what columns have been really updated (and their values have been changed). Unfortunately, SqlContext.TriggerContext.IsUpdatedColumn returns true, even when a column value is still the same. I guess, it's just because an SQL query, prepared b...

Javascript sorting to match SQL Server sorting

Can anyone point me towards a sorting algorithm in javascript that would sort the same way SQL Server does (for nvarchar/unicode columns)? For reference, my previous question about this behavior can be found here: http://stackoverflow.com/questions/3213717/sql-server-2008-different-sort-orders-on-varchar-vs-nvarchar-values Rather than ...

How could I design this database scenario?

I am trying to create a "Task" schema in my database. One field is "blockedBy" which represents another Task that is blocking this current task. I am new to SQL Server and databases in general. How can I create the table properly? It seems like the only valid options are numbers or text. Should I just store the ID number of the other ...

Looking for SQL Optimization Interview Questions

I'm on a project where I was asked to take a quick peek at some reporting SQL (in a SQL Server 2K5 environment) and was surprised at what I found: 4 to 5 levels of subquerys, distinct clauses, unions, and NoLock hints (which were needed because the SQL was running so long it was blocking standard processing) - all in the same set!. Beca...

Need help on this SQL...

Here is the question: +--------------+ Ships | +--------------+ Duke of north | ---------------+ Prince of Wales| ---------------+ Baltic | ---------------+ I need to replace all characters between the first and the last spaces (excluding these spaces) by symbols of an asterisk (*). The number of asterisks must be eq...

Is querying on views slower than doing one query?

Will Mssql be even fast when I query on a view opposed to one query? example When I have this view: create view ViewInvoicesWithCustomersName Select * from Invoices left join Customer on Customer.ID=Invoices.CustomerID What will be faster or will it be even fast? a) select * from ViewInvoicesWithCustomersName where customerName="B...

How to write a recursive trigger

I have written an update trigger, that does an update that could potentially call itself (which is the behavior I want). Unfortunately, The trigger does not call itself, and I cant see why. This trigger is simply changing a value of any child records (based on a Parent key), and then I expect on that child being updated the trigger sho...

SQL Server 2005 Merge Replication with SQL Compact 3.5 sp2 Web Synchronization setup error

I am trying to setup a merge replication from SQL Server 2005 to SQL Compact 3.5 sp2. My environment: - Server: Windows 2008 R2 64bit - SQL Server 2005 installed on server - IIS 7 installed on same server with IIS6 compatibility components installed - SQL Server Compact 3.5 SP2 Server Tools installed on server I create the publication ...

Complecated SQL Query: Members' Downline Business SQL Query

Hello Everyone! I've got confused at the moment. I've got one database to developed for MLM (Multi level marketing) company. so, there's one Members database.. each member have unique ID called membercode.. and all members can members under them.. can make 2 members down to 1 member.. all members are added in same table named "tbMembers...

Connecting to SQL Server very slow.

I have a standard php app that uses SQL Server as the back-end database. There is a serious delay in response for each page I access. This is my development server, so its not an issue with the live setup, but it is really annoying for working on the system. I have a 5 - 8 second delay on each page. I am running SqlServer 2000 Develop...

check for value before

DECLARE @xVar XML SET @xVar = '<book genre="security" publicationdate="2002" ISBN="0-7356-1588-2"> <title>Writing Secure Code</title> <author> <firstname>Michael</firstname> <lastname>Howard</lastname> <age>25</age> <birthday>2010-05-17T00:00:00</birthday> </author> <author> <firstname></first...