Tuesday, June 4, 2013

[T-SQL] column with foreign keys

[T-SQL] column with foreign keys


column with foreign keys

Posted: 03 Jun 2013 08:07 AM PDT

I have a table with a column id and a column with a list of foreign ids.------------------------------------| ID | PRICE | LIST_OF_FOREIGN_IDS |------------------------------------| 3 | 89 | 67,68,69 |------------------------------------| 4 | 120 | 45,46 |------------------------------------I need a way to get a view like the one below. Any solutions, ideas?---------------------------| ID | PRICE | FOREIGN_ID |---------------------------| 3 | 89 | 67 |---------------------------| 3 | 89 | 68 |---------------------------| 3 | 89 | 69 |---------------------------| 4 | 120 | 45 |---------------------------| 4 | 120 | 46 |---------------------------

MY query is procedure is not working?

Posted: 03 Jun 2013 08:37 PM PDT

Hai Friends, i made on application my input fields are name,class.where already ve the ID,and name means go to update otherwise ll make on insert.My procedure is:=============alter procedure update_use(@name varchar(20),@class nvarchar(30))asbegindeclare @der varchar(30), @id intselect @id=id from grts if exists (select * from grts where id=@id)beginset @der='update grts set name=@name,class=@class where id=@id'endelsebegininsert into grts (name,class) values(@name,@class)endendwhat was mY error in that?

SQL Permission Script needed

Posted: 03 Jun 2013 05:08 PM PDT

I am looking for a simple sql permission script.It needs to show me username, database role membership eg. db_datareader, db_datawriter etc., and database.There are plenty of scripts on the net with object level perms, but unfortunately that's not what i am looking for.Thanks in advance!

Join to Calendar Table

Posted: 03 Jun 2013 02:23 AM PDT

Hello EveryoneI hope that you are having a very nice monday, and that you had a great weekend.I am using the Calendar table. The DDL is shown below:I need to select the FirstDateOfWeek and LastDateOfWeek using the current date, without having to query the table twice. What would be the beast way to set those two values into variables for use later in another query? If I had to query the table twice, that will have to do, but I am sure there is a much more efficient means to perform this task.I would like to simply join the table from a table that is storing a date, this is also a possibility to select the two dates from the Calendar table.[code="sql"] [dbo].[Calendar] [CalendarDate] [date] NOT NULL, [CalendarYear] [int] NOT NULL, [CalendarMonth] [int] NOT NULL, [CalendarDay] [int] NOT NULL, [DayOfWeekName] [varchar](10) NOT NULL, [FirstDateOfWeek] [date] NOT NULL, [LastDateOfWeek] [date] NOT NULL, [FirstDateOfMonth] [date] NOT NULL, [LastDateOfMonth] [date] NOT NULL, [FirstDateOfQuarter] [date] NOT NULL, [LastDateOfQuarter] [date] NOT NULL, [FirstDateOfYear] [date] NOT NULL, [LastDateOfYear] [date] NOT NULL, [BusinessDay] [bit] NOT NULL, [NonBusinessDay] [bit] NOT NULL, [Weekend] [bit] NOT NULL, [Holiday] [bit] NOT NULL, [Weekday] [bit] NOT NULL, [CalendarDateDescription] [varchar](50) NULL[/code]Thank You in advance for all your suggestions, assistance and commentsAndrew SQLDBA

Break a String apart

Posted: 03 Jun 2013 05:04 AM PDT

Hello EveryoneI hope that you are having a very nice monday.I have found a column that is storing incorrect data. How about that :))This is a sample of the data[code="sql"]1596424@DAR[/code]I want only the numerals, nothing at all past the at symbol.This is all that I need[code="sql"]1596424[/code]The length of the numeric value is not always the same length.How may I get only the numeric value from the string? I am drawing a total blank on this one.Thank you for your advice, assistance and commentsAndrew SQLDBA

No comments:

Post a Comment

Search This Blog