How to get a float result by dividing two integer values using T-SQL?

Using T-SQL and Microsoft SQL Server I would like to specify the number of decimal digits when I do a division between 2 integer numbers like: select 1/3 That currently returns 0. I would like it to return 0,33. Something like: select round(1/3, -2) But that doesn’t work. How can I achieve the desired result? … Read more

How to create a table from select query result in SQL Server 2008 [duplicate]

This question already has answers here: How to create table using select query in SQL Server? (4 answers) Closed 8 years ago. I want to create a table from select query result in SQL Server, I tried create table temp AS select….. but I got an error Incorrect syntax near the keyword ‘AS’ 6 Answers … Read more

SQL Server query to find all permissions/access for all users in a database

I would like to write a query on a sql 2008 that will report all the users that have access to a specific database, or objects within the database such as tables, views, and stored procedures, either directly or due to roles, etc. This report would be used for security auditing purposes. Not sure if … Read more

How to drop all tables in a SQL Server database?

I’m trying to write a script that will completely empty a SQL Server database. This is what I have so far: USE [dbname] GO EXEC sp_msforeachtable ‘ALTER TABLE ? NOCHECK CONSTRAINT all’ EXEC sp_msforeachtable ‘DELETE ?’ When I run it in the Management Studio, I get: Command(s) completed successfully. but when I refresh the table … Read more