Transact SQL :: Select User By Name AND / OR ID

Apr 28, 2015

I'm working with the following query to try and determine if a user already exists in a DB before adding a new user.

SELECT COUNT (*) AS ENTITY_COUNT
FROM ORG_ENTITY
INNER JOIN ORG_ENTITY_TYPE ON ORG_ENTITY.N_TYPE_ID = ORG_ENTITY_TYPE.N_TYPE_ID
LEFT OUTER JOIN E_MAIL ON ORG_ENTITY.N_ORG_ENTY_ID = E_MAIL.N_ORG_ENTY_ID
WHERE (ORG_ENTITY.M_ORG_FIRST = 'paul' AND ORG_ENTITY.M_ORG_LAST = 'test')
OR ORG_ENTITY.N_USER_ID = 'TST1'

The thing is there could be an existing DB record with the same name but the new user to be added may have a different N_USER_ID in which case I want to reject the new entry. But if the name is the same and the N_USER_ID already exist then I want to reject the new entry. I'm returning an Int from my query.

View 3 Replies


ADVERTISEMENT

Transact SQL :: Select Statement Not Working In User Defined Function

Nov 3, 2015

The select statement:

SELECT DATEDIFF(n , LAG(CAST(Date AS DATETIME) + CAST(Time AS DATETIME), 1) OVER ( ORDER BY Date, Time ),
       CAST(Date AS DATETIME) + CAST(Time AS DATETIME))
   FROM [DataGapTest]

Gives the right output:

NULL
1
1
3548
0

However, when I put the statement in a function, I get only zeros as the output. It's as if the lag and current value are always the same (but they are not of course).

CREATE FUNCTION dbo.GetTimeInterval(@DATE date, @TIME time)
RETURNS INT
AS
  BEGIN
 DECLARE @timeInterval INT
   SELECT @timeInterval = DATEDIFF(n , LAG(CAST(@Date AS DATETIME) + CAST(@Time AS DATETIME), 1) OVER ( ORDER BY Date, Time ),
       CAST(@Date AS DATETIME) + CAST(@Time AS DATETIME))
   FROM dbo.[DataGapTest]
  RETURN @timeInterval
  END

View 5 Replies View Related

Transact SQL :: UPDATE Then SELECT - Return Task With Highest Priority For A Given User

May 15, 2015

I have a stored proc which evaluates a table of 'tasks' to return the task with the highest priority for a given user - at the same time, once that task has been found - I want to allocate that user to the task. 

I have created a stored proc that works...however I'm sure this requirement /pattern is common & I would like some best practice for this pattern of update and select within a transaction.

Here is some sample data:

use tempdb;
go
if OBJECT_ID('Tasks', 'U') is not null
drop table tasks;
go
create table tasks (
TaskId int identity primary key,

[Code] ....

And here's what my current stored proc looks like;

if OBJECT_ID('pGetNextTask', 'P') is not null
drop proc pGetNextTask;
go
create proc pGetNextTask (
@UserID char(10),
@TaskID int output
)

[Code] ....

View 3 Replies View Related

Transact SQL :: Allow A User To Select Data Through A View But Not Restrict Access To Underlying Table

Sep 29, 2015

I have two databases DB1 and DB2 DB1 has a source table named 'Source' I have created a login 'Test_user' in DB2 with Public access. I have also created a view named 'Test_view' in DB2 which references data from DB1.dbo.Source

How can I do the following: AS A Test_user

SELECT * FROM DB2.dbo.Test_view --Should work

SELECT * FROM DB1.dbo.Source --Should Not work

View 3 Replies View Related

Is There A Way To Show A User-friendly Error When User Did Not Select A Required Parameter ?

Apr 9, 2007

Hi all,



I was wondering whether there is a way to show the user an error when the user did not select a specific parameter.



In my case, I have two optional parameters. The user has to select either one to view the report. If the user does not select either one, I would like to show some sort of an error page indicating so. However, all i am getting is a complete blank with no report in sight. I as a developer know this is an error as a result of missing parameters, but i was wondering whether I could produce a page or direct it to a page so that the user doesn't go all horrified at an empty page ?



Thanks

Bernard

View 4 Replies View Related

Transact SQL :: Select From A Select Using Row Number With Left Join

Aug 20, 2015

The select command below will output one patient’s information in 1 row:

Patient id
Last name
First name
Address 1
OP Coverage Plan 1
OP Policy # 1
OP Coverage Plan 2

[code]...

This works great if there is at least one OP coverage.   There are 3 tables in which to get information which are the patient table, the coverage table, and the coverage history table.   The coverage table links to the patient table via pat_id and it tells me the patient's coverage plan and in which priority to bill.  The coverage history table links to the patient and coverage table via patient id and coverage plan and it gives me the effective date.  

select src.pat_id, lname, fname, addr1,
max(case when rn = 1 then src.coverage_plan_ end) as OP_Coverage1,
max(case when rn = 1 then src.policy_id end) as OP_Policy1,

code]...

View 6 Replies View Related

Reporting Services :: Select Text Field Dataset Based On User Select Option?

Aug 4, 2015

I have a report that uses different datasets based on the year selected by a user.

I have a year_id parameter that sets a report variable named dataset_chosen. I have varified that these are working correctly together.

I have attempted populating table cell data to display from the chosen dataset. As yet to no avail.

How could I display data from the dataset a user selects via the year_id options?

View 4 Replies View Related

Transact SQL :: Pass Results From Select To Another Select

Oct 13, 2015

I've got a select as follows:

select computer, count(*) as MissedCount  from WInUpdates_Neededreq
WHERE LoggedDate BETWEEN DATEADD (DAY, - 5, GETDATE()) AND GETDATE() and LastReportTime !< DATEADD (DAY, -5, GETDATE())
group by computer

I need to make a join onto another table but don't want to lose the coutn(*) as MissedCount.

How can I join to another table and still keep the count form the original table.  I want ot join to tblogons.workstationname and return computer from the original query...

View 16 Replies View Related

Transact SQL :: Create A User For Only One Database

Jul 17, 2015

I have a Java application (APP) that use SQL Server 2008 - 20014. In the SQL server there can be more than my database. During setup of the database the first user (ex:ADM) is created using MS SQL Server Management Studio (SMS). ADM can then launch the APP with proper credentials and connect to the database.ADM can then, in the APP, create new users for the APP and database. After some testing for proper CREATE and GRANTS I use the following code to create a new Create, Read, Update, Delete (CRUD) user for the APP and database: CREATE LOGIN testuser WITH PASSWORD='password', DEFAULT_DATABASE = testdb

USE testdb
CREATE USER testuser FOR LOGIN testuser
GRANT AUTHENTICATE TO testuser WITH GRANT OPTION
GRANT CONNECT TO testuser WITH GRANT OPTION
GRANT ALTER ANY USER TO testuser WITH GRANT OPTION
GRANT CONNECT SQL TO testuser WITH GRANT OPTION
GRANT INSERT,SELECT,UPDATE, EXECUTE, DELETE TO testuser WITH GRANT OPTION

USE master
GRANT CONTROL SERVER TO testuser

USE testdb..When I the use the SMS and look at security the "testuser" is only added to testdb. To test I create a second database "testdb2" --> launch the APP to connect to testdb2 and can login with "testuser".I don't know if I give to much grants or missing one...proper TSQL so new users only have CRUD access to "testdb" and no other database on the SQL server.

View 5 Replies View Related

Is It Possible To Extend SQL-TRANSACT With User-defined Function

Jun 20, 2000

View 3 Replies View Related

User-Defined String Functions Transact-SQL

May 3, 2005

Ladies and Gentlemen,

I would like to offer you the following string functions Transact-SQL

GETWORDCOUNT() Counts the words in a string
GETWORDNUM() Returns a specified word from a string
AT() Returns the beginning numeric position of the first occurrence of a character expression within
another character expression, counting from the leftmost character
RAT() Returns the numeric position of the last (rightmost) occurrence of a character string within
another character string
OCCURS() Returns the number of times a character expression occurs within another character expression
PADL() Returns a string from an expression, padded with spaces or characters to a specified length on the left side
PADR() Returns a string from an expression, padded with spaces or characters to a specified length on the right side
PADC() Returns a string from an expression, padded with spaces or characters to a specified length on the both sides
PROPER() Returns from a character expression a string capitalized as appropriate for proper names
RCHARINDEX() Is similar to a built-in function Transact-SQL charindex but the search of which is on the right
ARABTOROMAN() Returns the character Roman number equivalent of a specified numeric expression
ROMANTOARAB() Returns the number equivalent of a specified character Roman number expression ...

More than 2000 people have already downloaded my functions. I hope you will find it useful as well.

For more information about string UDFs Transact-SQL please visit the
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,54,33,27115

Please, download the file
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,2,27115

With the best regards

View 2 Replies View Related

[OT] User-Defined String Functions Transact-SQL

Nov 17, 2005

Ladies and Gentlemen,

I am pleased to offer, free of charge, the following string functions Transact-SQL:

AT(): Returns the beginning numeric position of the nth occurrence of a character expression within another character expression, counting from the leftmost character.
RAT(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string.
OCCURS(): Returns the number of times a character expression occurs within another character expression (including overlaps).
OCCURS2(): Returns the number of times a character expression occurs within another character expression (excluding overlaps).
PADL(): Returns a string from an expression, padded with spaces or characters to a specified length on the left side.
PADR(): Returns a string from an expression, padded with spaces or characters to a specified length on the right side.
PADC(): Returns a string from an expression, padded with spaces or characters to a specified length on the both sides.
CHRTRAN(): Replaces each character in a character expression that matches a character in a second character expression with the corresponding character in a third character expression.
STRTRAN(): Searches a character expression for occurrences of a second character expression, and then replaces each occurrence with a third character expression. Unlike a built-in function Replace, STRTRAN has three additional parameters.
STRFILTER(): Removes all characters from a string except those specified.
GETWORDCOUNT(): Counts the words in a string.
GETWORDNUM(): Returns a specified word from a string.
GETALLWORDS(): Inserts the words from a string into the table.
PROPER(): Returns from a character expression a string capitalized as appropriate for proper names.
RCHARINDEX(): Similar to the Transact-SQL function Charindex, with a Right search.
ARABTOROMAN(): Returns the character Roman numeral equivalent of a specified numeric expression (from 1 to 3999).
ROMANTOARAB(): Returns the number equivalent of a specified character Roman numeral expression (from I to MMMCMXCIX).

AT, PADL, PADR, CHRTRAN, PROPER: Similar to the Oracle functions PL/SQL INSTR, LPAD, RPAD, TRANSLATE, INITCAP.

Plus, there are CHM files in English, French, Spanish, German and Russian.


More than 6000 people have already downloaded my functions. I hope you will find them useful as well.

For more information about string UDFs Transact-SQL please visit the
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,54,33,27115

Please, download the file
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,2,27115

With the best regards.

View 3 Replies View Related

User-Defined String Functions Transact-SQL (New)

May 27, 2005

Ladies and Gentlemen,

I would like to offer you the following string functions Transact-SQL

GETWORDCOUNT() Counts the words in a string
GETWORDNUM() Returns a specified word from a string
AT() Returns the beginning numeric position of the first occurrence of a character expression within another character expression, counting from the leftmost character
RAT() Returns the numeric position of the last (rightmost) occurrence of a character string within another character string
CHRTRAN() Replaces each character in a character expression that matches a character in a second character expression with the corresponding character in a third character expression
STRFILTER() Removes all characters from a string except those specified
OCCURS() Returns the number of times a character expression occurs within another character expression (include overlaps)
PADL() Returns a string from an expression, padded with spaces or characters to a specified length on the left side
PADR() Returns a string from an expression, padded with spaces or characters to a specified length on the right side
PADC() Returns a string from an expression, padded with spaces or characters to a specified length on the both sides
PROPER() Returns from a character expression a string capitalized as appropriate for proper names
RCHARINDEX() Is similar to a built-in function Transact-SQL charindex but the search of which is on the right
ARABTOROMAN() Returns the character Roman number equivalent of a specified numeric expression (from 1 to 3999)
ROMANTOARAB() Returns the number equivalent of a specified character Roman number expression (from I to MMMCMXCIX)

AT, PADL, PADR, CHRTRAN, PROPER are similar to functions Oracle PL/SQL INSTR, LPAD, RPAD, TRANSLATE, INITCAP

More than 2000 people have already downloaded my functions. I hope you will find it useful as well.

For more information about string UDFs Transact-SQL please visit the
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,54,33,27115
Please, download the file
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,2,27115

With the best regards.

View 2 Replies View Related

User-Defined String Functions Transact-SQL

Jun 3, 2005

Ya know...I don't think I would Ever be able to build those functions if I needed them.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50370


You must be a very clever developer




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

View 20 Replies View Related

Transact SQL :: How To Find If User Not Logged In For 45 Days

Nov 20, 2015

I have created table called Login in sql server where i have column usercode, email and login_date (login_date is datetime type)So, i created web application using .net. whenever user logged in, i am allowing based userLoged table and  i am inserting into login table.

login table usercode  email       login_date
001          a@gmail.com    2015-11-18 22:02:41.153
001          a@gmail.com    xxx
.
.
.

I have another table called userLoged where i have column usercode,email and web_access 

UserLoged table usercode email         web_access
001         a@gmail.com   Y

Now, if a@gmail.com (001) is not logged in for 45 days, i need to update web_access to be 'N' how to know if he /she not logged for 45 days.

View 4 Replies View Related

Transact SQL :: User Defined Number Of Days

May 8, 2015

I am new to sql server query. I am trying to write a query for an application and I want user to enter number of over due days for payment.Below is my query and I am getting an error: An expression of non-boolean type specified in a context where a condition is expected, near 'Group'.

SELECT (P.FirstName+', '+P.LastName) As PA, Px.PRespDate,Px.DateFrom
 WHERE Px.Hide = 0 AND Px.Total <> Px.Payments AND Px.PRespDate IS NOT NULL AND PE.Hide = 0 AND PE.BillReady = 1 
AND DATEDIFF(DAY, Px.DateFrom, PRespDate)  LIKE 'Enter # of days |%% '
Group By (P.FirstName+', '+P.LastName), Px.PRespDate,Px.DateFrom

View 2 Replies View Related

Free User-Defined String Functions Transact-SQL

Apr 17, 2005

Ladies and Gentlemen,

I would like to offer you the following string functions Transact-SQL

GETWORDCOUNT() Counts the words in a string
GETWORDNUM() Returns a specified word from a string
AT() Returns the beginning numeric position of the first occurrence of a character expression within
another character expression, counting from the leftmost character
RAT() Returns the numeric position of the last (rightmost) occurrence of a character string within
another character string
OCCURS() Returns the number of times a character expression occurs within another character expression
PADL() Returns a string from an expression, padded with spaces or characters to a specified length on the left side
PADR() Returns a string from an expression, padded with spaces or characters to a specified length on the right side
PADC() Returns a string from an expression, padded with spaces or characters to a specified length on the both sides
PROPER() Returns from a character expression a string capitalized as appropriate for proper names
RCHARINDEX() Is similar to a built-in function Transact-SQL charindex but the search of which is on the right
ARABTOROMAN() Returns the character Roman number equivalent of a specified numeric expression
ROMANTOARAB() Returns the number equivalent of a specified character Roman number expression ...

For more information about string UDFs Transact-SQL please visit the
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,54,33,27115




Please, download the file http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,2,27115

With the best regards

View 1 Replies View Related

Free User-Defined String Functions Transact-SQL

Apr 17, 2005

Description
GETWORDCOUNT() Counts the words in a string
GETWORDNUM() Returns a specified word from a string
AT() Returns the beginning numeric position of the first occurrence of a character expression within
another character expression, counting from the leftmost character
RAT() Returns the numeric position of the last (rightmost) occurrence of a character string within
another character string
OCCURS() Returns the number of times a character expression occurs within another character expression
PADL() Returns a string from an expression, padded with spaces or characters to a specified length on the left side
PADR() Returns a string from an expression, padded with spaces or characters to a specified length on the right side
PADC() Returns a string from an expression, padded with spaces or characters to a specified length on the both sides
PROPER() Returns from a character expression a string capitalized as appropriate for proper names
RCHARINDEX() Is similar to a built-in function Transact-SQL charindex but the search of which is on the right

For more information about string UDFs Transact-SQL please visit the
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,54,33,27115

View 1 Replies View Related

Transact SQL :: Getting NULL For User Defined Data Types

Nov 27, 2015

I have a table RequestUtility with 3 columns Vendor, name, system. I want to call this table from BizTalk so that I send multiple vendors and will get corresponding Vendor, name and system for that. As I need to send multiple vendors at the same time I have created a User-Defined Table type VendorNames with a single column Names. and have written a SP :

ALTER PROCEDURE [dbo].[GetName]
 -- Add the parameters for the stored procedure here
 @vendorN VendorNames ReadOnly
AS
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;
    -- Select statements for procedure here
 SELECT * from dbo.RequestUtility where Vendor IN (SELECT Names from @vendorN)

This is working fine when the value for vendor is present in the table. But if the value is not present it is not returning any thing. But, my requirement is that for example vendor is Dummy which is not present in the table so it should return

Vendor   Name  System
Dummy  NULL   NULL

But currently it is not returning anything.

View 7 Replies View Related

Transact SQL :: How To Check If Current User Has Sysadmin Privs

May 27, 2015

Is there a simple command that can be executed to check if the current user has sysadmin privs?  I just want to check to see if I have sysadmin privs and if so then execute a command, if not do nothing in .Net code.  I just want to do this check once and set a variable in the .net code.

View 4 Replies View Related

Transact SQL :: Script That Creates User Mapping For Network Service

Aug 20, 2015

SQL script that creates a User Mapping for NT AUTHORITYNETWORK SERVICE to a database?

View 3 Replies View Related

Transact SQL :: Change Structure Of User Defined Table Types

Nov 4, 2015

Change structure of a User Defined Table Types

      field
([idConteudo] [int]
NULL)      to     
 ([idConteudo] [BigInt]
NULL)

Or really should drop and create again?

CREATE TYPE [dbo].[tbProjeto] AS TABLE(
[dsConteudo] [varchar](64) NOT NULL,
[idConteudo] [int] NULL,
[dtConteudo] [datetime] NULL DEFAULT (getdate())
)
GO

View 4 Replies View Related

Transact SQL :: Login Name Of User Inserting Into Table With Execute As DML Trigger?

Jun 24, 2015

Suppose you have a simple DML "execute as..." trigger that looks like this:

CREATE TRIGGER dbo.myTrigger
 ON dbo.myTable
 WITH Execute As Owner
 AFTER INSERT
AS

[code]...

which runs as "owner" so that the user inserting into "myTable" won't have the privs to edit the audit table.How does one capture the identity of the user whose insert statement caused the trigger to fire?  I've tried "current_user" and "system_user" without success when "execute as ..." is used: they each return a value not related to the identity of the user running the original insert.without an "execute as" clause, what prevents a user from adding to or editing the audit table directly?

View 6 Replies View Related

Transact SQL :: How To Restart Or Take DB In Single User Mode By Honoring All Requests

Oct 8, 2015

some times i need to take db in single user mode , which can be done using following

ALTER DATABASE xyz
SET  SINGLE_USER WITH NO_WAIT

this has other options but each one has some problems like if any single window is open at any location etc etc.

Q1)so the need is i want to honor running transaction from  msss or any application then i want db to get into single mode so that i can perform my task.

Q2)  some times i need to restart db as it becomes slow , i am trying to find the reason primarily i have seen it  is memory.so i want to restart my db honoring all requests.

View 6 Replies View Related

Transact SQL :: Adding Database - Single User Mode Freeze

Oct 5, 2015

I would like to add database to single user mode to enable broker. So, i have tried this:

ALTER DATABASE myDb SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE myDb SET ENABLE_BROKER
ALTER DATABASE myDb SET MULTI_USER

But the query works more than half an hour then i have stopped it. i guess it has infinite loop, I get also many of this messages:

Nonqualified transactions are being rolled back. Estimated rollback completion: 0%.

There is no other transaction also there is no other user connections. So, what happens?

View 5 Replies View Related

Transact SQL :: Maintain Log Table Of User Into Separate Database In Server

Sep 4, 2015

I have a table tbl_User(ID,UserName,UserPassword,UserStatus).

When some value insert into tbl_User the log data should insert in to another database table. How can I achieve this ???

Is any new features related to trigger that can be done in new database from one???

SQL Server 2014 Enterprise

View 5 Replies View Related

Transact SQL :: How To Select Inverse

Jun 8, 2015

I have two tables

first table name is table_VR and it has one column named CsNo and following values

table_VR
CsNo
1
2
3

second table is table_VS and it has also one column named CsNo and following values

CsNo
1
2
7

Now i want follow result

Select CsNo from table_VR where CsNo does not match with CsNo of Table_VS

result would be following

CsNo
3

so you saw in table_VR first two records matches in table_VS but the thirst row value does not match.I am not understanding what would be the query to get this result.

View 6 Replies View Related

Transact SQL :: Multiple Select CTE

Jun 11, 2015

I have database with three tables Accounts, Results, and ClosedOrders. All are connected through AccountID PK/FK.

I got a wonderful select statement that gives me the latest Results for each Account.

WITH cte AS
(
SELECT
Accounts.AccountID,
Accounts.AccountName,
Results.ResultTime AS LastUpdated,

[Code] ....

I've been struggling to extend this with two more columns from the ClosedOrders table. How to add columns to the this view? Basically what I need is this:

SELECT SUM([Lots]) AS Longs
FROM [DEV].[dbo].[ClosedOrders]
WHERE OrderTypeID = 0;

SELECT SUM([Lots]) AS Shorts
FROM [DEV].[dbo].[ClosedOrders]
WHERE OrderTypeID = 1;

But it has to "join" the CTE somehow so that I get the correct answer for each Account row.

View 14 Replies View Related

[OT] User-Defined String Functions MS SQL Server 2005 Transact-SQL SQLCLR .Net

Feb 7, 2006

User-Defined string Functions MS SQL Server 2005 Transact-SQL SQLCLR (VB. Net, C#.Net, C++. Net)

Ladies and Gentlemen,

I am pleased to offer, free of charge, the following string functions MS SQL Server 2005 Transact-SQL SQLCLR (VB. Net, C#.Net, C++. Net):

AT(): Returns the beginning numeric position of the nth occurrence of a character expression within another character expression, counting from the leftmost character.
RAT(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string.
OCCURS(): Returns the number of times a character expression occurs within another character expression (including overlaps).
OCCURS2(): Returns the number of times a character expression occurs within another character expression (excluding overlaps).
PADL(): Returns a string from an expression, padded with spaces or characters to a specified length on the left side.
PADR(): Returns a string from an expression, padded with spaces or characters to a specified length on the right side.
PADC(): Returns a string from an expression, padded with spaces or characters to a specified length on the both sides.
CHRTRAN(): Replaces each character in a character expression that matches a character in a second character expression with the corresponding character in a third character expression.
STRTRAN(): Searches a character expression for occurrences of a second character expression, and then replaces each occurrence with a third character expression. Unlike a built-in function Replace, STRTRAN has three additional parameters.
STRFILTER(): Removes all characters from a string except those specified.
GETWORDCOUNT(): Counts the words in a string.
GETWORDNUM(): Returns a specified word from a string.
GETALLWORDS(): Inserts the words from a string into the table.
PROPER(): Returns from a character expression a string capitalized as appropriate for proper names.
RCHARINDEX(): Similar to the Transact-SQL function Charindex, with a Right search.
ARABTOROMAN(): Returns the character Roman numeral equivalent of a specified numeric expression (from 1 to 3999).
ROMANTOARAB(): Returns the number equivalent of a specified character Roman numeral expression (from I to MMMCMXCIX).

AT, PADL, PADR, CHRTRAN, PROPER: Similar to the Oracle functions PL/SQL INSTR, LPAD, RPAD, TRANSLATE, INITCAP.

Plus, there are CHM files in English, French, Spanish, German and Russian.

Plus, there are versions for MS SQL SERVER, SYBASE ASA, DB2, Oracle.

More than 8000 people have already downloaded my functions. I hope you will find them useful as well.

For more information about string UDFs MS SQL Server 2005 Transact-SQL SQLCLR (VB. Net, C#.Net, C++. Net) please visit the
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,54,33,29527

Please, download the file
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,2,29527

With the best regards.

View 1 Replies View Related

Transact SQL :: Return Preset Data Values Based On User Material ID

Jul 22, 2015

I have 2 tables each containing a material type. Table 1 contains material from their 3D application. Table 2 contains material with specific values that is not ours and we cannot rename or edit the data. I need a type of junction or mapping table that can connect the user material to the preset material. for example:

User Material = Wood-MDF
Preset Material = MDF Panel

I figured that i would make this table with 3 fields (ID, UserMaterialID, PresetMaterialID).How would i then construct a query view / Stored procedure that would return the Preset data values based on the user material id?

View 2 Replies View Related

Transact SQL :: Cannot Perform Shrink File Operation Inside User Transaction

Sep 18, 2015

I am getting an error about "Cannot perform a shrinkfile operation inside a user transaction", but I don't have a shrinkfile command in my procedure.  Does SQL hang on to that command if it was received earlier in a different procedure?

View 5 Replies View Related

Transact SQL :: Select (sum) Statements With Two Table?

Jun 5, 2015

I have a database with two tables (Table1 and Table2)

looking for something like:

Table1:
+----+-------+----------+
| id   | Name | email    |
+----+-------+----------+
|  1 | name1 | mail1    |
|  2 | name2 | mail2    |
|  3 | name3 | mail3    |
|  4 | name4 | mail4    |
|  5 | name5 | mail5    |
|  6 | name6 | mail6    |
+-- +-------+----------+

Table2:
+----+------------+---------+------+
| id   | table1_ID | fee       | type |
+---+-------------+---------+------+
|  1 |     1           | 20000  |     1 |
|  2 |     3           | 1000    |     1 |
|  3 |     1           | 10000  |     1 |
|  4 |     3           | 1000    |     1 |
|  5 |     5           | 500      |     1 |
|  6 |     5           | 500      |     2 |
|  7 |     1           | 60000  |     2 |
|  8 |     2           | 1000    |     2 |
+----+------------+---------+-------+

i want the query that return:

+--------+-------+---------------------------------+---------------------------------+--------+
| name  | email | a:sum(fee) where type=1   | b:sum(fee) where type=2   |  b/10  |
+--------+-------+---------------------------------+---------------------------------+--------+
|name1 | mail1 |         30000                        |       60000                         |  6000|
|name2 | mail2 |           0                              |        1000                          |  100    |
|name3 | mail3 |          2000                         |          0                              |   0       | 
|name4 | mail4 |           0                              |          0                              |   0       |
|name5 | mail5 |          500                           |         500                           |   50     |
|name6 | mail6 |           0                              |          0                              |   0       |
+--------+-------+---------------------------+---------------------------------------+---------+

View 4 Replies View Related

Transact SQL :: Select Conditional Dates

Oct 15, 2015

TSQL statement, it should select the first date of the month at 11:59 PM as Firstdate and Closedate as 10 days later at 11:59 PM.

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved