sql-server-2008

Argument data type numeric is invalid for argument 1 of substring function

会有一股神秘感。 提交于 2021-02-16 18:01:52
问题 I get the following message with this code case when substring(New_Limit,11,1)=' ' then '0'+substring(New_Limit,1,10) The 'then' bit is meant to concat the 0 and substring. Any help? 回答1: This means that your New_Limit variable is a numeric value. You may want to put a CAST to (n)varchar around it. 回答2: You try to cast it to a string type (varchar) first: SUBSTRING(CAST(New_Limit AS varchar(38)), 11, 1) 来源: https://stackoverflow.com/questions/13647370/argument-data-type-numeric-is-invalid-for

how to protect database from windows authentication

旧街凉风 提交于 2021-02-11 15:33:05
问题 I want to deploy .net application on client machine.I don't know how to protect my database from from windows authentication. I want to access my database only from defined sqlserver authenticated user. I am Using sqlserver 2008 R2. 回答1: From MSDN discussion: You cannot disable Windows Authentication on SQL Server. In fact, SQL Server recognizes two modes of security: 1) Windows Authentication 2) SQL Server AND Windows Authentication There's a way out, however. Users of the Adminstrators

how to protect database from windows authentication

戏子无情 提交于 2021-02-11 15:32:10
问题 I want to deploy .net application on client machine.I don't know how to protect my database from from windows authentication. I want to access my database only from defined sqlserver authenticated user. I am Using sqlserver 2008 R2. 回答1: From MSDN discussion: You cannot disable Windows Authentication on SQL Server. In fact, SQL Server recognizes two modes of security: 1) Windows Authentication 2) SQL Server AND Windows Authentication There's a way out, however. Users of the Adminstrators

How to generate table name by datetime?

笑着哭i 提交于 2021-02-11 00:32:14
问题 I realize this is syntactically bad but I figure it somewhat explains what I'm trying to do. Essentially, I have a batch job that is going to run each morning on a small table and as a part of the spec I need to create a backup prior to each load that can be accessed by a report. What I have so far is: select * into report_temp.MSK_Traffic_Backup_ + getdate() from property.door_traffic How can I make this function or should I consider doing this a better way? 回答1: DECLARE @d CHAR(10) =

How to generate table name by datetime?

↘锁芯ラ 提交于 2021-02-11 00:31:23
问题 I realize this is syntactically bad but I figure it somewhat explains what I'm trying to do. Essentially, I have a batch job that is going to run each morning on a small table and as a part of the spec I need to create a backup prior to each load that can be accessed by a report. What I have so far is: select * into report_temp.MSK_Traffic_Backup_ + getdate() from property.door_traffic How can I make this function or should I consider doing this a better way? 回答1: DECLARE @d CHAR(10) =

How to describe strings ending with one or two numbers in one LIKE pattern?

ε祈祈猫儿з 提交于 2021-02-10 18:33:27
问题 When I am searching for a string ending with one or two numbers, I am using the following pattern: WHERE MyString LIKE 'ABC[0-9]' OR MyString LIKE 'ABC[0-9][0-9]' Is there a way to express my intent in one single equivalent pattern? 回答1: If LIKE supported regex quantifier syntax, you would do: LIKE 'ABC[0-9]{1,2}' However, according to the spec it does not. If you do not want to use the regular expression functions, then you are stuck with what you have. 回答2: You can use regular expressions

Calculating Geometrically Linked Returns in SQL SERVER 2008

空扰寡人 提交于 2021-02-10 12:11:34
问题 Calculating geometrically link returns How do you multiply record2 * record1? The desire is to return a value for actual rate and annulized rate Given table unterval: EndDate PctReturn ------------------------------- 1. 05/31/06 -0.2271835 2. 06/30/06 -0.1095986 3. 07/31/06 0.6984908 4. 08/31/06 1.4865360 5. 09/30/06 0.8938896 The desired output should look like this: EndDate PctReturn Percentage UnitReturn 05/31/06 -0.2271835 -0.002272 0.997728 06/30/06 -0.1095986 -0.001096 0.996634669 07/31

Temp Table unique across multiple requests on the same connection pool?

眉间皱痕 提交于 2021-02-10 08:48:08
问题 I have the following stored proc which uses a temp table to bulk import the data. I understand the temp tables are unique for every session, however i'm wondering if my application uses threads and makes multiple concurrent request to the stored proc, using the same sql connection from the application pool, will they end up referencing the same temp table? CREATE PROCEDURE [dbo].[Mytestproc] AS BEGIN BEGIN TRANSACTION CREATE TABLE #Hold ( ID INT, VAL NVARCHAR(255) ) BULK INSERT #Hold FROM 'C:

Temp Table unique across multiple requests on the same connection pool?

时光怂恿深爱的人放手 提交于 2021-02-10 08:48:08
问题 I have the following stored proc which uses a temp table to bulk import the data. I understand the temp tables are unique for every session, however i'm wondering if my application uses threads and makes multiple concurrent request to the stored proc, using the same sql connection from the application pool, will they end up referencing the same temp table? CREATE PROCEDURE [dbo].[Mytestproc] AS BEGIN BEGIN TRANSACTION CREATE TABLE #Hold ( ID INT, VAL NVARCHAR(255) ) BULK INSERT #Hold FROM 'C:

Referencing a previous row value for an arithmetic calculation in SQL Server 2008 R2

断了今生、忘了曾经 提交于 2021-02-10 06:32:54
问题 I am working with SQL Server 2008 R2 and new to relational database. I need to run a simple calculation but the calculation involves using a previous row value. Example: (Value of X) / ((Value of Y at time t + Value of Y at time t-1) / 2) Example: select (x/[(y@time,t + y@time,t-1)/2]) as 'Value' from datatable select ((c.ACHQ)/(c.RECTQ(row:n) + c.RETQ(row:n-1))/2) as 'AR' from co_ifndq c where c.GVKEY in (select GVKEY from spidx_cst where DATADATE = '2012-03-12' and INDEXID = '500') and c