sql-server-2005

SQL Profiler shows Exception when creating a stored procedure

Hello. I'm trying to trace sql events with sql profiler (2005). And I noticed that it shows an exception (Error: 2601, Severity: 14, State: 1) when altering a stored procedure even though there aren't any error. What might be the cause? Thank you for your help! ...

Count rows against to SQL server (2005) table?

I have a simple question with two options to get count of rows in a SQL server (2005). I am using VS 2005. There are two options to get the count: SELECT id FROM Table1 WHERE dt >= startDt AND dt < endDt;; I get a list of ids from above call in cache and then I get count by List.Count. Another option is SELECT COUNT(*) FROM Table1 W...

Aggregate survey results recursively by manager

I have a StaffLookup table which looks like this. UserSrn | UserName | ManagerSrn =============================== ABC1 | Jerome | NULL ABC2 | Joe | ABC1 ABC3 | Paul | ABC2 ABC4 | Jack | ABC3 ABC5 | Daniel | ABC3 ABC6 | David | ABC2 ABC7 | Ian | ABC6 ABC8 | Helen | ABC6 The staff stru...

How can an improvement to the query cache be tracked?

I am parameterizing my web app's ad hoc sql. As a result, I expect the query plan cache to reduce in size and have a higher hit ratio. Perhaps even other important metrics will be improved. Could I use perfmon to track this? If so, what counters should I use? If not perfmon, how could I report on the impact of this change? ...

Creating a Function in SQL Server with a Phone Number as a parameter and returns a Random Number

Hi Guys, I am hoping someone can help me here as google is not being as forthcoming as I would have liked. I am relatively new to SQL Server and so this is the first function I have set myself to do. The outline of the function is that it has a Phone number varchar(15) as a parameter, it checks that this number is a proper number, i.e....

updating changes from one database to another database in the same server

I have a copy of client database say 'DBCopy' which already contains modified data. The copy of the client database (DBCopy) is attached to the SQL Server where the Central Database (DBCentral) exists. Then I want to update whatever changes already present in DBCopy to DBCentral. Both DBCopy and DBCentral have same schema. How can i do ...

Efficiency of checking for null varbinary(max) column ?

Using SQL Server 2008. Example table : CREATE table dbo.blobtest (id int primary key not null, name nvarchar(200) not null, data varbinary(max) null) Example query : select id, name, cast((case when data is null then 0 else 1 end) as bit) as DataExists from dbo.blobtest Now, the query needs to return a "DataExists" column, t...

VSDBCMD deployment for additions to third party databases

We have some custom objects (stored procedures etc) in an SQL Server 2005 database belonging to an ERP system. The custom objects are in different schemas to the ERP objects. We're using Database Edition .dbproj projects and vsdbcmd deployment for all our custom application databases and would like to similarly manage our custom objects ...

How to change this mysql select into sql server select statement?

I use this mysql statement for concating description which has a length greater than 30.. select if (CHAR_LENGTH(description)>30,CONCAT(SUBSTRING(description,1,30), '.....'),description) as description from table How to change this mysql select into sql server select statement? ...

How to do a partial database backup and restore?

Simple problem. I'm working on a single SQL Server database which is shared between several offices. Each office has their own schema inside this database, thus dividing the database in logical pieces. (Plus one schema that is shared between multiple offices.) The database is stored on a dedicated server and we use a single database to k...

XML sitemap locking on database export

What would be the best approach for saving site categories from sql server 2005 db for use with menu control(asp.net 3.5)? I already have the full xml sitemap string from dataset.GetXml(), so I 'only' need to take care of writing the xml to the file and avoid locking it up because the whole site navigation depends on this sitemap. What h...

Physical size of MS SQL Table.

Hello, How to find what the physical size of table in MS Sql 2005? Is it possible using sql query or not? Thanks. ...

Insert Fails - Detailed Information

Hi, I am loading some data into a temp table. I then use a cursor to loop through the temp table, minipulate the data, and insert it into another table. The identity of the newly inserted record is then captured in a variable and inserted to another table to allow a look up of the newly inserted data. DECLARE c1 CURSOR READ_ONLY FO...

What happens to a SQL job if it doesn't finish?

Let's say there's a SQL job that runs a stored procedure every one minute. What happens, if it takes more than a minute? Does it start the procedure again (having 2 of them running in the same time) or it waits for the previous to finish? ...

How to create SSIS package to update from one database to another database within same server

My query is related to the answers i got for questions i had posted earlier in the same forum. I have a copy of a client database which is attached to SQL Server where the Central Database exists. The copy already contains the updated data. I just want to transfer the updates from that copy to Central Database both holding same schema an...

tsql source control help please

Hi All, According to the following section of BOL: How to: Use Source Control with SQL Server Management Studio If you have a source control client installed you should be able to choose it in the plug-in selection. I have both source control clients for Visual Studio 2005 and 2008 (tfs2005) installed and there's no plug-in to choose ...

How to sort a table with some fields positioned according to my conditions

I want to sort a table in sql server. Condition that i need to fulfill is this I have a table that has some records in it like this Select One None Child Old Neutral .. .. .. i want it to be sorted in such a way that Select One comes up and None comes at the end and remaining gets sorted alphabetically. Select One Child Neutral Old ....

execute stored procedure as another user premission

Hello. I faced the following problem: there's a user who has to execute a stored porcedure (spTest). In spTest's body sp_trace_generateevent is called. sp_trace_generateevent requires alter trace permissions and I don't want user to have it. So I would like user to be able to execute spTest. How can I do that? Thank you for your help. ...

Strange Sql Server 2005 behavior

Background: I have a site built in ASP.NET with Sql Server 2005 as it's database. The site is the only site on a Windows Server 2003 box sitting in my clients server room. The client is a local school district, so for data security reasons there is no remote desktop access and no remote Sql Server connection, so if I have to service the...

How to count two fields by using Select statement in SQL Server 2005?

Total records in table are 10. Select count(ID) from table1 where col1 = 1 (Result is 8) Select count(ID) from table1 where col1 = 0 (Result is 2) So its a same table but count is based on different condition. How am i gonna get two results (counts) using one select statement? Also Performance is a big concern here. PS: I am using ...