I have next block in the end of each my stored procedure for SQL Server 2008
BEGIN TRY
BEGIN TRAN
-- my code
COMMIT
END TRY
BEGIN CATCH
IF (@@trancount > 0)
BEGIN
ROLLBACK
DECLARE @message NVARCHAR(MAX)
DECLARE @state INT
SELECT @message = ERROR_MESSAGE(), @state = ERROR_STATE()
RAISERROR (@message, 11, @state)
END
END CATCH
Is it possible to switch CATCH-block to
BEGIN CATCH
ROLLBACK
DECLARE @message NVARCHAR(MAX)
DECLARE @state INT
SELECT @message = ERROR_MESSAGE(), @state = ERROR_STATE()
RAISERROR (@message, 11, @state)
END CATCH
or just
BEGIN CATCH
ROLLBACK
END CATCH
?
Question: I can get the SQL Server database language by querying:
SELECT @@language
And I can get further info via
EXEC sp_helplanguage
How can I query for a column of sp_helplanguage where name= @@language
I do SELECT * FROM sp_helplanguage WHERE name='DEUTSCH'
but that obviously doesn't work.
What's the correct way to query it ?
I am using sqlcmd in a T-SQl script to write a text file to a network location. However SQLCMD is failing to write to that location due to access permission to the network folder. SP is being run under my user account which has access to the network folder.
Could you please help me under which account sqlcmd will run if I do not specify -U and -P option in TSQL Script?
I would like to ask if there is a way to include the total number of rows, as an additional column, in the returned result sets from a TSQL query using also the Row_Number (SQL 2005) command.
For example, getting the results set from a query against Book table in a form similar to this:
RowNum BookId BookTitle TotalRows
--------------------------------------------
1 1056 Title1 5
2 1467 Title2 5
3 121 Title3 5
4 1789 Title4 5
5 789 Title5 5
is there some way to tell sql server to use the (nolock) hint or every select in a stored procedure?
is pretty tiresome to add it to each an every select....
Consider the following Transact sql.
DECLARE @table TABLE(val VARCHAR(255) NULL)
INSERT INTO @table (val) VALUES('a')
INSERT INTO @table (val) VALUES('b')
INSERT INTO @table (val) VALUES('c')
INSERT INTO @table (val) VALUES('d')
INSERT INTO @table (val) VALUES(NULL)
select val
from @table
where val not in ('a')
I would expect this to return
b, c, d, NULL
but instead it returns
b, c, d
Why is this the case? Is NULL not evaluated? Is NULL somehow in the set 'a'?
Hi ,
I need to add default value column in SqlServer Compact....i am new to this SQL server compact so Plz anyone tell me the Solution of this....
Thanks In Advance
to create new a new databse file start sql server management studio express on db server and create it!
i would like to create a database using c# in my web application visual studio 08
is it possible?
as connection string has to have a name of database to connect, but i want to create one.
I have to create a C# application which displays unicode data in a textbox.
But the SQL server column storage has varchar data which contains unicode data. But since varchar is non-unicode based it displays character strings like "????????".
Well the problem i am facing is i cant change the column type as there are other dependent application running on it.
What do I need to consider before I switch a bunch of fields from VARCHAR(bignumber) to TEXT?
Aside from performance, and sometime in the far future TEXT will be deprecated, and aside from the fact that it looks like I need to drop and recreate the table to alter the column's data type?
This is for SQL 2000-- I can't do VARCHAR(max) and VARCHAR(8000) isn't large enough.
Query:
select emp.empname as Name, dep.depname as Department
from Employee as emp
inner join Department as dep on emp.depid=dep.depid
where emp.id='2'
How can I change this to linq to sql?
I have a product table where the description column is fulltext indexed.
The problem is, users frequently search a single word, which happens to be in the noiseXXX.txt files.
We'd like to keep the noise word functionality enabled, but is there anyway to turn it off just for this one column?
I think you can do this in 2008 with the SET STOPLIST=OFF, but I can't seem to find similar functionality in SQL Server 2005.
So SQL Server 2008 in Hyper-V is a supported configuration, and should perform well as long as you use fixed or pass-through disks and increase your processor/memory settings appropriately. My question is can I use snapshots as a reliable backup mechanism, or should I use the tried and trusted maintenance plan to do my backups?
I am working on a big application on SQL Server 2008 with 60 000 stored procedures and over 10 000 tables. Is there a tool through which I can do impact analysis to find out all SPs doing a DML on a table?
Hello guys
does anyone know how to convert this SQL statement to a LINQ to a List?
SELECT TOP(5) COUNT(CategoryId), CategoryName
FROM Tickets
GROUP BY CategoryName
The result would be something like
public static List<Categories> List()
{
MyEntities db = new MyEntities();
/* here it should return a list o Category type */;
return db.Category.GroupBy(...).OrderBy(...);
}
What is the easiest way to take a SQL Server database and make a test copy of it?
I have looked through some existing topics but not sure if there is an easier way. I have database publisher. I want to be able to keep both database on the same server, potentially.
Simple question I couldn't figure out (not a SQL expert... sorry): I want to do a select on the result set of sp_who2. How can I?
for ex. select SPID from [result set from sp_who2]
I have a data set that I import into a SQL table every night. One field is 'Address_3' and contains the City, State, Zip and Country fields. However, this data isn't standardized. How can I best parse the data that is currently going into 1 field into individual fields. Here are some examples of the data I might receive:
'INDIANAPOLIS, IN 46268 US'
'INDIANAPOLIS, IN 46268-1234 US'
'INDIANAPOLIS, IN 46268-1234'
'INDIANAPOLIS, IN 46268'
Thanks in advance!
David
In SQL Server, how can I insert data into a table that has just one column which is of identity type?
Such as insert into the following table t.
How can I write the insert statement?
CREATE TABLE t
(
id INT IDENTITY(1, 1) PRIMARY KEY
)
Great thanks.
Possible Duplicates:
How to calculate age (in years) based on Date of Birth and getDate()
How do I calculate someone’s age in C#?
How to calculate the customer age automatically by using their Date of Birth
using c# and SQL Server 2005
What are the benefits of storing XML in SQL Server over storing JSON in a varchar field?
Any tutorial available for how to use the XML data type effectively?
Do I need to provide the dtd / xml schema somehow? I've heard it is optional, right?
Thank you.
Hi,
i am updating some set of records in that table , after that i need to make this table read only.
So How to make a table Read Only in SQL Server?
Regards,
Jeyavel N
Is there a query I can write against an INFORMATION_SCHEMA or against the system tables to determine if a column is an identity column in SQL CE version 3.5?
How can I copy a table from an SQL Server CE 3.5 database to another (also CE database) in Visual Studio 2008, using the design tools?
Note: When right clicking on a table there is a "copy" command, but I couldn't find any "paste" command so far...