SQL Server 2008 (major build version 10.00.xxxx). Please also tag with sql-server.

learn more… | top users | synonyms (2)

0
votes
2answers
52 views

RIGHT JOIN did not work as expected

I have a question about joining two tables. Schema CREATE TABLE [dbo].[DCString] ( [ID] [bigint] IDENTITY(1,1) NOT NULL, [DCDistributionBoxID] [bigint] NOT NULL, [CurrentMPP] ...
2
votes
1answer
87 views

Filtered Index hint rejected by SQL Server

I have a filtered non-clustered index that SQL Server is not using. I'm pretty sure the optimizer is doing the right choice but I would like to force it to run with that index so I can compare the ...
1
vote
1answer
43 views

How to SELECT a column in a row and return another row if it doesn't exists?

I want to write a query with two SELECT Statements in an order that if the first SELECT Statement doesn't return anything then only the second select statement runs. SELECT col1 FROM MyTable WHERE ...
2
votes
1answer
97 views

Efficient way to generate Time Slots for a schedule

I have a table named #MySchedule with columns StartTime, EndTime and duration. What I need is a query to get all time Slots for each row in MySchedule between these StartTime and EndTime based on ...
3
votes
1answer
92 views

Intermittent “Conversion failed…” error

I have several stored procedures. These procedures when called have been fully operational for over 18 months without error. Over the last 3-5 months, occasionally I will receive the error: ...
7
votes
1answer
475 views

How do I count the number of columns in each table?

I want to write a script to listing the tables in my database with the number of columns in that table. Like this: table name number --------- -------- table1 1 ...
0
votes
1answer
27 views

Alter Time of DateTime Field

I am needing to alter the time piece of a datetime field. I tried to use this syntax, but it gives me an error of Incorrect syntax near the keyword as What syntax can I use to alter the end ...
3
votes
2answers
76 views

Edit Application Name to Log Connection once for Logons on Pooled Connections

I am wondering if I can change the application name of a connection in SQL Server itself, e.g. in the logon trigger? Is that possible or is the application name "read only"? Edit to explain the ...
0
votes
1answer
75 views

Create Calculated Fields from Distinct Values in Second Table

I'm trying to create a report in Microsoft SQL Server Report Builder 3.0 that has a date field populated with dates for a specified year and alongside, calculated fields for each distinct error code ...
0
votes
0answers
39 views

Limit number of entries written by Logon-Trigger

We are auditing connections to our SQL server by using a logon trigger. (SQL Server 2008 Standard Edition.) However what we are seeing is that there are always a number of entries logged for each ...
0
votes
0answers
40 views

SQL Server 2008 Patch Installer shows incorrect information

When running the SQL Server 2008 SP3CU16, on one of our instances, the install seems to run through the wizard OK. However, the Setup Bootstrap log reports "The patch installer has failed to ...
0
votes
0answers
12 views

SQL server is replicating to wrong subscriber

I have a publication which is intended to push data to a subscriber over the internet from a remote server to our onsite local subscriber but it ends up on a wrong subscriber.Here is the scenario: ...
3
votes
1answer
20 views

Auto Increment Key Pair with Start Digit at 200000 SQL SERVER 2008

I'm currently rewriting a front end for a program that handles interviews. I want to prevent an issue the older program had were during the tiny amount of time it was doing a lookup for the next ...
0
votes
0answers
42 views

SQL server is replicating to wrong subscriber

I have a publication which is intended to push data to a subscriber over the internet from a remote server to our onsite local subscriber but it ends up on a wrong subscriber.Here is the scenario: ...
0
votes
0answers
15 views

Connecting database ISSUE to remote database in mssql [duplicate]

May be This question seems repeated but please read whole question carefully. I have Microsoft SQL Sever in one PC (ex. machine A) and I wants to connect and get data from that database from another ...
6
votes
2answers
163 views

Can't get databases or its objects with powershell

I have Powershell installed both in my server and development pc. In my dev machine apparently have a most recent version of PowerShell installed or some its components of SQL Server 'sqlps'. My ...
7
votes
4answers
531 views

In what cases a transaction can be committed from inside the CATCH block when XACT_ABORT is set to ON?

I've been reading MSDN about TRY...CATCH and XACT_STATE. It has the following example that uses XACT_STATE in the CATCH block of a TRY…CATCH construct to determine whether to commit or roll back a ...
1
vote
2answers
174 views

Which data type should I use to store a 11 digit number [closed]

Which data type I should use to store an 11 digit number? It must store '0' as the first digit. For example, if I store 02421402015, it must show 02421402015. I tried using varchar and it shows ...
0
votes
2answers
97 views

Concatenate column values [duplicate]

I have a query that uses a couple joins to get a name from another table. It works okay except that I would like to combine "Examiners Name" instead of having multiple duplicates: ID | Name ...
1
vote
1answer
87 views

SQL Server Import Export Wizard Error - Server throw Exception

I am trying to move all database tables from one db to another as a nightly job. The first (export) db is running sql server 2008 - SQL Server Authentication - I connect with SQL Server Native Client ...
5
votes
2answers
2k views

'CONCAT' is not a recognized built-in function name

A client reported that they were running on SQL Server 2012, and we delivered some test queries for testing prior to a final delivery, however: 'CONCAT' is not a recognized built-in function name. ...
0
votes
0answers
24 views

Count of application time outs in sql server

Can we get like below in sql server:
2
votes
1answer
39 views

String parsing: Extracting the filename from a URL

This is a link I have in a column of a table: http://earthexplorer.usgs.gov/browse/etm/1/11/2000/LE70010112000130KIS00.jpg There are like 1000's of rows like this. Is it possible to extract the ...
3
votes
0answers
57 views

SQL Server Incremental Backups Split

I am trying to recover a database where the incremental (log) backups are split between two methods (Carbonite/Zmanda and SQL .bak files). When I try to use the restore wizard I get the following ...
0
votes
1answer
41 views

Copy A Database

Is it possible to copy a SQL Server 2008 Express without launching SSMS? Little more back-story: my internal drive was removed and is now used as a USB drive (upgraded to a larger hard drive) and ...
-2
votes
3answers
61 views

Extract Portion From A Decimal [closed]

I need to extract any value > .5 from a decimal. Here is sample ddl Create Table #b ( fv decimal(16,4) fv1 decimal(16,4) ) Insert Into #b (fv) Values ('.8032') How can I capture the .3032 and ...
0
votes
1answer
123 views

Conversion failed when converting the varchar value 'Hours' to data type int

Conversion failed when converting the varchar value 'Hours' to data type int. This is my query: Sum(Cast(Cast(DATEDIFF(HH, ld_time_tracker_start_time, fld_time_tracker_end_time)%3600/60 As int) ...
0
votes
0answers
45 views

Query Freezes and SSMS Crashes

I feel like I have the syntax set on my query, but anytime I try to run this SSMS freezes and I have to reboot and once I get my PC back up and running no records have been updated. The table only ...
4
votes
2answers
150 views

Users running expensive queries

I am currently monitoring the expensive queries from the activity monitor for SQL server. How do I see who is running the different queries?
2
votes
0answers
17 views

TLS 1.2 with SQL Server 2008 [duplicate]

I have a VM where I use SQL Server 2008 as a black-box data store for a product I work with. I'm being told by my IT police that my VM is not (or will not be) secure in a short time unless I can ...
1
vote
3answers
460 views

Using Echo statement writes Echo is ON in the text file

Following code is used for write a number in the text file but instead it is writing "Echo is ON" into the text file. SET @CMD = 'ECHO '+@Ver+'>'+@Vercheck Print @CMD EXEC xp_cmdshell ...
2
votes
0answers
47 views

Max Degree of Parallelism for SQL Server 2008

Microsoft have recommendations around setting MAXDOP on various versions of SQL Server, but this (old) article raises some issues and recommends setting MAXDOP = 1 generally for SQL Server 2005 and ...
3
votes
1answer
30 views

Split Field Every 1K Characters

I have a field that can hold up to 3000 characters. I need to split this field into 3 individual fields split1, split2, split3, I have successfully been able to figure out how to get the beginning, ...
1
vote
2answers
98 views

Format Phone Numbers In SQL Server

I am using SQL Server 2008 and I found this solution which is only for SQL Server 2012 - what is the equivelant to format a phone number in SQL Server 2008? FORMAT([PhoneField],'###-###-####')
2
votes
1answer
54 views

Check 1 Table If No Data Check Second Table

I am passing into a stored procedure two variables @begindate & @enddate. I need to check firsttabletocheck and get a count of where csdate is between @begindate and @enddate. I then need to ...
0
votes
1answer
24 views

Accessing Registered Servers over Excel

With DBs in different countries, different servers but same structure, I have created registered server to access them when running certain queries for reports on SSMS. Thus far this is ok. However, I ...
0
votes
2answers
70 views

A simple Query causing high CPU in SQL Server 2008

We are noticing below SQL is causing very High CPU and its been executed 10,000 times. Is there a way we can tune this T-sql? SELECT ISNULL(max(trans_seq),0) +1 FROM inv_inventory_journal WHERE ...
10
votes
1answer
164 views

Why would suser_name() not reflect an AD account name change?

One of our users' names was legally changed, so we changed their Active Directory username to match - from domain\oldname to domain\newname. However, when suser_sname() is called by this user in a ...
1
vote
1answer
30 views

Find insert/update/delete queries that reference a partitioned view

I have just given a SQL Server with performance problems. The database is very large and use distributed views with a very large primary clustered key. (24 bytes). I would like to change this primary ...
0
votes
0answers
30 views

Replication jobs using proxy

I wanted to use a proxy account for replication agent checkup job on SQL Server 2012. This proxy works for other jobs. I got the following error: Executed as user: SQLUserID. Only members of the ...
1
vote
1answer
80 views

How to increase performance of UPDATE of ~ 50.000.000 entries

We have a query that uses a temporary table to update certain columns in the database: CREATE TABLE #NEW_OLD ( NEW nvarchar(20), OLD nvarchar(20) ); INSERT INTO #NEW_OLD VALUES ...
0
votes
2answers
254 views

Sql getting debit, credit and balance issue

I am using the query below to get Debit/Credit Balance from table statement SELECT t.[InvoiceID], t.S_Type as Type, t.Date, t.Debit, t.Credit, b.Balance FROM Statement as t CROSS apply ...
1
vote
1answer
44 views

Update Int Field [closed]

Why is my table not getting updated? For example, if I run this statement alone, I have a value of 6 returned Select COUNT(*) from #madeupland where SOapproved IS NULL however, when it is run ...
3
votes
2answers
327 views

Is there a Maintenance Plan that checks my database for corruption?

Is there any way to make a maintenance plan check all my databases on a single instance? Is the maintenance plan Check Database Integrity Task enough ?
0
votes
1answer
49 views

How can copy one column data of one table1 into other table2 column and other clumns table2 empty?

Here is my problem.I have two tables Stdd and result. stdd columns: id fname lname gender phonenum city result columns: physics chem math english urdu bio total id I want that in result table ...
6
votes
4answers
373 views

Multiple column concatenation

How to concatenate multiple columns in to a single row? For example: id name car 1 sam dodge 1 ram maserati 1 john benz 1 NULL mazda 2 kirk lexus 2 Jim ...
1
vote
1answer
40 views

SQL query for SQL Server backups [closed]

I found that SQL query for MS SQL server 2008 to display backups. SELECT D.name ,ISNULL(CONVERT(VARCHAR,backup_start_date),'No backups') AS last_backup_time ...
3
votes
1answer
93 views

Aggregation GROUP BY bottleneck

I have a performance bottleneck with a SELECT GROUP BY operation. Schema I have a table like this: CREATE TABLE [InverterData]( [InverterID] [bigint] NOT NULL, [TimeStamp] [datetime] NOT ...
3
votes
2answers
87 views

Is it safe to add new features to production SQL Server Instance

I need to add Integration Services Catalogs to our production instance of SQL Server 2008 in order to automate some SSIS packages. It wasn't included in the original installation 5 or 6 years ago. ...
13
votes
1answer
207 views

Massive INSERTs blocking SELECTs

I have a problem with a massive amount of INSERTs that are blocking my SELECT operations. Schema I have a table like this: CREATE TABLE [InverterData]( [InverterID] [bigint] NOT NULL, ...