sql-server

Create SQL identity as primary key?

create table ImagenesUsuario { idImagen int primary key not null IDENTITY } This doesn't work. How can I do this? ...

SQL Server Datetime vs Int key performance

For you database design/performance gurus out there. If you have a database that is intended to track financial data for fiscal year periods, is it better/more performance/more clear to do daterange type searches like PaymentDate Between X and Y or is it better to keep a int-key based table with fiscal year periods defined in it and tag...

How can I declare a Boolean parameter in SQL statement?

How can I declare a Boolean parameter in SQL statement? ...

SqlExpress with GoDaddy shared hosting

I've got a GoDaddy shared hosting account, and I need a database that is larger than the 200MB limit imposed on their included databases. I'm looking for a way to create MDF and LDF files locally from a SQL Server 2005 Express server, and copy them into my webspace. However, I'm not having any luck making that work. GoDaddy won't help...

What data-type should I use to store monetary values?

I've read I should use money, but in todays fast paced world maybe that's obsolete now. What should I use? ...

Using the Web.Config to set up my SQL database connection string?

Can anyone help me out please? I'm confused. I want to set up my connection string so I can just call it from my Web.Config file. I need a way to call it from my code, please make a little example. :( I also need help on setting up the Web.Config file. I don't know what properties to use. Here's a screenshot of what my credentials a...

Trouble using my stored procedure.

I have the following method that is supposed to be a generic "Save to SQL" method for my application. protected void EjecutarGuardar(string ProcedimientoAlmacenado, object[] Parametros) { SqlConnection Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); ...

How to add a number to a Sqlcommand.Parameters?

Here's my method: public void EjecutarGuardar(string ProcedimientoAlmacenado, object[] Parametros) { SqlConnection Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); SqlCommand Command = Connection.CreateCommand(); Command.CommandText ...

SQL database with Phorum

Hey SO, I was just exploring Phorum for my website. I already have a separate log in system associated with the main website, which I was hoping to be able to carry over to Phorum, so people don't have to sign up twice. I saw the way to hook in a SQL database through include/db/config.php, but there seems to be no good documentation...

export table to file with column headers (column names) using the bcp utility and SQL Server 2008

I have seen a number of hacks to try to get the bcp utility to export column names along with the data. If all I am doing is dumping a table to a text file what is the most straightforward method to have bcp add the column headers? Here's the bcp command I am currently using: bcp myschema.dbo.myTableout myTable.csv /SmyServer01 /c /t, ...

How to let SQL Server not return null query?

I have a sql query like this: if table1 exist if table1 has data select * from table1 if table2 exist if table2 has data select * from table2 ... tableN then I iterate dataset in c# but even a table does not exist in database, there is an empty result table in dataset, How to write the sql to only return not emp...

sp_OACreate error on SQL Server 2005

hi there, I have a stored procedure and trying to run "sp_OACreate" but fall over with the following message: Msg 50000, Level 16, State 1, Procedure HTTP_REQUEST, Line 26 sp_OACreate on MSXML2.XMLHttp.4.0 failed That occurs because I am setting a variable to get the return value of sp_OACreate and raise the above error if the retur...

How to change locking strategy in SQL Server?

I've read articles like these: http://www.codinghorror.com/blog/archives/001166.html http://www.databasejournal.com/features/mssql/article.php/3566746/Controlling-Transactions-and-Locks-Part-5-SQL-2005-Snapshots.htm And from what I understand, SQL Server has a very pessimistic locking strategy. And to improve performance, I should chang...

SQL Server 2005 compare dates

I'm having a problem with some T-SQL in a SP on SQLServer 2005 comparing dates. I'm running the stored procedure from c# with ADO.Net and passing a the native c# datetime datatype(could this be my issues as I know the ranges are slightly different). I do the following to compare 2 DateTime values in my SP. CREATE PROCEDURE [dbo].[spGetL...

What port is a remote SQL Server 2005 running on?

How do I find what port is my remote SQL Server 2005 running on? ...

How do I find which database uses a file

Using MS SQL Server 2005. On one of our servers we're running out of room, so I'm going through the databases, shrinking, removing, backuping etc. The largest file in the Data directory (an .mdf no less, not a .ldf) is not named according to our common naming-convention (it should reflect the database's name). I cannot move the file, s...

How can I load balance users access to 3 images of a database on different 3 servers?

I have 3 images of the same sql server database on 3 different servers. I need a technique that helps me get the user accesses the database image with the least access load. ...

Insert server datetime using a SqlCommand

I have a SqlCommand which inserts a datetime into column using a SqlParameter. At present I use DateTime.Now as the value of this parameter. I believe this will add the datetime on the user's PC which is not consistent. How do I change this so the datetime of the database server is inserted? EDIT: I should have made it clear this wa...

Columns into row in custom format

I have a sql table called UsersInAuthentication like ----------------------- | AuthUserId | UserId | | 1 | 4 | | 1 | 5 | | 1 | 8 | ----------------------- I wish to get all users in format "(4,5,8)" as string with a single stored proc and If possible I also wish to insert,update,delete operat...

How do you put an large existing database (schema) under source control?

My DBA just lost some development work that he did on our development database. Poor fella. So naturally our manager asked him, at our status meeting, how this could happen and how we could avoid this happening in the future. "Source control could alleviate the problem" I suggested... The dba's response; "No, we just backup the server mo...