In SQL server, I am trying to insert values from one table to another by using the below query: delete from tblTable1 insert into tblTable1 select * from tblTable1_Link I am getting the following …
Tag: sql-server
Dynamic order direction
I writing a SP that accepts as parameters column to sort and direction. I don’t want to use dynamic SQL. The problem is with setting the direction parameter. This is the partial code: Answer You could have two near-identical ORDER BY items, one ASC and one DESC, and extend your CASE statement to make one or other of them always
How can I get column names from a table in SQL Server?
I want to query the name of all columns of a table. I found how to do this in: Oracle MySQL PostgreSQL But I also need to know: how can this be done in Microsoft SQL Server (2008 in my case)?
How to precompile stored procedures in SQL server?
Is there any way to pre compile stored procedures in SQL Server? My requirement goes like this.. I have some stored procedures, which take more time in compiling than executing. So I want to precompile all the stored procedures. It would be nice to precompile them when the db server is started and running. Any ideas on this would be
Best way to determine Server Product version and execute SQL accordingly?
This is a two-pronged question: Scenario: I have a script to query MSDB and get me details of job schedules. Obviously, the tables differ from SQL 2000 to SQL 2005. Hence, I want to check the version running on the box and query accordingly. Now the questions: Question 1: This is what I am doing. Is there a better way
DCount vs. SQL SELECT COUNT(*)?
I am trying to get a count of all items sent to a supplier based on the purchase order they are assigned to. But I can’t seem to get the control to show a number of items based on the purchase order instance – it keeps throwing either a #name? or #error! message in the text box when the form
Deferrable Constraints in SQL Server
Do any versions of SQL Server support deferrable constraints (DC)? Since about version 8.0, Oracle has supported deferrable constraints – constraints that are only evaluated when you commit a …
Copy Data from a table in one Database to another separate database
Basically I have a two databases on SQL Server 2005. I want to take the table data from one database and copy it to another database’s table. I tried this: This didn’t work. I don’t want to use a restore to avoid data loss… Any ideas? Answer SELECT … INTO creates a new table. You’ll need to use INSERT. Also,
SQL Server: Extract Table Meta-Data (description, fields and their data types)
I am trying to find a way to extract information about my tables in SQL Server (2008). The data I need needs to include the description of the table (filled from the Description property in the Properties Window), a list of fields of that table and their respective data types. Is there any way I can extract such meta-data? I
Passing a varchar full of comma delimited values to a SQL Server IN function
Duplicate of Dynamic SQL Comma Delimited Value Query Parameterized Queries with Like and In I have a SQL Server Stored Procedure where I would like to pass a varchar full of comma delimited values to an IN function. For example: This does not work of course. I get the error: Conversion failed when converting the varchar value ‘1,2,3,5,4,6,7,98,234’ to data