Tag: sql

List of Stored Procedure from Table

I have a huge database with 100’s of tables and stored procedures. Using SQL Server 2005, how can I get a list of stored procedures that are doing an insert or update operation on a given table.

Find All Rows With Null Value(s) in Any Column

I’m trying to create a query that will return all the rows that have a null value across all but 1 column. Some rows will have more than one null entry somewhere. There is one column I will want to exclude, because at this moment in time all of the entries are null and it […]

Update multiple tables in SQL Server using INNER JOIN

This question already has an answer here: How to update two tables in one statement in SQL Server 2005? 7 answers

How to find the worst performing queries in SQL Server 2008?

How to find the worst performing queries in SQL Server 2008? I found the following example but it does not seem to work: SELECT TOP 5 obj.name, max_logical_reads, max_elapsed_time FROM sys.dm_exec_query_stats a CROSS APPLY sys.dm_exec_sql_text(sql_handle) hnd INNER JOIN sys.sysobjects obj on hnd.objectid = obj.id ORDER BY max_logical_reads DESC Taken from: http://www.sqlservercurry.com/2010/03/top-5-costly-stored-procedures-in-sql.html

What is the SQL command to return the field names of a table?

Say I have a table called myTable. What is the SQL command to return all of the field names of this table? If the answer is database specific then I need SQL Server right now but would be interested in seeing the solution for other database systems as well.

Rename SQL Server Schema

How can I rename a schema using SQL Server?

converting Epoch timestamp to sql server(human readable format)

I have a problem in converting the Unix timestamp to sql server timestamp. I have a data in excel sheet and I will import that data through a tool. So I am looking for a code or syntax which can convert that Epoch timestamp to sql server timestamp. I have 3 different columns with the […]

How to get the client IP address from SQL Server 2008 itself?

I have a trigger for insert/update/delete. That is working fine. Also, I need the client’s IP address from where the changes are made. That I need in T-SQL, that means, not in any web form but in the SQL/T-SQL while my trigger will get fired. Also I go-ogled, and got that there is stored procedure […]

Script entire database SQL-Server

Is there a way I can get a scripting of all tables, procs, and other objects from a database? I know there’s an option to script the database but it only gave me some sort of top level script, certainly not a script to create all tables, procs, udfs, .etc.

Best practice on users/roles on SQL Server for a web application

I searched online a bit and couldn’t find anything that really nailed the spot or covered the bases how to go about setting up users/roles on a database. Basically, there would be a user that would be used to access the database from the application (web application in this case) that will need access to […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.