sql-server-2008

SQL Server : View permission to table

拈花ヽ惹草 提交于 2020-01-06 08:25:35
问题 Is it possible to grant a user access to a view but restrict the user from accessing the table the view selects from? CREATE TABLE [dbo].[tUsers]( [ID] [int] IDENTITY(1,1) NOT NULL, [Username] [nvarchar](50) NULL, [Password] [nvarchar](50) NULL, [TenantID] int ) ON [PRIMARY] CREATE VIEW [scmTenant1].[vUsers] AS SELECT ID, Username, Password FROM dbo.tUsers WHERE TenantID = 1 The SQL Server user account ( usrTenant1 ) has access to schema scmTenant1 but does not have access to the dbo schema.

Error in Dynamic SQL SP

让人想犯罪 __ 提交于 2020-01-06 08:24:13
问题 I Have created a procedure which has code like this: Create PROCEDURE Sample( @ID INT ) AS BEGIN DECLARE @SQL NVARCHAR(max) DECLARE @SchemaName SYSNAME DECLARE @TableName SYSNAME DECLARE @DatabaseName SYSNAME SELECT @SQL = 'Create Table ' + @DatabaseName + '.' + @SchemaName + '.' + @TableName + '_temp' + '(' SELECT @SQL = @SQL + 'ID int NOT NULL Primary Key, Name VarChar(10))' I Always get error as : Msg 102, Level 15, State 1, Line 77 Incorrect syntax near ','. Can anyone help me on this?

Data Migration From Oracle To SQL Server

馋奶兔 提交于 2020-01-06 08:16:10
问题 I have an Oracle database in which there is one or more table. I also have blob data, i.e. images are stored, now I would like to move that data to Sql Server database. What is the best way to do this? I would like to test it for one table migration which contains image data in the Oracle database and move it into SQL Server table. How do I test for migrating data from one table from Oracle to SQL Server? But first thing I would like to confirm is that whether Image data moving from Oracle DB

SQL Select, Specific Rows based on multiple conditions?

走远了吗. 提交于 2020-01-06 07:51:34
问题 Not sure if it's because I'm tired, but I can't seem to figure this out... I'm looking for a Query that will filter the data based on a couple items... Sample Data: Business_Month ID Calls Transferred Loaded 11/1/2012 0:00 119118 226 16 12/19/12 15:56 12/1/2012 0:00 119118 333 17 1/15/13 23:54 1/1/2013 0:00 119118 284 6 3/13/13 17:49 1/1/2013 0:00 119118 284 6 3/20/13 13:03 1/1/2013 0:00 119118 284 6 3/20/13 13:25 2/1/2013 0:00 119118 219 8 3/20/13 13:25 3/1/2013 0:00 119118 17 0 3/20/13 13

SQL Server 2008: Bulk Insert taking forever

一曲冷凌霜 提交于 2020-01-06 07:44:21
问题 I have a txt file(tab delimited) which has almost 1200 records. I m doing a bulk insert operation to get the data from .txt file to a table- which(structure) is already created in the database. I don't know why bulk insert is taking forever. Any suggestions on where/what/how to check what's causing this operation to take forever? Thanks. I did it before as well and it used to work fine. Any reasons? BULK INSERT DataFromatltemp FROM '\\abcd\Admin\temp\Copyatltemp07.txt' WITH ( FIELDTERMINATOR

SQL Server 2008: Bulk Insert taking forever

自作多情 提交于 2020-01-06 07:44:18
问题 I have a txt file(tab delimited) which has almost 1200 records. I m doing a bulk insert operation to get the data from .txt file to a table- which(structure) is already created in the database. I don't know why bulk insert is taking forever. Any suggestions on where/what/how to check what's causing this operation to take forever? Thanks. I did it before as well and it used to work fine. Any reasons? BULK INSERT DataFromatltemp FROM '\\abcd\Admin\temp\Copyatltemp07.txt' WITH ( FIELDTERMINATOR

SQL Server 2008: Bulk Insert taking forever

浪子不回头ぞ 提交于 2020-01-06 07:44:07
问题 I have a txt file(tab delimited) which has almost 1200 records. I m doing a bulk insert operation to get the data from .txt file to a table- which(structure) is already created in the database. I don't know why bulk insert is taking forever. Any suggestions on where/what/how to check what's causing this operation to take forever? Thanks. I did it before as well and it used to work fine. Any reasons? BULK INSERT DataFromatltemp FROM '\\abcd\Admin\temp\Copyatltemp07.txt' WITH ( FIELDTERMINATOR

selecting top column1 with matching column2

给你一囗甜甜゛ 提交于 2020-01-06 07:31:12
问题 sorry for asking this, but i'm runnin' out of ideas i have this table: [id] [pid] [vid] 1 4 6844 1 5 6743 2 3 855 2 6 888 ... how to i query this eg.table to get the following result: [id] [pid] [vid] 1 5 6743 2 6 888 i want to get the highest [pid] for an [id] with the [vid] matching to this [pid] any ideas? i'm using mssql 2008 回答1: I would use Common Table Expressions (CTE). This offers lots of possibilities like so: WITH Result (RowNumber, [id], [pid], [vid]) AS ( SELECT Row_Number() OVER

SQL - Find if column dates include at least partially a date range

坚强是说给别人听的谎言 提交于 2020-01-06 07:30:47
问题 I need to create a report and I am struggling with the SQL script. The table I want to query is a company_status_history table which has entries like the following (the ones that I can't figure out) Table company_status_history Columns: | id | company_id | status_id | effective_date | Data: | 1 | 10 | 1 | 2016-12-30 00:00:00.000 | | 2 | 10 | 5 | 2017-02-04 00:00:00.000 | | 3 | 11 | 5 | 2017-06-05 00:00:00.000 | | 4 | 11 | 1 | 2018-04-30 00:00:00.000 | I want to answer to the question "Get all

How to create a dynamic IN query in SSIS 2008?

回眸只為那壹抹淺笑 提交于 2020-01-06 07:16:14
问题 I have a variable @csv which hold a comma separated value such as: -a -a,b -a,b,c I need to pass it in a query in my OLE DB source in a data flow to create a query such as: SELECT COUNT(1) FROM table WHERE col1 IN @csv So if @csv="a,b" then internally it should resolve into SELECT COUNT(1) FROM table WHERE col1 IN 'a','b' How can this be best achieved in SSIS 2008? Can I avoid the script component to create a dynamic query and storing it in a variable? 回答1: How can this be best achieved in