sql-server-2005

How to get results from OSQL.exe without dash characters from the command line?

Is there a way to send a osql query from the command line that returns results that do not include the big long line of dash characters that represent the column width? Here is the sample code I am working with: echo. "%PROGRAMFILES%\Microsoft SQL Server\%SQLVER%\Tools\BINN\osql" -S . -E -Q "SELECT name + ', ' FROM sysdatabases order b...

Cannot create sql server replication subscription due to timestamps and queued transactions, but that's not right

In Sql Server 2005, we have a publication of a few tables. This publication has 3 push subscriptions to DB2 databases (using connector from HIS2009) and has had for several months. Attempting to add another subscription, virtually identical to the existing ones except it's a distinct server, we get: SQL Server could not create a subscri...

Updating table based on 2 tables with RowID is as commonality

Hi there I have a table like this: RowID; ListDescription1; ListNormalisedDescription1; 1 XXXX YYYY NULL 2 ZZZZZ NULL I made a complex transformation/normalisation (removing spaces, replacing space and split) and manage to make the same data turning into: RowID; NormalisedItemDescrption1; 1 XXXX 1 ...

SQL query to find where no primary key exists

Hi I have re-added a foreign key relationship to a table in order to do so I had to abandon checking data on creation. I presume some parent(Company) objects have been deleted and I want to find the orphaned(Division) records. How would I find an row where the foreign key does not exist in the primary table? This is what I was thinking ...

SQL Server 2005 One query to calculation two table

Hello everyone, I'm beginner in SQL Server I have three tables in Database hospital PatientFiles OtherServices PatientDeposit Two queries to display my result Query Number One. Display PatientFilesID, TotalOtherServices SELECT pf.ID AS PatientFileID, SUM(os.Quantum * os.Price) AS TotalOtherServices FROM PatientsFiles pf INNER ...

Define Failover SQL Server

Hi, We are begining to test some BC solution's for our SQL Server DB's, we have decided that where possible we will use DB Mirroring and for all other less critical or where DB mirroring is not possible to use log shipping. I have setup two test SQL Servers to test log shipping to be able to document procedures, and also to establish w...

SQLSERVER mirroring VS Log shipping

Hello, I need some help understanding mirroring for the follwoing example. primary server in FL Mirror server in germany My application is doing an insert into the table for the FL system CASE 1 : The mirror server is down -- network issue -- I assume that the insert will be written to the Transaction log on the principal -- It ...

Sqlserver automatically hangs , but when service restart Its working fine.......

I am using Asp.net and Sql Server 2005 express edition ,server is automatically hangs up , if i restart the sql service the application is much faster than expecting ,Few days back this problem is occured .My Project is in live iam unable to understand why these problem raised Please help me out of this situation…… Thanxs in advance ...

Update database n:n

I have two classes: public class RichMan { public string ID {get;set;} List<Car> _cars=new List<Car>(); { public List<Car> Cars { get { return this._cars; } set { this._cars = value; NotifyChanged("Ema...

SQL Server Developer

I have got one offer from MNC company for the post of SQL Server Developer. As such i am a programmer (in .net and SQL Server as back end).To crack the interview what topics i need to be aware of? (as there would be a difference in MS SQL used by programmer and a MS SQL Developer) Thanks! ...

Does SQL Server automatically discard unnecessary joins?

If I submit a query to SQL Server 2005 which contains a number of LEFT JOIN clauses where the table joined to is then never referenced, will the joins still happen or is SQL Server intelligent enough to discard them? Obviously it wouldn't be able to discard INNER JOINs [false assumption! see answers] as that would potentially change the...

Error using osql.exe (Sql Server 2005)

I use sql server 2005 enterprise, windows server 2003. I try execute osql.exe command, for execute sql file in my server DESSQL: osql.exe -E -n-1 -i"CarpetaUno\TextFile1.sql" I get this error: Msg 102, Level 15, State 1, Server DESSQL, Line 1 Incorrect syntax near 'n' UPDATE: I try this too, osql.exe -E -i"CarpetaUno\TextFile1.s...

UPDATE column from another column two tables away

Not that good with SQL yet but I'm learning. So I have 3 tables: tblOne(Id, Type) tblTemp1(Name, Type) tblTemp2(Id, Name) Basically, I want to update tblOne where the where it's 'Id' matches from tblTemp2, but than that also goes and grabs its 'Type' from tblTemp1 where the 'Name' matches. Can anyone help? ...

generate schemas for sql 2008 xml bulk load

hey guys i have to import large sized xml data files (some of them 500 mb in size) into sql 2008. i plan to use sqlxml bulk load for the same. however i am only interested in certain elements of the xml data file, not each and every element. my question is: in the schema file do i need to mention each and every element present in the xm...

Finding drop off rate from membership table in SQL Server 2005

We have a view that stores the history of membership plans held by our members and we have been running a half price direct debit offer for some time. We've been asked to report on whether people are allowing the direct debit to renew (at full price) but I'm no SQL expert! The view in effect is memberRef, historyRef, validFrom, validTo...

Practice SQL Queries

Hi I wanted a website that has ample amount of SQL (SQL Server 2005 or 2008) related queries to practice at home Please let me know if you have any idea about the same. thanks ...

Setting a password for a DB in SQL 2005

I am writing a program in VS 2005 and I wanna control the access to one of the DBs in SQL Server 2005 (Express) I mean, I do not like let other applications to connect to this server an access the data in this DB. What can I do? ...

Datetime pattern for yyyy.mm.dd.hh.mm.ss pattern code?

What is the DATE FORMAT CODE for "yyyy.mm.dd.hh.mm.ss"? I know that 34 (date format code) is "yyyymmddhhmmss", but what about the code for "yyyy.mm.dd.hh.mm.ss"? This is on SQL 2005. ...

Why doesn't prompt for input in a batch file allow for a DASH character?

I have this simple little batch file program that I wrote but it fails if I enter a database name that contains a "-" character. Im not exactly sure why but I wish I could figure out a way around this? :: open DB batch file @echo off :: starts Sql Server Management Studio Express 2005 :: and opens it to a specific database with query ...

Stored procedure, pass table name as a parameter

I have about half a dozen generic, but fairly complex stored procedures and functions that I would like to use in a more generic fashion. Ideally I'd like to be able to pass the table name as a parameter to the procedure, as currently it is hard coded. The research I have done suggests I need to convert all existing SQL within my proce...