sql-server

Choosing optimal indexes for a SQL Server table

I have a SQL Server table with the following structure: CREATE TABLE [dbo].[Log]( [LogID] [bigint] IDENTITY(1,1) NOT NULL, [A] [int] NOT NULL, [B] [int] NOT NULL, [C] [int] NOT NULL, [D] [int] NOT NULL, [E] [int] NOT NULL, [Flag1] [bit] NOT NULL, [Flag2] [bit] NOT NULL, [Flag3] [bit] NOT NULL, [Counter] [int] NOT NULL, [Start...

SQL create table and query from it

Morning all, I'm running SQL Server and there are a whole lot of tables in there. I have taken one column from one of these tables using SELECT, and it gives me the list of IDs. I need to use these IDs as the lookup point to get the data for that ID from another table. Is it necessary that I do a CREATE TABE manouvre? I was hoping I c...

To create a view in a linked SQL Server 2005 database with some data types transformations

good day! There are two linked SQL Server 2005 machines, server A with a lot of data and empty base on sever B. Our user does not have a permission to create views on A, but have this ability on server B. We checked out a possibility to make selects @B to A, and it's ok, there's a connection. Please, prompt us on how to make a view @...

SQL server simple query

How to select value from a table if it value is not null,and select a default value if not?.I.E: select coalesce(username,'its null') from tb_user where int_id_user = 0 I try to run this query but its not working,i expect to get 'its null' since int_id_user is 0,but it returns NULL. ...

Invoke-Sqlcmd unavailable from the ISE, but works in conventional Powershell host

I'm having some trouble with Invoke-Sqlcmd From the normal powershell console, it's fine. But I'm unable to use it from the ISE. I can confim the addin is loaded >Get-PSSnapin SqlServerCmdletSnapin100 Name : SqlServerCmdletSnapin100 > add-PSSnapin SqlServerCmdletSnapin100 Add-PSSnapin : Cannot add ... SqlServerCmdletSnapin100 ....