I'm writing a stored procedure and I want to return 0 records when something fails. I can't seem to figure out how to just return 0 rows? I've used SELECT NULL but this returns 1 row with a NULL in row 1 col 1. I have also tried not specifying any SELECT statements in my error code path but when testing the value of @@ROWCOUNT after the ...
I am trying to work out a bug we've found during our last iteration of testing. It involves a query which uses a common table expression. The main theme of the query is that it simulates a 'first' aggregate operation (get the first row for this grouping).
The problem is that the query seems to choose rows completely arbitrarily in some ...
I have a situation wherein to accomodate the need of dynamic addition of columns to a table, I am putting the columns values as rows in a table.
As an example, storing of columns of an Address Table would be in the format:
ID PropertyName
1 HouseNo.
2 Street
3 City
4 State
5 Country
Now, if I need to create an O...
I was asked in the interview tell me the different ways of exporting database from one sql server to another, I knew only about creating a .bak file and then restoring it to another sql server which I told them. However, they asked me about a single SQL INSERT command which will perform this task.
I have googled it and can not find it....
I have 2 tables- master and detail table. Master Table has ID column which is Primary key and Auto Id. I have wrtten an SP to insert records into both tables. In this SP, when a record id inserted in master table, current_ident is fetched and stored in a variable which is then passed to detail table insert the detail records. This is wo...
I have 3 tables (A,B,C) and I need quite often to query the result of
A inner join B
union
A inner join C
I'm just thinking which way is going to be faster:
to write in each query the whole thing from scratch
to create a view and use it in queries
...
Are table variables created in memory or in tempdb? Same for
short temp tables?
...
Our SQL Server databases (SQL Server 2008 Standard edition, so to be R2) are getting bigger and bigger from years of data gets stored. So we are thinking of moving the old data (possibly older than a year) into an archive database. There are many reasons why we would benefit from having our production databases smaller.
This is how I pl...
if a sql server table's column is wiped out in a database and you restore a backup to a new database, would you use merge to restore that column or run an update across the two databases?
...
When i have a column say "GROUP"
TableName.GROUP
during select it show me error
Incorrect syntax near the keyword 'GROUP'
I tried
select [TableName.GROUP] from TableName
it shows me invalid column name TableName.GROUP
i tried
select [dbo.TableName.GROUP] from TableName
i received the same error invalid column name dbo.Ta...
I have the following update statement:
update db1.dbo.table1 set db1.dbo.table1.col = db1_bk.dbo.table1.col where db1.dbo.table1.id = db1_bk.dbo.table1.id
no error.. it just won't update the table row.
however if i run
update db1.dbo.table1 set db1.dbo.table1.col = '2010-01-01' where db1.dbo.table1.id = 2
it does work.
any ideas?...
When I run the mongrel server in a command window everything works
fine, database connections are made and the app is running properly.
If I set the Windows Service to run my app by logged in with my user
credentials it works fine as well. However, when I set the Service to
run as Local System I cannot get the application to start an...
Hello
I had an php apliccation with mssql2000 (sql server 2000) , I'm using appserv 2.5.9 with apache2 and php5.
I've upgraded my computer to Windows 7 Ultimate x64, and tryied to run the application, but it goes to sloooooooooooooooooooow
Since like 2 years, works perfectly fine (not application problem, and no db problem, works fine...
Ok this is what i need to model...
I have 2 objects, that can exist seperately - lets say man and woman, neither needs to know about the other. But once they get get "married" it can only be married to each other.
In other words, I'm trying to create 2 tables, 1 table has a FK to the other, that is NULLABLE. When i try to set the rela...
Put simply, I have a set of special characters in a Sql Server database varchar column, and I want to fetch it from a C# application.
Now the difficulty is: using Query Analyzer, I get the desired value of: "·°ï££".
However, through the client application, I end up with: "À░´úú".
It's a varchar column in a database with collation SQL_...
I'm assuming some sort of security constraint, but if I have access to all folders on a PC, why allow some folders and not others.
What is the criteria for a folder being a valid backup / restore / attach folder?
Any advice appreciated!
...
I have a SQL Server 2008 procedure that sends email via sp_send_dbmail.
I'm using the following code:
set @bodyText = ( select
N'Here is one line of text ' +
N'It would be nice to have this on a 2nd line ' +
N'Below is some data: ' +
N' ' +
...
I'm using sqlmetal.exe to generate a DataContext class from a sqlserver database to use with LINQ. I have a bunch of stored procedures that in some cases returns a primary key column that is a NOT NULL INT, such as this one:
CREATE PROCEDURE spDDIs_Find(@DDINumber VARCHAR(64)) AS
IF NOT EXISTS (SELECT ID FROM tDDIs WHERE DDINumber = @D...
I have a classic ASP website I am working to try and convert to .NET- one page at a time. I am using VS2010 for this. The development db is on a network share drive, and when I try to debug my application I recieve an error because the BIOS command limit has been reached, as a result of the db being located on a network share drive. Is t...
I've got a simple table "Logins" with two columns:
username (nvarchar)
logged (datetime)
It's really simple, just records the username and datetime when someone logs into my web application. Sometimes, however, people login a few times in one minute... I want to try to run a query to filter those results and only have it return one ...