sql-server-2005

SQL server for an oracle developer/dba

I have a few years experience developing with oracle and have now moved to a place where they use SQL server (2005). Where would be a good place to learn things like SQL Server query optimisation, basic dba stuff and sql server gotchas for someone with my background. Thanks! ...

sql server 2005 xml update query chinese characters

Hi I am trying to update the value of a tag with Chinese characters. However it does not add the chinese characters. Instead it adds "???" . e.g. update table set col.modify('replace value of (/tag/text())[1] with "我"') where .. Any help is much appreciated thanks Ben ...

There are spatial data features for MS Sql Server 2005?

I wonder if there is any optimization I can do to achieve faster SELECTs for spatial data without moving to SQL SERVER 2008. There is for SQL Server 2005, natively or through plugins, any of the features below? Spatial field types Spatial indexes Arcsin math function for surface distance calculation on a sphere (Earth) ...

Keyboard shortcut for "Connect to Server" in Management Studio

Is there a keyboard shortcut for the "Connect to Server" modal window in Microsoft SQL Server Server Management Studio? The modal window that is displayed when you first opened up SQL Server Management Studio from the Start Menu or shortcut. ...

raiseerror sql server silent message

How can I use ROLLBACK TRANS inside a SQL Server trigger without getting the standard message ? "Msg 3609, Level 16, State 1, Line 1 The transaction ended in the trigger. The batch has been aborted." This is being returned to the client. I would like the ROLLBACK to complete silently. I need to achieve this within the trigger only; i.e...

SQLCMD, command-line variables and script :setvar

When running SQLCMD.exe and providing command-line arguments for scripting variables, I expect that the values provided on the command-line will override those defined in the SQL script file. e.g. Given the following SQL Script: :setvar XXX "SQL script" print '$(XXX)' And the command line: sqlcmd.exe -S <Server> -d <Database> -E -b...

why I cannot drop procedure from different schema using drop procedure statement in sql server 2005

As simple as it is : drop procedure schemaName.procName Gets the following error msg: Msg 3701, Level 11, State 5, Line 2 Cannot drop the procedure 'procName', because it does not exist or you do not have permission. Edit: I tried also using Sql based authentication - still does not work Strange that I am able to drop the proced...

SQL Server 2005/8 Query Optimisation Hints

I'm looking at educating a team on writing better SQL Server queries and was wondering what people's best hints were for improving performance. For instance I once had a DBA who insisted that count(*) would perform worse than count(1) (I have no idea whether she was right or whether it's still valid against the latest query optimisers)....

sql server 2005 question

hi I need to work with sql server 2005, I need server and developer tools. my database contain 2 million records, 20 tables and 30 users. what version of sql server 2005 I need ? ...

Restrictions on a Log Shipped database

In SQL 2005, what are the things that you should not do to a database that has Log Shipping enabled (and that runs under the Full Recovery Model)? I gather that scheduling additional Transaction Log backups to a different location will break the log shipping (because the full log chain is no longer reaching the secondary server). I al...

How can I parse dynamic SQL before execution in T-SQL?

I'd need to know how to parse a query to know if it is well build before executing it. If the parsing is correct then execute it, if not discard it. I haven't been able to accomplish this using SET NOEXEC, SET PARSEONLY, TRY/CATCH. I m using dynamic sql inside a loop. Sometimes the dynamic sql is incorrect not for my fault but for the ...

Finding out which locks that are acquired in a query on SQL Server?

I have a SQL statement from my application. I'd like to know which locks that statement acquires; how can I do that with SQL server? The statement has been involved in a deadlock, which I'm trying to analyze; I cannot reproduce the deadlock. I'm running on MS SQL Server 2005. ...

SQL Dynamic DatePart when using DateDiff

Is there a way to pass the DatePart parameter of DateDiff as a variable? So that I can write code that is similar to this? DECLARE @datePart VARCHAR(2) DECLARE @dateParameter INT SELECT @datePart = 'dd' SELECT @dateParameter = 28 SELECT * FROM MyTable WHERE DATEDIFF(@datePart, MyTable.MyDate, GETDATE()) < @dateParameter The only ...

Sql Server 2005 SSIS/Agent - Query status of a job

Is there a way to query the current status (executing, idle, etc) and the last result (successfull, failed, etc), and the last run time for a specific job name? The end result I am looking for is being able to display this information in an internal web application for various SSIS packages. ...

How to Add Nonrecorded Time Gab in recorded timeGap? How to create tihs method?

CREATE procedure sp_ActivityFrequencyOneUserGraph ( @date1 nvarchar(100) , @date2 nvarchar(100), @customerID int, @user int, @type nvarchar(50) ) as select Count(Page) as VisitingCount,[Time] from ( SELECT Page,Date,[user], ...

Asp.Net Gives a Timeout Error While Running a Stored Procedure

Hello Friends, I am using asp.net, .NET 3.5, C#, and SQL Server Express 2005. I have created a stored procedure in SQL, and when I run SP from SQL server it takes less than 1 second to return results. I have also tried that query in query analyzer and it also gives me results in less than 1 second. But when I try to call this SP from ...

SQL 2005 Reporting Services if check for null

In SSRS 2005 I have a table with a dataset linked to it. I want to check if the value of a field is null and if it is not null then format the data to make sure it has one decimal place and add a % sign etc. This is my expression on the field/column: =iif(IsNothing(Fields!COL01.Value), "" ,Format(CDbl(Trim(Replace(Fields!COL01.Value, ...

ORM and database indexes

What approach do you have towards creating and maintaining database indexes when using ORM such as NHibernate/Hibernate. Since the ORM is generating the queries, are there any tools you could recommend that could analyze query plans of those and suggest the kind of indexes that should be created? My current approach is ... wait until...

get the position of a value in a column

How do I get the position of a given value inside a table column. I need to get the column number. ...

how to convert nvarchar to time ,not datetime ?

DECLARE @DateNow smalldatetime SET @DateNow='12:30' select @DateNow -------------------------------------OR-------------------------------------- select CAST( '12:30' as datetime ) Result: 1900-01-01 12:30:00.000 (i don't want this) But i need this result in time format not string not datetime? Result: 12:30 (i want this) ...