sql-server

Pivot Queries in a UNION

Pivon queries, love em. Turn rows into columns. I need to do a pivot query on the union of 3 other queries. How do I structure this? I already know the names of the fields in the rows I want to transform but where do I put the pivot statement so it works? ...

Handling datetime with bcp and format file

I'm using bcp to import a flat file into an SQL Server 2005 database. I'm running into a problem with datetime fields. My format file field is specified as: <COLUMN SOURCE="15" NAME="DATEOFSERVICE" xsi:type="SQLDATETIME"/> My data file has dates formatted as: 19820101 However, some (many) are filled with 00000000 The 00000000 date...

How to create a search engine with filters?

I'm trying to create an online search for a particular set of literature/quotes/etc from a spiritual organization, and while the number of items (mostly PDF, HTML, or plain text) that can be searched is limited, I wanted to provide comprehensive search filters (Kayak.com style). That means my data will need to be organized in such a ...

Updating a table with missing records from another table

Hi, I am running a query that returns records from the LEFT of the EXCEPT that are not on the right query; USE AdventureWorks; GO SELECT ProductID FROM Production.Product EXCEPT SELECT ProductID FROM Production.WorkOrder; Lets say there are 6 records returned (there are 6 records in Production.Product table, that are not in Producti...

How do you set autocommit in an SQL Server session?

How do you set autocommit in an SQL Server session? ...

IN SSMS how do I script a stored proc with a Drop Section and a Create Section?

For our deployments, I just want to drop the existing stored proc, then re-create in the same script. The script wizard only seeems to give me a mutually exclusive option - I'm looking for a Drop-Then Create Option. Am I missing something? ...

Can't import as null value SQL Server 2008 TSV file

I import data from a TSV file with SQL Server 2008. null is replaced by 0 when I confirm a table after import with integer column. How to import as null, please Help me!! ...

SQLServer2000 Constraints

Is there any way to remove all forgeinKey and primary key contriants from Database ? ...

A 99.99 numeric from flat file doesn't want to go in a NUMERIC(4,2)'SQL Server

I have a csv file : 1|1.25 2|23.56 3|58.99 I want to put this value in a SQL Server table with SSIS. I have created my table : CREATE TABLE myTable( ID int, Value numeric(4,2)); My problem is that I have to create a Derived Column Transformation to specify my cast : (DT_NUMERIC,4,2)(REPLACE(Value,".",",")) Otherwise, SSIS don't ...

Using Visual Studio to create a more complex setup project.

I need to learn more about creating setup projects from within Visual Studio to support the following scenario: When the user starts the setup, he needs to choose between the parts that he wants to set up. The setup should offer to install three web services, one web site and maybe even run some SQL scripts to install/update the database...

Jobs to improve database availablity and performance

can anyone suggest Jobs that will improve database availablity and performance in sql server 2008? ...

[LAZARUS] Access Remote SQL Server Database on WinCE programming

I'm programming using Lazarus (Freepascal IDE, Delphi Like), and i have a problem when i need to connect into a remote SQL Server database on the network. My question: Is there any way to connect to a remote SQLdb on Lazarus? What is required connector type for SQL Server 2005? Is there any ODBC driver available for Windows CE (Window...

Cross Database SQL Scripts

I'm working on a project where we talk directly from one database to another. We have a master database where the client updates their website and then changes are pushed from one database to the other through numerous SQL scripts. The master database works as a preview site allowing them to see changes before pushing them to live. At t...

Alter column charset and collation MS SQL 2005

Can I alter a column charset and collation in MS SQL 2005 for a specific column without changing the collation of the entire database. I just need it for one column (or table) I know this can be done in MySQL with a simple "ALTER TABLE" query, but in MS SQL..? Regards /C ...

Scripting your database first versus building the database via SQL Server Management Studio and then generating the script

I had a (friendly but heated) argument with my lead developer the other day because our project has TSQL Scripts that I code directly into SQL files which I then run against the database. I find that when I do this, it's easy to work out the schema in advance without fiddly pointing and clicking and then there's no opportunity to forget ...

How to rebuild full-text index?

Got a requirement to rebuild mssql full-text index. Problem is - i need to know exactly when job is done. Therefore - just calling: ALTER FULLTEXT CATALOG fooCatalog REBUILD WITH ACCENT_SENSITIVITY = OFF doesn't work or I'm doing something slightly wrong. :/ Any ideas? ...

MSSS Management Studio Object Explorer changes from 2005 to 2008

I'm connecting to a database server (MSSS 2005, 9.0 SP2) which is almost totally without my control. If I connect to it using Management Studio 2005 I can browse the list of tables, views, other objects in some of the databases using object explorer. If I connect to it using Management Studio 2008, I cannot see the list. I can write ...

Execute xp_cmdshell command as specific user

Hello, I would like to run xp_cmdshell (TSQL procedure) in order to mount a network drive and then access remotes mdb files. I am administrator on the MS SQL server and I have allowed xp_cmdshell execution accordingly. However, there is still a problem: When I call xp_cmdshell, the user executing the command is the SQL SysAdmin, i.e...

sql connnection, close as soon as possible - true for vb.net apps? or just asp.net

When writing apps with asp.net, which I do more of than vb.net apps, I have always followed the rule of opening a connection to the server, getting the data, and closing the connection as quickly as possible. This seems like a best practice. Is it equally important to do this on a client/server vb.net app? For example, if you had multip...

How can you cancel a SQL Server execution process programmatically

Let's say you have execute the following (long running) process from your code: int processID = DB.Execute(SQL); //some long running sql statement Is there a way to programatically call SQL Server to cancel the process if it is taking too long (kind of like hitting the "Stop" button in QueryAnalyzer)? //cancel the process if it is ta...