sql-server-2005

How do i rename the table name using SQL query?

I Used the following syntax but I couldn't find the rename keyword in SQL server 2005. Alter table Stu_Table rename to Stu_Table_10 Please help me in renaming the table name using a query statement. ...

how to get top ten result in sql?

This delow query give me some error: declare @date1 nvarchar(100) , @date2 nvarchar(100) select @date1='2009-04-20', @date2='2009-05-20' select top 10 t.VisitingCount , t.Page from ( select Count(Page) as VisitingCount,Page from scr_SecuristLog where Date between @date1 and @date2 ...

How to find sql2000 databases info using Sqlserver SMO

Hi How to Find sqlserver2000 databases info using SQLSERVER-SMO ...

database in App_Data not persisting data

I have a a sql database in my app_data folder and my connection string looks like this: Server=.\SQLExpress;AttachDbFilename=|DataDirectory|wikipediamaze.mdf; Trusted_Connection=Yes; I'm using Fluent Nhibernate, and everything is mapped properly. I'm able to connect to the database fine and even update and insert rows with no problem. ...

Any better ways to ascertain whether a column in a table is empty or not?

Hi I have a table say T in SQL Server 2005 database and it has two columns say A and B, which more often than not won't have any values in them. How to check whether A and B are empty (has all zero length strings) or not? I have this naive way of doing it - select count(*) as A_count from T where A <> '' Let's assume A has data typ...

What's the best way to update data in a table while it's in use without locking the table?

I have a table in a SQL Server 2005 Database that is used a lot. It has our product on hand availability information. We get updates every hour from our warehouse and for the past few years we've been running a routine that truncates the table and updates the information. This only takes a few seconds and has not been a problem, until no...

Class is not found in SQL assembly

Hello, I am trying to make my first CLR Assembly\stored procedure. I have compiled the code using CSC, and added the assembly to SQL server. The assembly shows up, but the class seems to be missing. C# CODE using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; usin...

How do I view the SSIS packages in SQL Server Management Studio?

Argh! I created an SSIS package via an Import Wizard and I can't find the SSIS packages on the server using Management Studio. Execute an SSIS package doesn't appear as an option when I go into job scheduler, either. ...

uninstall sql server 2005 instance with database issues

On a non-production machine, I have two instances of SQL Server 2005. I want to uninstall the second instance, but I have two problems. Although this is a non-production machine, I want to be sure to keep the first instance safe so that I don't have to re-build anything. I have had the second instance off for a month. When I started ins...

What is the difference between the two sql statements?

Good Day All we are trying to do is inside a trigger make sure the user is not inserting two fees that have 'alone' in the name. Those fees need to be handled individually. For some reason, it appears the top section of sql quit working two weeks ago. To get around it I recoded it the second way and get the correct results. What I...

Send email for each row in a result set

I'd like to send an email for each row of a result set using sp_send_dbmail. What is the appropriate way to accomplish this without using loops? Edit: I'm not insisting a loop is not proper here, but is there a set based way to do this. I've tried creating a function, but a function cannot call a stored proc inside it. Only anoth...

INNER and LEFT OUTER join help

Say I have 3 tables. TableA, TableB, TableC I need to operate the recordset that is available after a INNER JOIN. Set 1 -> TableA INNER JOIN TableB Set 2 -> TableC INNER JOIN TableB I need the Set 1 irrespective of if Set 2 is empty or not (LEFT OUTER JOIN) comes to mind. So essentially, I am trying to write a query and have come th...

SQL Server datetime data type does not allow many formats

Hi I have a table in SQL Server 2005 which has a date time field. I want to save the date time value in mm/dd/yyyy hh:mm:ss format, but I guess SQL Server allows date time in yyyy-mm-dd HH:mm:ss.ll format. I can save date time value in mm/dd/yyyy hh:mm:ss format as a varchar, but that defeats my intention of sorting the table on that d...

SQL Server 2005 - If condition with union

Hello, I have a SP that has the following algorithm. IF <SomeCondition> BEGIN SELECT * FROM TABLE1 END ELSE BEGIN SELECT * FROM TABLE2 END --Union the above with the query below UNION SELECT * FROM TABLE3 The recordset returned is EXACTLY the same. I need to do a UNION of that resultset and another query. Is there a way to do ...

What is the best way to profile SQL Server 2005 Express?

Would like to see the incoming queries in SQL server 2005 express. What should I use? ...

SQL 2005 express with 2008 express compatibility

I installed VS 2008 without SQL 2005, then I installed SQL 2008, then I needed 2005 express so I reinstalled VS checking the SQL feature. The installation went OK, however I still cannot open mdf files from VS. I think there is no 2005v instance installed. When I dbl-click an mdf file in VS I get the following message: Connections to SQ...

How to update a datawarehouse after migrating to sql2005 from sql2000

Hi Guys, I apologise for asking basic questions but I'm new to Analysis Services and dimensional data. My current situation is, I have a sql server2000 database with a warehouse which was built by a previous developer. The warehouse and the transactional DB are on the same physical server. The warehouse is filled nightly by stored proce...

Is there any known issues with using linked servers between 64bit sqlserver2005 and 32bit sql2000

I seem to have problem getting linked servers working to query between database/servers running sql2000 32bit and 64bit sql2005. Is this a known bug? If so, is there a workaround, or fix? ...

Fastest way to check date range...

I store events in SQLServer 2005 where the time the event occured is important and must be stored in the datebase. What is the fastest way to write the date range check in the where clause to ensure everything on that day is selected? Currently when @DateStart and @DateEnd are passed in I set @DateStart to midnight and set @DateEnd to t...

How to run SQL Server Management Studio without loading Add-Ins

I have recently installed an Add-in for SQL Management Studio for intelisense/refactoring. It has caused my Management Studio to perform so slow that it is unusable. I have uninstalled the product, but it still appears to have affect Management Studio. Is it possible to run without any Add-ins enabled? ...