sql-server

SQL Server 2008 - Database Merger and Aliasing?

Suppose I have two SQL Server 2008 databases, A and B. They initially were created with the intention to be separate, but over time have grown to both have constant references (in sprocs, views, etc) to each other. It's gotten to the point that they're effectively just two halves of the same database. So, we're considering merging them....

Linq to SQl Stored Procedure Problem( it can't figure out the return type)

Hi I have this SP USE [Test] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[UsersInsert](@UpdatedProdData XML) AS INSERT INTO dbo.UserTable(UserId,UserName,LicenseId,Password,PasswordSalt,Email,IsApproved,IsLockedOut,CreateDate, LastLoginDate,LastLockOutDate,FailedPasswordAttempts,RoleId) ...

Using a table-value function inside a view in SQL Server

I have a table-value function that works correctly if I try the following query: SELECT * FROM dbo.GetScheduleForEmployee() AS schedule However if I try to create a view with that query I get a "too few parameters" error. Is there a limitation with table-value functions and views? ...

Invalid columns on trigger

I get the error invalid column media.user and tuid. Before running this i see that media.user does exist and i would think that the coalesce() as tuid would solve the tuid problem. Why are these columns invalid? CREATE TRIGGER media_comment_trig_0 ON media_comment AFTER INSERT AS INSERT INTO user_incoming_media_comments(recipie...

How to Compare two strings using a if in a stored procedure in sql server 2008?

I want to do something like this: declare @temp as varchar set @temp='Measure' if(@temp == 'Measure') Select Measure from Measuretable else Select OtherMeasure from Measuretable ...

Insert a Join Statement - (Insert Data to Multiple Tables) - C#/SQL/T-SQL/.NET

I have a Winform that has fields need to be filled by a user. All the fields doesn't belong to one table, the data will go to Customer table and CustomerPhone table, so i decided to do multiple inserts. I will insert appropriate data to CustomerPhone first then Insert the rest data to Customer table. Is it possible to Join an Insert OR ...

Deploying and calling SSIS package from .NET

I have a SSIS package that I plan to deploy on my SQL Server 2008 machine. I need to call this SSIS package remotely and synchronously from .NET. Obviously I need to pass parameters to this package as well. How could I do that? Thanks, Alex ...

Migrations for PostgreSQL

Red-Gate has very interesting in beta software (Sql Source Control) that is installing inside SSMS and can save schema iterations through commit button. I need the same feature for postgresql, the only way i found similar to this - is log_statement = ddl, but log need be transformed and saved properly to file and than commited. What is y...

Treating empty elements as nulls in SQL Server's OPENXML function

I have the following (highly simplified) XML document that I am reading into my database using the OPENXML function: <root> <row> <bar>123</bar> </row> <row> <bar>0</bar> </row> <row> <bar></bar> </row> </root> I am importing in into the database like so: insert into [Foo] ([bar]) s...

Questions About SQl BulkCopy

Hi I am wondering how can do a mass insert and bulk copy at the same time? I have 2 tables that should be affect by the bulk copy as they both depend on each other. So I want it that if while inserting table 1 a record dies it gets rolled back and table 2 never gets updated. Also if table 1 inserts good and table 2 an update fails tab...

Best naming for a column in a SQL Server table

Which of the following three options would you choose for a column name in a SQL Server table, and why? YearToDateWages YTDWages YtdWages Follow up: SSN Ssn SocialSecurityNumber ...

Transform Search String into FullText Compatible Search String?

I'm working with the fulltext search engine of MSSQL 2008 which expects a search string like this: ("keyword1" AND "keyword2*" OR "keyword3") My users are entering things like this: engine 2009 "san francisco" hotel december xyz stuff* "in miami" 1234 something or "something else" I'm trying to transform these into fulltext e...

Why do SQL connection leave parameters in?

While coding with sqlite everytime i always had the exact number of parameters and when i executed the query i always had 0 parameters after it. I kept using the cmd object and it worked fine. Now while porting to use sql server (2008) my SqlConnection has parameters left over from a successful command. Why? I seem to be able to create ...

DataWarehouse - What is a good definition?

Could someone give me a good, practical definition of what a data warehouse is? ...

Is adding indexes to a SQL Server ever a bad idea?

We have a mid-size SQL Server based application that has no indexes defined. Not even on the the identity columns. I suggested to our moderately expensive application consultant that perhaps we might get better performance (particularly as our database grows) by creating some indexes on appropriate fields, and he said: "Indexes will ...

Accessing Microsoft SQL Server from iPhone app

How do I go about doing this? ...

How to do a batch update?

Hi I am wondering is there a way to do batch updating? I am using ms sql server 2005. I saw away with the sqlDataAdaptor but it seems like you have to first the select statement with it, then fill some dataset and make changes to dataset. Now I am using linq to sql to do the select so I want to try to keep it that way. However it is t...

Session or Query

Should I store the user's ID, name & email address in a session variable or should I query for the user's user's ID, name & email address everytime i need to use it? ...

Problem with duplicates in a SQL Join

I have the following result set from a join of three tables, an articles table, a products table, an articles to products mapping table. I would like to have the results with duplicates removed similar to a select distinct on content id. Current result set: [ContendId] [Title] [productId] 1 article one 2 1 ...

Can I use TransactionScope to do distributed transaction?

Hi I have a MVC app that uses Linq2Sql to access a SQL DB. But I want create a distributed transaction to update another DB on different local server. I want to update both in a transaction. Can I just wrap logic in TransactionScope class??? Malcolm ...