sql-server

Problem in cursor and print function and cursor

i was just working with cursor in SQL 2008 but i face some problems. the first is that with the line i declared the cursor every time i execute the query it gives me an error. which says the cursor with such a name already exists. i want to offer me a way that if the cursor exists do not create it and if it is not defined yet sql creates...

how to set to NULL all the filestream varbinary(max) fields?

I need to create a test database out of a huge database where the most data is contained as filestream data. I need to test not filestream related data, so what I'd like to do is to remove the varbinary(max) info. These are the fields I have in my FILE_REPOSITORY_TABLE table: [ID_FILE] [int] NOT NULL, [FILE_DATA] [varbinary](max) FILE...

JTDS Connection problems to SQL Server - Works on 2000 but not 2005

I've been trying to get a java application connecting via the jtds jdbc to a couple of SQL servers. I have to connect via windows authentication. The connection string specified is: String connectionString = _"jdbc:jtds:sqlserver://"+server+":"+port+"/"+database+";domain="+domain;_ and I am getting the connection via: con = j...

Incrementing a counter for dateadd

Hello, I'm trying to increase the time between dates by a set amount. For example, I want to add two months to the time between date 1,2 and 3. I'm having trouble incrementing my 'date counter'... DECLARE @monthDiff int SET @monthDiff = 1; UPDATE [Table1] SET [Date] = DATEADD(MONTH, (SET @monthDiff = @monthDiff + 1), [Date]) WHERE ...

Convert From Bigint to datetime value

Hi people, please help me with this one, i want to convert a value from Bigint to datetime. For example im reading HISTORY table of teamcity server, on the field *build_start_time_server* i have this value on one record 1283174502729. How can i convert to datetime value??? Thanks ...

How to force the filestream garbage collector to complete its work with the highest priority?

After asking this question it is clear to me that I need to be able to perform the garbage collection in the fastest possible time. How is it possible to tell SQL Server filestream's garbage collector to delete all the files with high priority? I tried with the CHECKPOINT statement, even by setting a duration (CHECKPOINT 100), but noth...

SqlCommand-class force SELECT only?

Hi, I'm developing a application that's for SQL-surveillance, it's just a console application that will run each 5min on a bunch of servers. It has a config file with connection string and sql query. The thing is I would like the program to accept SELECT queries only. I colleague told me he thought I could set something in the SqlComma...

best default collation of a multilingual database

I am a bit confused about de default collations when creating a database. The data stored in the database will be in different languages. The main users of the database will be using the spanish language, but it will also be used in english, french... As the spanish default collation is Modern_Spanish_CI_AS, and the english, french itali...

SQL SERVER Foreign Keys and Indexes

Is it a good practice to create an index to every foreing key in my database? ...

Login error to database for Team Foundation Server 2010

I have installed Team Foundation Server 2010 (basic configuration) on a Windows Server 2003 without any problems. But when I go to administer the Team Foundation Server Administration Console, I get the error when in the press "Administer Security" or "Group Membership" Server was Unable to process request. ---> Team Foundation services...

SQL Server: using table or @table in stored procedure

I have a stored procedure (see below) which inserts data into a physical table and then joins information with sys.databases. I was thinking that would it be better to not have a physical table for data insertion? Would it be better to fetch these results into a table variable within this procedure? If so, how to do that? CREATE PROCEDU...

Replacing DB Trigger mechanism

Hi everyone. I'm using SQL Server (2005). Today i have some tables that everytime the data inside them changes i get DB trigger (implemented via the sql server trigger mechanism) and handles it. the problem is that the trigger mechanism has bad performance and handling with it is not exaclly afun thing to do. now to my question. is anyb...

Add login and user to SQL Server without using SMO

Hello, in our company's product, we attach a database to SQL Server, and we need to add credentials to some accounts to the catalog. Currently we're using SMO to do this, but this gives us problems (x86 vs x64, SQL Server 2005 vs 2008, etc) Is there's anyway of adding a login (to the server) and a user (to the catalog) using SQL? This...

Newline in SQL Server

Can anybody tell me how to save newline in database and also retrieve it in a same manner using asp.net. ...

Is it okay to modify the SQL Server Reporting Services' web.config file?

I need to implement custom security for SQL Server Reporting Services. To do this, I would like to add some configuration into the web.config of the SSRS' Reports Server web application. My question is - is it safe to do this? Might my custom configuration be overrun by some SSRS process? Or by an automatic update to the SSRS? ...

How do I select records less than 1 year old...

Howdy, this should be a fairly simple question but I know very little about SQL. I have a database which has the following fields: client_id, scheduled_amount, deposit_amount, message_code_id, note_text, system_date now I wish to select all the records that are less than 1 year old from when the sql statement is run. I know I should u...

EMPTY_CLOB() in Microsoft SQl server

Hey guys, Oracle has a CLOB type and the function EMPTY_CLOB(). I'm looking for an alternative for use in SQL server. Thanks in advance. ...

Asp.net MVC Hosting - SQL Server

So I'm moving my Asp.net mvc web app over to Arvixe shared hosting. This is the first time I've deployed an MVC app. I have been using SQL Server 2008 Express for the development database. Arvixe provides SQL Server 2008 or MySQL hosted databases. A couple questions: 1.Can I use the mdf files from my Express database with the new No...

Help writing SQL query..

Possible Duplicate: Need help with a SQL query that combines adjacent rows into a single row So this is how my table looks. ..and I need to write a query to get the output like this: This is not a homework question. ...

SQL - select * from X WHERE (if value is numeric, else ...)

I would need to make a DB select that will behave differently when number or text is entered, just different condition should be used. I think it should be done but not quite sure with the syntax (MSSQL). Thank you I would need: SELECT * FROM X WHERE (IF value passed is numeric = "ID" ELSE "NAME") = Value //ID or Name are columns ...