sql-server-2005

To change date format in sql

hi guys, I have date in mm/dd/yyyy format in database.I want to display in form as dd/mm/yyyy. Can anybody help?I want to get time along with date. ...

SQL Server Stored Proc takes (much) longer to run than the same query executed from text in Management Studio

So here is a bit of a strange one... I have a stored proc that takes 40 seconds to run. I copy the contents of the stored proc to a new query window, change the 2 input parameters (which are both dates) so they are declared and set, and run the query. It is basically instant, sub 1 second execution. The only difference is the stored proc...

is any Header files provided by microsoft to work with SMO in c++

Hi Microsoft provided some header files for c++ to work with DMO. Likewise to work with SQLSMO in c++ is such type of any header files are provided??? using managed c++ code is the only way to work with SMO in c++?? Plz Help me.... ...

Grant permission to only a view

Hello everyone. I have one user in my database, and I want to grant to him permission to read only one view, nothing more, no tables, nothing. How can I do this? Thanks a lot. P.S.: I am using MS SQL Server 2005 ...

Count Query in SQL

Hi. I am using SQL 2005. Table one, LinkedDocumentFolderTable, contains the names and information about the folders that hold linked documents. Table two, LinkedDocumentTable, contains the information about the linked documents themselves. The two tables are linked by the LinkedDocumentFolderID. I need the LinkedDocumentFolderID, De...

SQL Server error handling: exceptions and the database-client contract

We’re a team of SQL Servers database developers. Our clients are a mixed bag of C#/ASP.NET, C# and Java web services, Java/Unix services and some Excel. Our client developers only use stored procedures that we provide and we expect that (where sensible, of course) they treat them like web service methods. Some our client developers don...

SSRS 2005: Change column display from item column value/one row to something else?

I have a table/dataset like: 1/1/2009 | Training 1 | Mike 1/1/2009 | Training 1 | Bill 1/1/2009 | Training 1 | Steve I would like to display as 1/1/2009 | Training 1 Mike, Bill, Steve The idea is that the resulting printed page space is not wasted by printing one column on most of the page down but shortening the space to either a...

ASP.NET Store uploaded file sql server table

How do you store a file that was uploaded by an ASP.net webform into a sql server 2005 varbinary(max) field? Here is what I have so far: protected void btnUpload_Click(object sender, EventArgs e) { for (int i = 0; i < Request.Files.Count; i++) { StoreFile(Request.Files[i]); } } private void StoreFile(HttpPostedFile...

Error regarding cursor in SQL

Hi guys, following is my stored procedure. It contains a subquery Select StartTime From DrTimings Where DrID = @DrID If this subquery returns more than one value, I get an error. Subquery returns multiple rows. I want to get each @StartTime and @EndTime in cursor. Means I want to "fetch next from Doctor into @StTime and @EndTime" C...

Asynchronous Triggers in SQL Server 2005/2008

I have triggers that manipulate and insert a lot of data into a Change tracking table for audit purposes on every insert, update and delete. This trigger does its job very well, in other words, we are able to log the desired oldvalues/newvalues as per the business requirements for every transaction. However in some cases where the sou...

How can I drop all the default constraints constraints on a table

Hi All, How can I drop all the default constraints belonging to a particular table in SQL 2005? ...

Deleting or not deleting rows in ssis package destination table

i used the import/export wizard in sql server 2005 management studio to export rows from an excel sheet to an sql table and checked the Do not delete rows in destination table option. I saved the export operation as a ssis package, and yes new rows are being appended to existing ones, but now i have a requirement to delete all rows in th...

SQL Server 2005 Replication, transactional with updateable subscription error

Several days ago i setup some replication for our SQL Server 2005 database, the type of replication was a transactional with updateable subscription. The replication are working fine, lately i test the upgradeable subscription feature by modifying 1 data on subscriber server but then the error was raise and data are not committed. The ...

How do I create unique constraint that also allows nulls in sql server

The question is quite simple, as the title. Added a column to table I want a unique constraint , the column will insert guids, but to allow for existing data before column was added I need to allow for nulls in the check ...

Difference between sp_spaceused and DataLength SQL Server

I have a table with single Row when i use SP_SpaceUsed N'<TableName>' it gives me data as 16 KB and when I use dataLength something like this:- select ClientID , (0 + isnull(datalength(ClientID), 1) + isnull(datalength(LeadID), 1) + isnull(datalength(Company_Name), 1) + isnull(datalength(Website), 1) + isnull(datalength(EmployeeC...

Storing Files in a different Database?

Is it a good idea to store files in a different SQL Server 2005 database "FileDb" and point to it (files) in the "AppDb" by "FileId". Please take in consideration that I have a dedicated server and I can create as many Sql Databases as I want. update: Which perform better single database or multiple databsae? ...

Is there a way to reset the IDENTIY column in sql server? and would this be a reason not to use an Identity Column?

I have a development database that has fees in it. It has a feeid, which is a unique key that is the identifier. The problem I run into is that the feeid/fee amount may not match when putting updating the table on a production server. This obviously could lead to some bad things happening, like overcharging for something or undercharg...

How do I change the owner of a SQL Server database?

When I accidentally click on the Database Diagrams tab, I get one of the following errors: Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the data...

Disconnected Data Windows Program using Sql Server Compact

I am going to need to create a small windows application that stores basic data about people. The requirements are: Recruiters go out into the field and gather demographic data about people they talk to. Recruiters return 'home' and contribute their gathered data into the main database (SQL Server 2005). This is the first time I hav...

Dynamic WHERE statement - SQL server 2005

I need to create a SQL statement that uses the LIKE keyword to filter the result set. Sometimes this value is NULL. What is the best way to implement in T-SQL? I am using SQL server 2005 ...