sql-server

SQLCMD, when called from Powershell, returns ExitCode == 1, even if successful

Hi everyone. I have a Powershell script that calls sqlcmd to run a sql script that backs up a database: function RunSqlScriptWithErrorMessage { param([string]$sqlServer, [string]$sqlUserName, [string]$sqlPassword, [string]$scriptName, [string]$errorMessage) $commandName = "sqlcmd" $startInfo = New-Object Diagnostics.Proces...

Can Sql Server BULK INSERT read from a named pipe/fifo?

Is it possible for BULK INSERT/bcp to read from a named pipe, fifo-style? That is, rather than reading from a real text file, can BULK INSERT/bcp be made to read from a named pipe which is on the write end of another process? For example: create named pipe unzip file to named pipe read from named pipe with bcp or BULK INSERT or: ...

How to handle multiple rows in this Sql Server Trigger?

Hi folks, I have the following trigger, but because a trigger needs to handle multiple records, I'm not sure how to correctly handle this, in my trigger code. Can someone please suggest how I can change the TSql below to correctly handle multiple records, instead of just a single record (as is listed, below). Table Schema and defaults...

Linked Server related

I have two instances of SQL Server: Server1 (SQL Server 2008) Server2 (SQL Server 2005) I am executing a stored procedure from Server1 which references tables on Server2. It is working fine in my test environment: Server1 runs Vista SP2, SQL Server 2008; Server2 runs Windows XP SP2, SQL Server 2005. However, it is not working in...

Suggestions for SQL Server GUI?

I just downloaded SQL Server 2005 Express edition. I was hoping it would come with a GUI to let me design my tables and such, but it doesn't. I'm working with ColdFusion/CF Builder here, so I don't really want one that integrates into Visual Studio. Also, it would be helpful if it has the option to connect to a remote database too. Sugge...

Can't keep DataReader open and get new rows as they become available

I would like to be able to execute a query only once and keep the resulting DataReader open all the time to get new rows as they are added to the database table. Something like this: SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "select * from table"; using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SequentialA...

Does this Web App Server-Data Server configuration make sense on a cloud server?

I was planning to have my web application on one server instance, my sql (express) on another instance and a separate domain controller on another. The purpose to allow the asp.net application to access sql server under windows security. This is hosted on a cloud server. Am I getting any security benefit doing this considering its on t...

Querying NHibernate

Hi All, We are using NHibernate as our ORM for the project and we have only database read only feature. The application will not be updating,deleting or inserting any records into the database it will be just querying the database for records. My question is which is the best method to query the database with NHibernate in the scenari...

NHibernate Query Execution Plan?

HI all, How does NHibernate executes the queries? Does it manipulates the queries and uses some query optimization techniques? And what is the query execution plan followed by NHibernate? ...

Creating a table in SQL Server using SELECT ... INTO

Hi ... i am creating a table in sqlserver database using query like "SELECT Table1.* INTO Table2 FROM Table1" here Table2 created successfully but it is not showing my database when i again fire this query than it gives error that Table2 is already created but i can't see this in my database i am refreshing my database also so please...

connect sql server 2005/2008 over internet

How do I connect to SQL Server 2005/2008 using Management Studio or other desktop application over the internet? ...

IN Operator SQL

I have a table called NUMS with a single column n. And I fill values 1,2,3,4,5,null in it. Now a query SELECT n FROM Nums WHERE n IN (1, 2, null) In this case I guess it's converted to SELECT n FROM Nums Where n = 1 OR n = 2 OR n = null I am also comparing n with a null value which should yield unknown and it should r...

insert in dymanic update - linq to sql

I'm developing a dynamic data app, in which I'm trying perform insert RequestRevision during update of request (logging change of request, somthing like that) public partial class ProjectDataContext { partial void UpdateRequest(Request instance) { RequestRevision rv = new RequestRevision...

SQL Server: Copying table contents from one database to another

I want to update a static table on my local development database with current values from our server (accessed on a different network/domain via VPN). Using the Data Import/Export wizard would be my method of choice, however I typically run into one of two issues: I get primary key violation errors and the whole thing quits. This is ...

Question regarding getting exclusive access to SqlServer database for restoring

Here's my problem: I have an application which uses sql server express 2005, and it is installed under default sql server express instance, SQLExpress Under this instance there are several other databases, used by other applications (web based or desktop) If I need to restore the database, sometimes it works, but sometimes it fails, tell...

Make a one line data to a table in SQL

Hi all There is a record like SWD Lead QA Lead PD Lead Business Manager AAAA BBBB CCCC DDDD I want to use T-SQL to get a result like below with the column name SWD Lead AAAA QA Lead BBBB PD Lead CCCC Business Manager DDDD Does anyone know how to do it ? Best Regards, ...

Asynchronous sql queries using ADO

Is there a way to place a sql query and call a callback function in C++ when the results are ready? I know there is a way to do this in ado.net, but this is a native environment, so I can't use .net. ...

One Database with 20 million records or 51 databases with 50,000-300,000 records in each database?

I've bought a CSV United States business database with ~20 million records, which is divided to 51 databases, every database represents a state. I need to write an ASP.NET MVC Web Application that will query this database, by state and more arguments. Should I create a SQL Server database and import all the records in the all 51 csv fi...

Stored procedure output parameters in SQL Server Profiler

I've got a stored procedure with an int output parameter. If I run SQL Server Profiler, execute the stored procedure via some .Net code, and capture the RPC:Completed event, the TextData looks like this: declare @p1 int set @p1=13 exec spStoredProcedure @OutParam=@p1 output select @p1 Why does it look like it's getting the value of th...

SPROC hangs in SQL Server 2005

I get a problem with SQL Server 2005, where a stored procedure seems to randomly hang/lock, and never return any result. What the stored procedure does is to call a function, which in turn makes a union of two different functions – returning the same type of data, but from different criteria. Nothing advanced. I don’t think it’s the fu...