sql-server

Sql - format phone number

HI , i have table in the db with phone number column the numbers look like this 123456789 i want to format tham to 123-456-789 thanks!!! ...

How Do I create a log using performance monitor in SQL?

A company I deal with have their own server, and a couple of sites using SQL server 2005 on it. They are getting random, intermitten freezes and its pointing to SQL Server so the company who they got the server from said to "create a log using performance monitor in SQL" I have RD Access... Is this a simple setting I just need to put ...

Top tools for c#/sql developer.

I love resharper it makes refactoring other peoples code also most fun. www.jetbrains.com/resharper And ghost doc is another great tool. http://submain.com/GhostDoc I would love to use redgates sql prompt but my company wont pay for it ? so free tools are the best :) My question is what other great tool are in the c#/sql dev toolbar? ...

Taking incremental backups of SQL Server 2008 Database

We are building an ASP.NET application (with C#.net as language) and will be hosting on Windows Server 2003 Operating System with SQL Server 2008 as database. We are planning to take the incremental database backups to a disk and use them to restore whenever there is a necessity. So would you please guide me on this, if you have an ide...

Why does the SSIS Runtime fail to start the distributed transaction?

While creating an SSIS package for SQL Server 2008 i run into the following error: Error: The SSIS Runtime has failed to start the distributed transaction due to error 0x8004D01B "The Transaction Manager is not available.". The DTC transaction failed to start. This could occur because the MSDTC Service is not running. I...

Calculating ad impression rank

I am currently working on a database ad rotating system where some of the ads have higher impression (or rank) than others and should be shown more often. What is the best way for calculating the impression rank while still keeping the appearance of "random" ads? What would the table structure for the database look like? Should the cal...

SQL Server Syntax to select two rows of data and overwrite values that are different from the first row

Hi, I have a table that looks like the following: id, Name, LinkBackId, Param1, Param2, Param3 1, "Name1", NULL, 10, 20, 30 2, "Name2", NULL, 10, 20, 30 3, "Name3", 2, 14, NULL, NULL The LinkBackId is important here because this is associated with the id that is also in th...

insert data in increments

Does anyone know how to insert data into a table in increments of about 1000? I have a table with thousands of records that I want to insert into an identical table on a different server. ...

Compare dates in T-SQL, ignoring the time part

I'm using MS SQL 2005, and I want to check two dates for equality, but ignoring the time part. I know I can make use of DATEDIFF, but am concerned that it may be slow - this SP gets used in the DB a lot! Any suggestions? Edit: David Andres' comment: '"comparison" includes much more than equality' made me realise that I didn't make my...

SQL Server JDBC: unable to create new native thread

We are using Microsoft's sqljdbc driver 1.2 in combination with Hibernate under Windows. Occasionally we are getting an OutOfMemoryError from the JDBC driver although plenty of memory is still available in the JVM heap. Here's a stack trace of the exception we are getting: java.lang.OutOfMemoryError: unable to create new native thread ...

Get permissions for stored procedure in sql server 2005

How do I get the granted permissions for a stored procedure in sql server 2005? ...

SQL Server Bulk Insert fails (Network related)

I'm fairly new to SQL Server. I'm trying to bulk insert into a table, using the command in SQL Server Management Studio (2005): BULK INSERT Table1 FROM 'c:\text.txt' WITH (FIELDTERMINATOR = '|') I get the error: Msg 4860, Level 16, State 1, Line 1 Cannot bulk load. The file "c:\text.txt" does not exist. I'm positive the file actua...

SQL: What does =* mean?

I'm trying to trace some SQL in Microsoft Server. I came across a join that is using a convention unfamiliar to me. What does "=*" mean? WHERE table1.yr =* table2.yr -1 ...

How to escape a string for use with the LIKE operator in SQL Server?

I am looking for something that works in SQL Server similar to the @ symbol in c# which causes a string to be taken as it's literal. Eg: string text = "abcd\\efg"; Output of text = abcd\efg string text = @"abcd\\efg"; Output of text = abcd\\efg Note how the @ affected the string to take every character as is. Now I am not sure this...

Does JIRA work well with SQL Server 2008?

I'm evaluating JIRA for my work. The offical documentation says that it only supports SQL Server 2005. The sales person told me explicitly that 2008 is NOT fully supported. But we would like to use 2008 since we are standardizing on it. For JIRA users/admins, if you have deployed it with SQL Server 2008, have you encountered any issues?...

How can I effectively perform advanced processing on my DB?

I'm developing a timesheet application using SQL Server as my backend and I am trying to figure out the best way to handle implementing relatively complex processing logic in my DB for reporting purposes. I have a table (timesheet_entries) that is composed of the following fields: entry_id employee_id job_id job_state pto_code (this s...

SQL - Using Group By and Count to collect the total of unique two-field combinations

I have two fields (project and version) from two different tables, and I am trying to get the total of entries that match unique project/version combinations, however the versions in some projects match up with versions in other projects (Project 1 has version 1.0, and so does Project 2) so my SQL statement isn't working: SELECT TOP 100...

Is there a method to estimate the recovery time of a SQL Server 2005 database?

I am looking at a large-ish SQL Server 2005 database, that has entered into Recovery mode, and I am wondering if there is any way to estimate how long it's going to be until the database has recovered? ...

SQL Server XML output with CDATA

Is there a way to have an SQL Server XML return use CDATA? I have XML being returned by SQL Server like this: <locations> <site id="124"> <sitename>Texas A &amp; M</sitename> </site> </locations> When I am required to have this: <locations> <site id="124"> <sitename><![CDATA[Texas A & M]]></sitename> <...

Determining the primary and foreign table in a relationship?

When designing a database, what usually determines what tables will be the primary and foreign table in a relationship? For example, if I have a table called posts and it contains and id column postid and I have a table called comments and it contains a column called postid. Which of these tables would be the primary one in the relati...