sql-server-2005

How much size "Null" value takes in SQL Server

Hi, I am having a large table say 10 columns. 4 of them remains null most of the times. I have a query that does null value takes any size or no size in bytes. I read few articles some of them are saying : http://www.sql-server-citation.com/2009/12/common-mistakes-in-sql-server-part-4.html "There is a misconception that if we have the ...

Secure communication between linked SQL Servers

Is the data transferred between two SQL Servers protected (encrypted) by default? If not, is there a way to accomplish this? I have two SQL Server 2005 databases running on separate servers, separate machines, separate networks. How can I ensure that data transmitted from one server to another is secure? I have tried researching the su...

DateTime BETWEEN condition; cannot get correct answer in SQL Server

Declare @str DateTime, @End DateTime, @CatID Int Set @str = '24 Sep 2010 8:30 AM' Set @end = '24 Sep 2010 1:30 PM' Set @CatID = '3' Select b.ID, b.BookingID, Name, r.ResID, r.ResName , DATEADD(day, 0, DATEDIFF(day, 0, StrDate)) + DATEADD(day, 0 - DATEDIFF(day, 0, StrTime), StrTime) as StrDate , DATEADD(day, 0, DATEDIFF(day, 0, EndDat...

From where to learn the basics of Sql Server 2005

I am new to SQL Server 2005 and want to start from the basics with examples. Could anyone guide me how can I proceed. As my target is to learn Businness Intelligence[BI], what I need to concentrate to get the sufficient knowledge to walk into BI? ...

How to create a schema-bound function that counts nodes in an xml and then be able to persist this result in a column

I have an xml column and I want to persist a node count in it in an adjacent column. For example, in an xml given below, I have 3 nodes a and so I want to output it. The problem that I have, however, is that I can't manage to create a generic schema-bound function that would take @xml and @nodeName so as to return the count of a speci...

Facing error of "The default schema does not exist." when executing runtime query inside sp using exec()

Hi, i have made a runtime query inside a sp and am exceuting the query within the sp using exec(), but when creating the sp i am getting the error The default schema does not exist. The SP is: CREATE PROCEDURE MySP @tableName varchar(100) AS BEGIN SET NOCOUNT ON; declare @selectQuery varchar(MAX) set @selectQuery = 'se...

How to create a database snapshot in SQL Server with SSMS GUI, not SQL code

Hi, How to create a database snapshot in SQL Server with SSMS GUI? I can't find the menu of that action. Thanks. ...

Documetation of a table of database

Can anyone suggest me the right way to begin with the documentation of the table of database I am working on..What actually I need to show to the evaluator? ...

Select elements of child tables with a given property

I am really not good at sql, The problem is the following: I have a metadata table like this META: id(pk) prop1 prop2 1 'pr1' 'pr2' 2 'pr1' 'pr2' At the same time, I have many child tables which look something like this: TABLE1: metaID(fk-pk) indx(pk) active ... 1 1 1 ... ...

Show hexadecimal dump of string

Is there any way to obtain an hexadecimal dump of a string in SQL Server? It'd be useful to troubleshoot character set and collation issues. In MySQL you'd do SELECT HEX('€uro') and in Oracle you'd do SELECT DUMP('€uro') FROM DUAL. ...

Recursive query that returns itself and all of its descendants

My Table 'Levels' in a SQL Server 2005 database looks like this: LevelId Description ParentLevelId 0 Level_1 NULL 1 Level_2 0 2 Level_3 0 3 Level_4 1 4 Level_5 3 I now want to create a query that will produce a results set in which every level and all of i...

TSQL Is returning boolean is not possible ?

Can't i write something in TSQL declare @set1 int declare @set2 int set @set1=1 set @set2=2 select @set1 < @set2 by getting true as result? I Know i can use case when @set<@set then 'true' but can't i do by the way i have written above? ...

Using XPath/XQuery to create child nodes in a SQL column

I have a sql table with an xml column named CasingRules, which would contain data such as: <root> <Item> <RegularExpression>^Mc[A-Z,a-z]*</RegularExpression> <Format>ULU</Format> </Item> <Item> <RegularExpression>^Mac[A-Z,a-z]*</RegularExpression> <Format>ULLU</Format> </Item> </root> I'm trying to use MS SQL's...

T-SQL Pivot to display One Comment field per week

I've been asked to change a pivot query that currently displays a week ending date, category and hours by date for one week in a row. I've been asked to display a comment field at the end of the row and I can't figure out how to alter the query to do this. The table is structured like this Category Date Comments Hours test...

I Get a Weird Error while Deploying a SQL Server Report

When i attempt to deploy a SQL Server Report, i get the following error: An attempt has been made to use a data extension 'OLEDB-MD' that is either not registered for this report server or is not supported in this edition of Reporting Services. (rsDataExtensionNotFound) This error occurs only when i try to deploy a certain report. Rest...

How to read/write or copy/paste text file locally using Stored procedure?

Hi My Stored Procedure is using Bulk Insert Task. As per requirement of Bulk Insert, the text file should be on same server where database is. Now file is residing on another machine. But database server can access file using shared network drive. Now question is How my stored procedure can read or copy the file from network drive an...

Sql single index or multiple index

Let's say I have the Products table. On my UI, I allow the user to search by name, description, code The user can only search on criteria. Should I create an index for each criteria : name, description, code or create ONE single index for all 3? What will make you choose one versus the other? ...

Remove all but one duplicate rows where datetime column values are within seconds of each other?

Due to an error in the system a tracking log was firing repeatedly causing what should have been one log entry to actually be in the hundreds. This has been resolved but the data is still there and needs to be for reporting (I can't just deleted it all). However I only want ONE instance of the data. This is going to be tricky I think, he...

Update statement fails because I have a column named order

I am trying to run an update statement as follows... UPDATE tblDeductionSystem SET [ORDER] = [0RDER] + 6 WHERE [ORDER] >= 7 AND ScoringCriteriaTypeID = @CheerDeductionScoreSheetID Sql Server if giving me invalid column name ORDER. I thought if I delimited the reserved word with the square brackets this would work. ...

optimising sql select statement

Is there a way to fetch 4 million records from SQL Server 2005 in under 60 seconds? My table consists of 15 columns. Each has datatype of varchar(100) and there is no primary key. ...