sql-server

Sproc Parameter Returning First Character Only

I've got a sproc and some C# calling it. My problem is that both the (N)VARCHAR values only have the first character returned. Everything else is fine. Why would only the 1st character be returned? So Content = (string)cmd.Parameters["@SmsContent"].Value, ToNumber = (string) cmd.Parameters["@ToNumber"].Value, both only get the 1st ch...

Why won't Visual Studio 2008 create .mdf files with SQL Server 2008 Developer installed?

I'm trying some of the ASP.NET MVC tutorials and one of them has the following steps: Right-click on the "App_Data" folder, and choose "Add New item" Choose "SQL Server Database" under the "Data" category. However, once I do that, I get the following message from Visual Studio: Connections to SQL Server files (*.mdf) require SQL ...

What's the best method to pass parameters to SQLCommand?

What's the best method to pass parameters to SQLCommand? You can do: cmd.Parameters.Add("@Name", SqlDbType.VarChar, 20).Value = "Bob"; or cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = "Bob"; or cmd.Parameters.Add("@Name").Value = "Bob"; It seems like the first one might be somehow "better" either performance-wise or err...

Trigger to alert delete and insert

How can we create a trigger to send an email on any insert or delete action on a table.It should send an email and also it should have the location of the server and the database. Please, let me know. ...

How to display image from sql server in ms access

Hi, I have an MS sql server database. There is a table with one of the column of the "image" type. Now, the customer wants to read the data from an MS access. He wants to display the images in a form. I have never used access and have no idea of how to do simple things there. Any help will be greatly appreciate. Thanks, Ramjee ...

How to make a SQL query "you are better than XX percent of other users" for MSSQL2000

I have a large table with list of scores like this, one score per user: user,score ------ matt,10 john,20 bill,30 I want to make a query that answers to question: "John, you are faster than xx percent of others" How to make such a query for Microsoft SQLServer 2000 with optimal performance. ...

SQL Server - Fulltext search for %book%

Folks, I'm trying to wrap my head around how to search for something that appears in the middle of a word / expression - something like searching for "LIKE %book% " - but in SQL Server (2005) fulltext. How can I do that?? It almost appears as if both CONTAINS and FREETEXT really don't support wildcard at the beginning of a search expre...

SQL Server Timeout Logging

Hello Hopefully this a simple yes/no question.. Are SQL Server timeouts (SELECT queries, in particular) logged in the ERRORLOG file? Background is a customer with a web site having occasional Request timeout messages, looking to me assuming that the timeout is caused by a database timeout. There are no timeout errors in the ERRORLOG in...

Compressed backups in SQL Server 2005

What is the best free way to get your maintenance plan-generated backups compressed? I know there are non-free tools that will compress the backups, but I'm not interested in them. Options: Have a T-SQL task after the backups that will run a script through xp_cmdshell that compresses every non compressed backup. ??? Any other ideas...

Get SQL Server database folder of selected instance by using vbscript

Assume that you have a running SQL Server Express instance named (local)\SQLEXPRESS. Its database folder is c:\program files\Microsoft SQL Server\MSSQL.1\MSSQL\Data. How can VBScript be used to retrieve that folder? Maybe by using SMO? And if so, how? <- Forget that. SMO uses .NET. Only possible in PowerShell. Update: The reason f...

Inner select on one to many

Hi all, I have 2 tables event + event_artist event eventId | eventName 1 , gig1 2, gig2 event_artist eventId, artistName 1, Led Zip 1, The Beatles ie Led Zep and the Beatles are both playing @ Gig1 I need to create the SQl to bind to a gridview ( you necessarily need to know about gridviews to answers this ) The results that i ...

Configure Hibernate to escape underscores in LIKE clause using SQL Server dialect

I have a SQL SELECT query which has a LIKE clause containing an underscore, which should specifically look for an underscore, not treat it as a wildcard: SELECT * FROM my_table WHERE name LIKE '_H9%'; I understand that I can change the actual clause to '[_]H9%' for this to work as I expect, but the problem is that this clause is bein...

Locking SQL Server to a specific application on a web server

I'm curious, is there a way to tell the SQL Server that a specific group has access to the database only from a single location/application. I have an SQL Server and a Web Server. Our applications use stored procedures and access for each stored procedure is based on the role that is allowed to access it. Then user groups are assigned...

Where can I get a large Sql Server sample database?

Hi, I was wondering if it is possible to get a large, enterprise-scale sample Sql Server database? I am working with Sql Server 2005, and feel that looking at a large scale database would really improve my database design skills. I'm aware of, and have checked Nortwind and AdventureWorks, but these aren't large enough. Also, when worki...

What harm can DBO do to a server?

Aside from executing XP_CmdShell, which I have disabled in my SQL 2005 installation, what could a malicious user who gains DBO rights to my database do: to my database, to my server? I'm assessing the worst-case security risk of someone obtaining DBO to justify running a "least-privileged" user account in an application. Some allege ...

Windows Authentication and Network Service account as a db_owner

There is a number of commercial products out there, that give you a windows based installers for configuring your app and the back end SQL Server DB. Typically it will ask if you want to connect to the DB with Windows or SQL Server authentication. Most of them make a recommendation to use Windows Auth and then configure your DB with the ...

What is the best way to store historical data in SQL Server 2005/2008?

My simplified and contrived example is the following:- Lets say that I want to measure and store the temperature (and other values) of all the worlds' towns on a daily basis. I am looking for an optimal way of storing the data so that it is just as easy to get the current temperature in all the towns, as it is to get all the temperature...

SQL query question: SELECT ... NOT IN ...

I am sure making a silly mistake but I can't figure what: In SQL Server 2005 I am trying select all customers except those who have made a reservation before 2 AM. When I run this query: SELECT idCustomer FROM reservations WHERE idCustomer NOT IN (SELECT distinct idCustomer FROM reservations WHERE DATEPART ( hour, insertDate) ...

SQL Server Integration Services

What are some recommended resources/books/blogs on SQL Server Integration Services? Thanks. ...

What is the best query to get the current records in an archive table (SQL Server 2005/2008)

Example There is an application that measures temperature in each town of the world. Each measurement is taken every 5 minutes and written in to the Measurement table. CREATE TABLE [dbo].[Measurement]( [MeasurementID] [int] IDENTITY(1,1) NOT NULL, [Town] [varchar](50) NOT NULL, [Date] [datetime] NOT NULL, [Temp] [int] N...