sql-server

How do I convert from a money datatype in SQL server?

I have a money data type in SQL Server. How do I reformat 0.00 to 0 in my query? ...

Corrupt SQL Server Index?

I'm encountering a very strange problem concerning what appears to be a corrupt index of some kind. Not corrupt in the sense that dbcc checkdb will pick it up, but corrupt in the sense that it has rows that it shouldn't have. I have two tables, TableA and TableB. For the purposes of my application, some rows are considered functionally ...

How do I pull value from a DataValueField?

I have a drop down list that reads from the SQL database. depending on the option selected, I want to pull the actual 'value from the DataValueField. how do I do that? Page_Load(object sender, EventArgs e) { ... ddlOption.DataTextField = "Option"; ddlOptions.DataValueField = "OptCode"; ... } protected void ddlOptionSelectionChange(ob...

Deadlock in delete-select

The following SQL statement is occasionally generating deadlocks in my mssqlserver 2000 server delete from tb_intervaloServico where idFeriado in ( select ints.idIntervalo from tb_periodicidadeServico ps, tb_intervaloServico ints where ints.idPeriodicidadeServico=ps.idPeriodicidadeServico and idservicoContrato='7f20b4...

Database file-level encryption

We recently were given a client requirement to encrypt all their data while at rest. They have agreed that encrypting the dbf, backup and trn files will suffice this need for them. My question is, do I need to encrypt the ldf file also? Is there any retrievable data in the ldf file that would require it to be encrypted? ...

BizTalk: In the remote connection dialog, is there any way to force TCP/IP transport rather than Named Pipes?

I am trying to connect to a biztalk instance over the network, and not being all that successful. The SQL server with the biztalk databases on it has named pipes disabled. When I try to connect to the server that has biztalk installed, it gives a named pipes error. When I try to connect to the database server, it just times out and gives...

Handling errors in ReportViewer Control

Hello All, i am using the reportviewer control in a winforms application, with local processing. I want to handle the ReportError event, and if that happens, display a message to user and exit out so i don't have to show subsequent error messages that occur during rendering. problem is, that even if i do this.close (Close on form that ...

SQL ADSI Active Directory Create New Accounts

I have an ADSI connection in my SQL Server (2005) and I'm able to query it using openquery. Is there any way to create new accounts (and/or) edit existing ones? Also, I'd like to have to use openquery to get to the data, but it looks like it's the only solution. Here's a sample query that I'm using: SELECT samaccountname, depar...

Synchronizing SQL Server 2005 with MySQL

I'm need to copy several tables wholesale from a third-party SQL Server 2000 database to a MySQL 5 database and keep them synchronized--i.e., when some CRUD happens on the SQL Server tables, I'd like it to be reflected in the MySQL versions in a timely manner. Now, I know there are ways to do this with 2000, but some time in the near fut...

Stored procedure - Send a list of parameters in for use with the IN clause

[DUPLICATE of http://stackoverflow.com/questions/337704/parameterizing-a-sql-in-clause] Issue: I need to send in a list of values into a stored procedure for use with an IN statement in the WHERE clause. Example: declare @SPType NVARCHAR ( 30 ) declare @SPCodeA int set @SPCodeA = 75 set @SPType = '''I'',''M''' select * from tabl...

How do I use the OLE DB provider for Directory Services in a SQL Server Integration Services project?

I can setup a connection manager that uses the Directory Services OLE provider and points to one of our domain controllers. Then, in the Data Flow area, I create a OLE DB Source and set the Data Access Mode to "SQL Command". I then use this query to pull data from Active Directory: Select employeeid, sAMaccountName From 'LDAP://MyComp...

Why would you NOT set IGNORE_DUP_KEY to ON?

IGNORE_DUP_KEY = ON basically tells SQL Server to insert non-duplicate rows, but silently ignore any duplicates; the default behavior is to raise an error and abort the entire transaction when there are duplicates in a column that doesn't allow them. I've worked with a ton of data that normally has at least one duplicate when there shou...

What is the best database to use for an intranet?

Someone suggest me to use a wamp for the intranet but the database is already setup with a mssql. I want to know if it's a great move to use mysql instead of mssql cause I have to migrate all data from mssql to mysql. Plus, I want to know some crappy problem that I can face during the migration. Thanks! ...

How to return the latest row written for the day?

I have a table with a FooId and a CreatedTime column. During the day, multiple rows can be inserted for the same FooId. The CreatedTime column represent the time at the moment of the inserting. I would like a query which will return me the latest row for a given day (e.g. 2000-01-01). Is there a way to write a query which will do that ...

MSSQL Select statement with incremental integer column... not from a table

Hi guys I need, if possible, a t-sql query that, returning the values from an arbitrary table, also returns a incremental integer column with value = 1 for the first row, 2 for the second, and so on. This column does not actually resides in any table, and must be strictly incremental, because the ORDER BY clause could sort the rows of ...

SSPI Errors for SQL Server Authentication?!

We have several old ASP and PHP web applications which use SQL Server Authentication. Periodically, all the applications lose the ability to connect to our SQL Server 2000 database server, getting access denied. Corresponding to roughly the same times, we are getting 1115 Cannot generate SSPI Context SQLSTATE HY000 errors on the SQL...

Sql statement using parameters is slow, fast without them.

Hello. I'm having a bit of trouble with the performance of a parameterized sql statement. The table i'm working with has ~150,000 records with each record having ~30 columns. This statement executes in 3.5 seconds. Dim selectstring As String selectstring = "SELECT * FROM LineInfo WHERE jobNum=@jobnum and revision_number=@revnu...

Multiple Parameter Search in SQL Server 2000

I have a search screen in a Visual Basic .Net App that has text boxes for: First Name Varchar(50) Last Name Varchar(50) Middle Name Varchar(50) DOB DateTime Home Phone Varchar(10) Work Phone Varchar(10) How would I create a stored procedure in SQL Server 2000 that would allow me to be able to searh on all/some/one of the fields. If ...

Is there a way to have an SSRS 2008 chart show top X results and group/sum the rest as other?

I would like to have a chart in SQL Server Reporting Services 2008 show the top X values and sum/group the rest as other. Is this possible without doing the grouping in T-SQL? Example: A query brings back the total sales from 50 US states. I want to show the five states that have the most sales and group the rest as "All Other States" ...

Implode type function in SQL Server 2000?

Is there an Implode type function for SQL Server? What I have is a list (in a SQL server table): Apple Orange Pear Blueberry and I want them to come out as Apple, Orange, Pear, Blueberry I hope for the space and comma to be configurable but I can always replace it if it isn't... Quick help would be appreciated! ...