I have a column DECIMAL(9,6) i.e. it supports values like 999,123456. But when I insert data like 123,4567 it becomes 123,456700 How to remove those zeros? Answer A decimal(9,6) stores 6 digits on the right side of the comma. Whether to display trailing zeroes or not is a formatting decision, usually implemented on the client side. But since SSMS formats
Tag: sql-server-2008
SQL How to correctly set a date variable value and use it?
I have the following query which uses a date variable, which is generated inside the stored procedure: The problem is that the @sp_Date value appears to be being ignored and I am wondering why? Have I defined or used it incorrectly? Answer Your syntax is fine, it will return rows where LastAdDate lies within the last 6 months; Are you
How to find unused tables in SQL Server
Is there a way of finding out when the data was last entered into a table? I’m trying to find obsolete tables within my database and would like to know if there is a simple script(s) that I can run? Answer You could try check the results of querying the sys.dm_db_index_usage_stats Dynamic Management View like this: This will return things
How to do pagination in SQL Server 2008
How do you do pagination in SQL Server 2008 ? Answer You can try something like
Check if Stored procedures have syntax errors
I have tons of stored procedures in my database. We are constantly changing the data structure (we are in development) Is there a tool that will tell me which stored procedures won’t compile? When …
How do I return the SQL data types from my query?
I’ve a SQL query that queries an enormous (as in, hundreds of views/tables with hard-to-read names like CMM-CPP-FAP-ADD) database that I don’t need nor want to understand. The result of this query needs to be stored in a staging table to feed a report. I need to create the staging table, but with hundreds of views/tables to dig through to
Why & When should I use SPARSE COLUMN? (SQL SERVER 2008)
After going thru some tutorials on SQL Server 2008’s new feature “SPARSE COLUMN”, I have found that it doesn’t take any space if the column value is 0 or NULL but when there is a value, it takes 4 …
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)?
Use bcp to import csv file to sql 2005 or 2008
I have a csv file and i need to import it to a table in sql 2005 or 2008. The column names and count in the csv are different from the table column names and count. The csv is splitted by a ‘;’ . Example CSV FILEcontents: SQL Person Table Answer I’d create a temporary table, bulk insert the lot,
Parameterize an SQL IN clause
How do I parameterize a query containing an IN clause with a variable number of arguments, like this one? In this query, the number of arguments could be anywhere from 1 to 5. I would prefer not to use a dedicated stored procedure for this (or XML), but if there is some elegant way specific to SQL Server 2008, I