Quantcast
Channel: Solved » sql-server
Browsing all 48 articles
Browse latest View live

Adding an Identity Column to an Existing Table Sql Server 2008

I am using SQL Server 2008 Enterprise. I want to add an identity column (as unique clustered index and primary key) to an existing table. Integer based auto-increasing by 1 identity column is ok. Any...

View Article


What Is the Difference Between Char Nchar Varchar and Nvarchar in SQL Server

What is meant by nvarchar? What is the difference between char, nchar, varchar, and nvarchar in SQL Server? Solution Just to clear up… or sum up… nchar and nvarchar can store Unicode characters. char...

View Article


Update Table With Join in Sql Server 2005

I need to update this table in SQL Server 2005 with data from its ‘parent’ table, see below: sale id (int) udid (int) assid (int) ud id (int) assid (int) sale.assid contains the correct value to...

View Article

Update Table Using Inner Join in Sql Server

This question already has an answer here: Update a table using JOIN in SQL Server? 7 answers I have the below query which does not work. What am I doing wrong? Is this even possible? UPDATE...

View Article

Update Table With Inner Join in Sql Server 2008

I want to update a column in a table making a join on other table e.g.: UPDATE table1 a INNER JOIN table2 b ON a.commonfield = b.[common field] SET a.CalculatedColumn= b.[Calculated Column] WHERE...

View Article


When Should I Use Cross Apply Over Inner Join

What is the main purpose of using CROSS APPLY? I have read (vaguely, through posts on the Internet) that cross apply can be more efficient when selecting over large data sets if you are partitioning....

View Article

How to Calculate Percentage Using Sql Query

I have a SQL Server table that contains users & their grades. For simplicity’s sake, lets just say there are 2 columns – name & grade. So a typical row would be Name: “John Doe”, Grade:”A”....

View Article

List of All Index

How do I get a list of all index & index columns in SQL Server 2005+? The closest I could get is: select s.name, t.name, i.name, c.name from sys.tables t inner join sys.schemas s on t.schema_id =...

View Article


Function vs Stored Procedure in SQL Server

I’ve been learning Functions and Stored Procedure for quite a while but I don’t know why and when I should use a function or a stored procedure. They look same to me, maybe because I am kinda newbie...

View Article


Difference Between Function and Stored Procedure in Sql Server 2005 Msdn

Let’s say I have to implement a piece of T-SQL code that must return a table as result. I can implement a table-valued function or else a stored procedure that returns a set of rows. What should I...

View Article

Image may be NSFW.
Clik here to view.

Auto Increment Primary Key in Sql Server Management Studio 2012

How do I auto increment the primary key in a SQL Server database table, I’ve had a look through the forum but can’t see how. I’ve looked the the properties but can’t see an option, I have seen an...

View Article

Best Way to Get Identity of Inserted Row

This question already has an answer here: How to get last inserted id? 8 answers I want to get the new created ID when you insert a new record in table. I read this:...

View Article

Best Way to Get Identity of Inserted Row

What is the best way to get identity of inserted row? I know about @@IDENTITY and IDENT_CURRENT and SCOPE_IDENTITY but don’t understand the pros and cons attached to each. Can someone please explain...

View Article


How to See Active SQL Server Connections

I am using SQL Server 2008 Enterprise. I want to see any active SQL Server connections, and the related information of all the connections, like from which IP address, connect to which DB or...

View Article

How to Execute Sql Server Stored Procedure in Sql Developer

I’ve been given a user account to a SQL Server database that only has privileges to execute a stored procedure. I added the JTDS SQL Server JDBC jar file to SQL Developer and added it as a Third Party...

View Article


Get List of Databases from SQL Server

How can I get the list of available databases on a SQL Server instance? I’m planning to make a list of them in a combo box in VB.NET. Solution SELECT name FROM master..sysdatabases or if you prefer...

View Article

Get List of Tables from Database Sql Server

What is the best way to get the names of all of the tables in a specific database on SQL Server? Solution SQL Server 2005, 2008 or 2012: SELECT * FROM information_schema.tables SQL Server 2000: SELECT...

View Article


Sql Server When to Use With Nolock

Can someone explain the implications of using with (nolock) on queries, when you should/shouldn’t use it? For example, if you have a banking application with high transaction rates and a lot of data in...

View Article

Sql Server Convert String to Date Format

I have this date format: 2011-09-28 18:01:00 (in varchar), and I want to convert it to datetime changing to this format 28-09-2011 18:01:00. How can I do it? Solution SELECT CONVERT(Datetime,...

View Article

SQL Server Text Type vs Varchar Data Type [Closed]

I just read that the VARCHAR(MAX) datatype (which can store close to 2GB of char data) is the recommended replacement for the TEXT datatype in SQL Server 2005+. If I want to search inside a column for...

View Article
Browsing all 48 articles
Browse latest View live