sql-server-2005

How do i call a stored procedure with parameters from c# code behind

I have created a stored procedure shown below ,how will i call this from c# code behind to get the result and results are stored in dataset. USE [Test] GO /****** Object: StoredProcedure [dbo].[tesproc] Script Date: 09/01/2010 13:00:54 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[tesproc] -- A...

SQL Server: COLLATE CS->CI performance vs UPPER

What's better to use when comparing columns that could contains values with different cases? Is Collate faster? Just trying to figure this out because in our project with tons of data comparisons. we use: select * from table t1, table t2 where t1.col1 collate SQL_Latin1_General_CP1_CI_AS = t2.colb collate SQL_Latin1_General_CP1_CI_AS ...

inner join Vs Function

Hi all, Which of the following query is better... This is just an example, there are numerous situations, where I want the user name to be displayed instead of UserID Select EmailDate, B.EmployeeName as [UserName], EmailSubject from Trn_Misc_Email as A inner join Mst_Users as B on A.CreatedUserID = B.EmployeeLog...

Invalid column name, on select-statement created columns

I have simplified my problem to the following select statement. select u.UserId, aVariable = cast((case when exists(select * from TblUser u where u.Disabled=1) then 1 else 0 end) as bit), from TblUser u where aVariable = 1 aVariable is not a column of a table, but just a column that gets a value in this select statement. Is ...

Error with calling stored procedure from C#

I have the following c# code to call stored procedure testproc, but when i run this application it displays saying that could not find stored procedure testproc, do i need to make any changes in syntax to call stored procedure. This is my c# code behind to call stored procedure SqlConnection con = new SqlConnection(); con.ConnectionStri...

Getting the parameter values being passed to SQL database via SQLDataSource control

I am debugging code written by a previous developer :-) I have a SQLDataSource control that is calling a database stored procedure, and passing quite a large number of paramaters, and the stored proc returns records that populates a gridview control. When I walk through the code behind to determine the values being passed, is ther...

Generating create table script (with indexes, keys, constrains) for all tables in SQL Server database

Hello. If I run the following script SELECT so.Name, sc.Text FROM syscomments sc JOIN sysobjects so ON sc.ID = so.ID I will get all the create procedure/function scripts. Is there something like this for tables, indexes, keys, and triggers? Thank you for your help! ...

How to make SqlConnection timeout more quickly

I am using an SQL connection string with SqlClient.SqlConnection and specifying Connection Timeout=5 in the string, but it still waits 30 seconds before returning failure. How do I make it give up and return faster? I'm on a fast local network and don't want to wait 30 seconds. The servers that are not turned on take 30 seconds to fai...

sql server - move tables from master to new database

In an attempt to move my DB to a new server I had to run the script from cmd prompt and forgot to assign the DB name and all my tables were created under master. Is it possible to move these tables to a different DB or do I need to rerun the script? ...

selecting data between a certain date range

Hi i have fromdate and todate ..How will i get data that falls in this range ?? ...

Tough SQL Update

2 databases QF AND TK QF has the following: Imagine you have a table called FunctionalGroup with this data: FunctionalGroupID | FunctionalGroup 1 Engineering 2 Purchasing And a table that was a set of login's with a functionalgroupID to reference the group the person is in... LoginID | Functio...

SQL Server: intrigued by GETDATE()

I have SQL Server 2005 Standard Service Pack 2 9.00.4053.00 (Intel X86) Table has close to 30 million rows.. If I do SELECT GETDATE(), * FROM <table> Identical Date and time value is returned including milliseconds part.. though query took more then 3 minutes to complete... I have already read http://sqlblog.com/blogs/andrew_k...

Is there significant overhead for PRINT statements in SQL Server 2005 Stored Procedures?

I noticed in a code review that one developer added PRINT statements throughout many SQL Server stored procedures. These stored procedures are executed from a ASP.NET website, using SqlClient. Is there any performance penalty to having these PRINT statement in the code? Or will they automatically be skipped when the procs are called fr...

SQL Server 2005 Alter Full text catalog not populating indexes

Hi I am rebuilding a full text catalog as follows: ALTER FULLTEXT CATALOG myCatalog REBUILD It is not populating my indexes. When i use the FULLTEXTCATALOGPROPERTY to check the properties I am getting the populating status always as 0 and the itemcount as 0. If i populate the index(which is a part of the catalog above) directly as fo...

Execute SQL Task on SSIS 2005. ADO.NET connection type and Stored Procedure Input Parameter. Not working. Syntax error

I am Execute SQL Task on SSIS 2005. ADO.NET connection type and Stored Procedure Input Parameter. Not working. Syntax error I read some documentation and blogs but its not working for me. This is what I have on SQL Statement of the Exeute sql task (ADO.NET) EXEC StoredProcedureName @ParameterName = It gives different errors on d...

sql 2005 xml passed to asp.net grid with date formating

i have sql that uses FOR XM RAW to generate xml for my asp.net application to use to bind grids to and things like this. the problem is that the date data is not taking the gridView formatting of the date because (and im taking a crack at this) the date value in the xml is a string and the formatting is not taking. any thoughts on how ...

Transfer column data from one database to another

Hello, I'm trying to transfer an entire column's worth of data from the backup database to the current production database (earlier in the day I had ruined this column in production with a bad update). I am using MS SQL Server 2005. In this example, I am trying to restore 'Column1' from DB2.Table1 into DB1.Table1: begin transaction ...

send notification message to client

Hello everybody, I have a table in server. I want to show a notification message in client when that table will update. How can i do that? excuse me because I'm beginner in SQL ...

BREAK description in BOL

SQL Server 2005 BOL says about BREAK: Exits the innermost loop in a WHILE or IF…ELSE statement. I don't understand this part about IF…ELSE. It looks like you can put BREAK inside IF. Actually BREAK works only inside WHILE, and control flow pass after loop's END. BREAK not in a WHILE context fires error, and that's completely OK. M...

Server was unable to process request

Hi Friends, I have made web service, when it is accessed by remote computer to send me the data using this web service then the following errors shows on the remote computer:- "Server was unable to process request..A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not fo...